Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6d3e5d0

Browse files
committed
[FrameworkBundle] fixed yaml:lint when yaml is not installed along side framwork-bundle
1 parentf1c1e37 commit6d3e5d0

File tree

2 files changed

+72
-22
lines changed

2 files changed

+72
-22
lines changed

‎src/Symfony/Bundle/FrameworkBundle/Command/YamlLintCommand.php‎

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
namespaceSymfony\Bundle\FrameworkBundle\Command;
1313

14+
useSymfony\Component\Console\Command\Command;
15+
useSymfony\Component\Console\Input\InputInterface;
16+
useSymfony\Component\Console\Output\OutputInterface;
1417
useSymfony\Component\Yaml\Command\LintCommandasBaseLintCommand;
1518

1619
/**
@@ -19,17 +22,39 @@
1922
* @author Grégoire Pineau <lyrixx@lyrixx.info>
2023
* @author Robin Chalas <robin.chalas@gmail.com>
2124
*/
22-
class YamlLintCommandextendsBaseLintCommand
25+
class YamlLintCommandextendsCommand
2326
{
27+
private$command;
28+
2429
/**
2530
* {@inheritdoc}
2631
*/
2732
protectedfunctionconfigure()
2833
{
29-
parent::configure();
34+
$this->setName('lint:yaml');
35+
36+
if (!$this->isEnabled() &&null !==$this->command) {
37+
return;
38+
}
39+
40+
$directoryIteratorProvider =function ($directory,$default) {
41+
if (!is_dir($directory)) {
42+
$directory =$this->getApplication()->getKernel()->locateResource($directory);
43+
}
44+
45+
return$default($directory);
46+
};
47+
48+
$isReadableProvider =function ($fileOrDirectory,$default) {
49+
return0 ===strpos($fileOrDirectory,'@') ||$default($fileOrDirectory);
50+
};
3051

31-
$this->setHelp(
32-
$this->getHelp().<<<EOF
52+
$this->command =newBaseLintCommand(null,$directoryIteratorProvider,$isReadableProvider);
53+
54+
$this
55+
->setDescription($this->command->getDescription())
56+
->setDefinition($this->command->getDefinition())
57+
->setHelp($this->command->getHelp().<<<EOF
3358
3459
Or find all files in a bundle:
3560
@@ -39,17 +64,16 @@ protected function configure()
3964
);
4065
}
4166

42-
protectedfunctiongetDirectoryIterator($directory)
67+
/**
68+
* {@inheritdoc}
69+
*/
70+
publicfunctionisEnabled()
4371
{
44-
if (!is_dir($directory)) {
45-
$directory =$this->getApplication()->getKernel()->locateResource($directory);
46-
}
47-
48-
returnparent::getDirectoryIterator($directory);
72+
returnclass_exists(BaseLintCommand::class) &&parent::isEnabled();
4973
}
5074

51-
protectedfunctionisReadable($fileOrDirectory)
75+
protectedfunctionexecute(InputInterface$input,OutputInterface$output)
5276
{
53-
return0 ===strpos($fileOrDirectory,'@') ||parent::isReadable($fileOrDirectory);
77+
return$this->command->execute($input,$output);
5478
}
5579
}

‎src/Symfony/Component/Yaml/Command/LintCommand.php‎

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ class LintCommand extends Command
3030
private$parser;
3131
private$format;
3232
private$displayCorrectFiles;
33+
private$directoryIteratorProvider;
34+
private$isReadableProvider;
35+
36+
publicfunction__construct($name =null,$directoryIteratorProvider =null,$isReadableProvider =null)
37+
{
38+
parent::__construct($name);
39+
40+
$this->directoryIteratorProvider =$directoryIteratorProvider;
41+
$this->isReadableProvider =$isReadableProvider;
42+
}
3343

3444
/**
3545
* {@inheritdoc}
@@ -170,14 +180,6 @@ private function getFiles($fileOrDirectory)
170180
}
171181
}
172182

173-
protectedfunctiongetDirectoryIterator($directory)
174-
{
175-
returnnew \RecursiveIteratorIterator(
176-
new \RecursiveDirectoryIterator($directory, \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS),
177-
\RecursiveIteratorIterator::LEAVES_ONLY
178-
);
179-
}
180-
181183
privatefunctiongetStdin()
182184
{
183185
if (0 !==ftell(STDIN)) {
@@ -201,8 +203,32 @@ private function getParser()
201203
return$this->parser;
202204
}
203205

204-
protectedfunctionisReadable($fileOrDirectory)
206+
privatefunctiongetDirectoryIterator($directory)
205207
{
206-
returnis_readable($fileOrDirectory);
208+
$default =function ($directory) {
209+
returnnew \RecursiveIteratorIterator(
210+
new \RecursiveDirectoryIterator($directory, \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS),
211+
\RecursiveIteratorIterator::LEAVES_ONLY
212+
);
213+
};
214+
215+
if (null !==$this->directoryIteratorProvider) {
216+
returncall_user_func($this->directoryIteratorProvider,$directory,$default);
217+
}
218+
219+
return$default($directory);
220+
}
221+
222+
privatefunctionisReadable($fileOrDirectory)
223+
{
224+
$default =function ($fileOrDirectory) {
225+
returnis_readable($fileOrDirectory);
226+
};
227+
228+
if (null !==$this->isReadableProvider) {
229+
returncall_user_func($this->isReadableProvider,$fileOrDirectory,$default);
230+
}
231+
232+
return$default($fileOrDirectory);
207233
}
208234
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp