Skip to content

Commit 16aa769

Browse files
kalessilfabpot
authored andcommitted
[2.6] Static Code Analysis for Components and Bundles
1 parent c37b4b6 commit 16aa769

File tree

7 files changed

+20
-20
lines changed

7 files changed

+20
-20
lines changed

Command/TranslationDebugCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
9595
);
9696

9797
foreach ($bundlePaths as $path) {
98-
$path = $path.'views';
98+
$path .= 'views';
9999
if (is_dir($path)) {
100100
$this->getContainer()->get('translation.extractor')->extract($path, $extractedCatalogue);
101101
}
@@ -104,7 +104,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
104104
// Load defined messages
105105
$currentCatalogue = new MessageCatalogue($locale);
106106
foreach ($bundlePaths as $path) {
107-
$path = $path.'translations';
107+
$path .= 'translations';
108108
if (is_dir($path)) {
109109
$loader->loadMessages($path, $currentCatalogue);
110110
}

Command/TranslationUpdateCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
108108
$extractor = $this->getContainer()->get('translation.extractor');
109109
$extractor->setPrefix($input->getOption('prefix'));
110110
foreach ($transPaths as $path) {
111-
$path = $path.'views';
111+
$path .= 'views';
112112
if (is_dir($path)) {
113113
$extractor->extract($path, $extractedCatalogue);
114114
}
@@ -119,7 +119,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
119119
$output->writeln('Loading translation files');
120120
$loader = $this->getContainer()->get('translation.loader');
121121
foreach ($transPaths as $path) {
122-
$path = $path.'translations';
122+
$path .= 'translations';
123123
if (is_dir($path)) {
124124
$loader->loadMessages($path, $currentCatalogue);
125125
}
@@ -168,7 +168,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
168168
$output->writeln('Writing files');
169169
$bundleTransPath = false;
170170
foreach ($transPaths as $path) {
171-
$path = $path.'translations';
171+
$path .= 'translations';
172172
if (is_dir($path)) {
173173
$bundleTransPath = $path;
174174
}

Console/Descriptor/TextDescriptor.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o
174174
$serviceIds = isset($options['tag']) && $options['tag'] ? array_keys($builder->findTaggedServiceIds($options['tag'])) : $builder->getServiceIds();
175175
$maxTags = array();
176176

177-
foreach ($serviceIds as $key => $serviceId) {
177+
foreach ($serviceIds as $key => $serviceId) {
178178
$definition = $this->resolveServiceDefinition($builder, $serviceId);
179179
if ($definition instanceof Definition) {
180180
// filter out private services unless shown explicitly
@@ -212,7 +212,7 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o
212212
foreach ($definition->getTag($showTag) as $key => $tag) {
213213
$tagValues = array();
214214
foreach ($tagsNames as $tagName) {
215-
$tagValues[] = isset($tag[$tagName]) ? $tag[$tagName] : "";
215+
$tagValues[] = isset($tag[$tagName]) ? $tag[$tagName] : '';
216216
}
217217
if (0 === $key) {
218218
$table->addRow(array_merge(array($serviceId), $tagValues, array($definition->getClass())));
@@ -225,10 +225,10 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o
225225
}
226226
} elseif ($definition instanceof Alias) {
227227
$alias = $definition;
228-
$table->addRow(array_merge(array($serviceId, sprintf('alias for "%s"', $alias)), $tagsCount ? array_fill(0, $tagsCount, "") : array()));
228+
$table->addRow(array_merge(array($serviceId, sprintf('alias for "%s"', $alias)), $tagsCount ? array_fill(0, $tagsCount, '') : array()));
229229
} else {
230230
// we have no information (happens with "service_container")
231-
$table->addRow(array_merge(array($serviceId, get_class($definition)), $tagsCount ? array_fill(0, $tagsCount, "") : array()));
231+
$table->addRow(array_merge(array($serviceId, get_class($definition)), $tagsCount ? array_fill(0, $tagsCount, '') : array()));
232232
}
233233
}
234234

@@ -245,7 +245,7 @@ protected function describeContainerDefinition(Definition $definition, array $op
245245
: array();
246246

247247
$description[] = sprintf('<comment>Service Id</comment> %s', isset($options['id']) ? $options['id'] : '-');
248-
$description[] = sprintf('<comment>Class</comment> %s', $definition->getClass() ?: "-");
248+
$description[] = sprintf('<comment>Class</comment> %s', $definition->getClass() ?: '-');
249249

250250
$tags = $definition->getTags();
251251
if (count($tags)) {
@@ -269,7 +269,7 @@ protected function describeContainerDefinition(Definition $definition, array $op
269269
$description[] = sprintf('<comment>Abstract</comment> %s', $definition->isAbstract() ? 'yes' : 'no');
270270

271271
if ($definition->getFile()) {
272-
$description[] = sprintf('<comment>Required File</comment> %s', $definition->getFile() ? $definition->getFile() : '-');
272+
$description[] = sprintf('<comment>Required File</comment> %s', $definition->getFile() ?: '-');
273273
}
274274

275275
if ($definition->getFactoryClass()) {

DependencyInjection/FrameworkExtension.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -642,22 +642,22 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder
642642
if (class_exists('Symfony\Component\Validator\Validator')) {
643643
$r = new \ReflectionClass('Symfony\Component\Validator\Validator');
644644

645-
$dirs[] = dirname($r->getFilename()).'/Resources/translations';
645+
$dirs[] = dirname($r->getFileName()).'/Resources/translations';
646646
}
647647
if (class_exists('Symfony\Component\Form\Form')) {
648648
$r = new \ReflectionClass('Symfony\Component\Form\Form');
649649

650-
$dirs[] = dirname($r->getFilename()).'/Resources/translations';
650+
$dirs[] = dirname($r->getFileName()).'/Resources/translations';
651651
}
652652
if (class_exists('Symfony\Component\Security\Core\Exception\AuthenticationException')) {
653653
$r = new \ReflectionClass('Symfony\Component\Security\Core\Exception\AuthenticationException');
654654

655-
$dirs[] = dirname($r->getFilename()).'/../Resources/translations';
655+
$dirs[] = dirname($r->getFileName()).'/../Resources/translations';
656656
}
657657
$overridePath = $container->getParameter('kernel.root_dir').'/Resources/%s/translations';
658658
foreach ($container->getParameter('kernel.bundles') as $bundle => $class) {
659659
$reflection = new \ReflectionClass($class);
660-
if (is_dir($dir = dirname($reflection->getFilename()).'/Resources/translations')) {
660+
if (is_dir($dir = dirname($reflection->getFileName()).'/Resources/translations')) {
661661
$dirs[] = $dir;
662662
}
663663
if (is_dir($dir = sprintf($overridePath, $bundle))) {
@@ -775,7 +775,7 @@ private function getValidatorXmlMappingFiles(ContainerBuilder $container)
775775

776776
foreach ($container->getParameter('kernel.bundles') as $bundle) {
777777
$reflection = new \ReflectionClass($bundle);
778-
if (is_file($file = dirname($reflection->getFilename()).'/Resources/config/validation.xml')) {
778+
if (is_file($file = dirname($reflection->getFileName()).'/Resources/config/validation.xml')) {
779779
$files[] = realpath($file);
780780
$container->addResource(new FileResource($file));
781781
}
@@ -790,7 +790,7 @@ private function getValidatorYamlMappingFiles(ContainerBuilder $container)
790790

791791
foreach ($container->getParameter('kernel.bundles') as $bundle) {
792792
$reflection = new \ReflectionClass($bundle);
793-
if (is_file($file = dirname($reflection->getFilename()).'/Resources/config/validation.yml')) {
793+
if (is_file($file = dirname($reflection->getFileName()).'/Resources/config/validation.yml')) {
794794
$files[] = realpath($file);
795795
$container->addResource(new FileResource($file));
796796
}

Tests/Command/CacheClearCommand/CacheClearCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ protected function setUp()
2424
{
2525
$this->fs = new Filesystem();
2626
$this->kernel = new TestAppKernel('test', true);
27-
$this->rootDir = sys_get_temp_dir().DIRECTORY_SEPARATOR.uniqid('sf2_cache_');
27+
$this->rootDir = sys_get_temp_dir().DIRECTORY_SEPARATOR.uniqid('sf2_cache_', true);
2828
$this->kernel->setRootDir($this->rootDir);
2929
$this->fs->mkdir($this->rootDir);
3030
}

Tests/Command/TranslationDebugCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function testNoDefinedMessages()
5656
protected function setUp()
5757
{
5858
$this->fs = new Filesystem();
59-
$this->translationDir = sys_get_temp_dir().'/'.uniqid('sf2_translation');
59+
$this->translationDir = sys_get_temp_dir().'/'.uniqid('sf2_translation', true);
6060
$this->fs->mkdir($this->translationDir.'/Resources/translations');
6161
$this->fs->mkdir($this->translationDir.'/Resources/views');
6262
}

Tests/Console/Descriptor/AbstractDescriptorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function getDescribeContainerParameterTestData()
9898
{
9999
$data = $this->getDescriptionTestData(ObjectsProvider::getContainerParameter());
100100

101-
array_push($data[0], array('parameter' => 'database_name'));
101+
$data[0][] = array('parameter' => 'database_name');
102102

103103
return $data;
104104
}

0 commit comments

Comments
 (0)