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

Commitc965a17

Browse files
sez-openAmrouche Hamza
authored and
Amrouche Hamza
committed
fix debug:autowiringcommand
1 parent9793522 commitc965a17

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
100100
$hasAlias = [];
101101
$all =$input->getOption('all');
102102
$previousId ='-';
103+
$serviceIdsNb =0;
103104
foreach ($serviceIdsas$serviceId) {
104105
$text = [];
105106
if (0 !==strpos($serviceId,$previousId)) {
@@ -127,11 +128,22 @@ protected function execute(InputInterface $input, OutputInterface $output)
127128
$serviceLine .=' - <fg=magenta>deprecated</>';
128129
}
129130
}elseif (!$all) {
131+
$serviceIdsNb++;
130132
continue;
131133
}
132134
$text[] =$serviceLine;
133135
$io->text($text);
134136
}
137+
138+
$io->newLine();
139+
140+
if (0 <$serviceIdsNb) {
141+
$io->text(sprintf('%s more concrete service%s would be displayed when adding the --all option.',$serviceIdsNb,$serviceIdsNb >1 ?'s' :''));
142+
}
143+
if ($all) {
144+
$io->text('Pro-tip: use interfaces in your type-hints instead of classes to benefit from the dependency inversion principle.');
145+
}
146+
135147
$io->newLine();
136148
}
137149

‎src/Symfony/Bundle/FrameworkBundle/Tests/Functional/DebugAutowiringCommandTest.php‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,29 @@ public function testSearchNoResults()
7272
$this->assertContains('No autowirable classes or interfaces found matching "foo_fake"',$tester->getErrorOutput());
7373
$this->assertEquals(1,$tester->getStatusCode());
7474
}
75+
76+
publicfunctiontestSearchNotAliasedService()
77+
{
78+
static::bootKernel(['test_case' =>'ContainerDebug','root_config' =>'config.yml']);
79+
80+
$application =newApplication(static::$kernel);
81+
$application->setAutoExit(false);
82+
83+
$tester =newApplicationTester($application);
84+
$tester->run(['command' =>'debug:autowiring','search' =>'redirect']);
85+
86+
$this->assertContains(' more concrete service would be displayed when adding the --all option.',$tester->getDisplay());
87+
}
88+
89+
publicfunctiontestSearchNotAliasedServiceWithAll()
90+
{
91+
static::bootKernel(['test_case' =>'ContainerDebug','root_config' =>'config.yml']);
92+
93+
$application =newApplication(static::$kernel);
94+
$application->setAutoExit(false);
95+
96+
$tester =newApplicationTester($application);
97+
$tester->run(['command' =>'debug:autowiring','search' =>'redirect','--all' =>true]);
98+
$this->assertContains('Pro-tip: use interfaces in your type-hints instead of classes to benefit from the dependency inversion principle.',$tester->getDisplay());
99+
}
75100
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp