Skip to content

Commit dec1e7a

Browse files
committed
minor #48 Minor code improvements (javiereguiluz)
This PR was merged into the 1.0-dev branch. Discussion ---------- Minor code improvements Spotted with PHP-CS-Fixer and Php Inspections (EA Extended). Commits ------- 51af48d Minor code improvements
2 parents a51ed03 + 51af48d commit dec1e7a

File tree

8 files changed

+10
-15
lines changed

8 files changed

+10
-15
lines changed

src/Command/AbstractCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
9898
continue;
9999
}
100100

101-
if (in_array($argument->getName(), $this->nonInteractiveArguments)) {
101+
if (in_array($argument->getName(), $this->nonInteractiveArguments, true)) {
102102
continue;
103103
}
104104

src/DependencyBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ final class DependencyBuilder
1313
* the user if other required dependencies are missing. An example
1414
* is the "validator" when trying to work with forms.
1515
*/
16-
public function addClassDependency(string $class, string $package, bool $required = true)
16+
public function addClassDependency(string $class, string $package, bool $required = true): void
1717
{
1818
$this->dependencies[$class] = [
1919
'name' => $package,

src/FileManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function fileExists($path): bool
6060

6161
private function absolutizePath($path): string
6262
{
63-
if ('/' === substr($path, 0, 1)) {
63+
if (0 === strpos($path, '/')) {
6464
return $path;
6565
}
6666

src/Generator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function __construct(FileManager $fileManager)
2828
$this->fileManager = $fileManager;
2929
}
3030

31-
public function setIO(SymfonyStyle $io)
31+
public function setIO(SymfonyStyle $io): void
3232
{
3333
$this->io = $io;
3434
$this->fileManager->setIO($io);

src/Resources/skeleton/form/Type.php.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ class {{ form_class_name }} extends AbstractType
1818

1919
public function configureOptions(OptionsResolver $resolver)
2020
{
21-
$resolver->setDefaults(array(
21+
$resolver->setDefaults([
2222
// uncomment if you want to bind to a class
2323
//'data_class' => {{ entity_class_name }}::class,
24-
));
24+
]);
2525
}
2626
}

src/Str.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,6 @@ public static function getRandomTerm(): string
120120
'kangaroo',
121121
];
122122

123-
return sprintf(
124-
'%s %s',
125-
$adjectives[array_rand($adjectives)],
126-
$nouns[array_rand($nouns)]
127-
);
123+
return sprintf('%s %s', $adjectives[array_rand($adjectives)], $nouns[array_rand($nouns)]);
128124
}
129125
}

tests/Command/FunctionalTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class FunctionalTest extends TestCase
3030

3131
public function setUp()
3232
{
33-
$tmpDir = sys_get_temp_dir().'/sf'.mt_rand(111111, 999999);
33+
$tmpDir = sys_get_temp_dir().'/sf'.random_int(111111, 999999);
3434
@mkdir($tmpDir, 0777, true);
3535

3636
$this->targetDir = $tmpDir;
@@ -53,7 +53,7 @@ public function testCommands(AbstractCommand $command, array $inputs)
5353

5454
$tester = new CommandTester($command);
5555
$tester->setInputs($inputs);
56-
$tester->execute(array());
56+
$tester->execute([]);
5757

5858
$this->assertContains('Success', $tester->getDisplay());
5959

@@ -199,7 +199,7 @@ private function parsePHPFiles($output)
199199
continue;
200200
}
201201

202-
list(, $filename) = explode(':', $line);
202+
[, $filename] = explode(':', $line);
203203
$files[] = trim($filename);
204204
}
205205

tests/StrTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,3 @@ public function provideAsTwigVariable()
100100
yield ['generate', 'generate'];
101101
}
102102
}
103-

0 commit comments

Comments
 (0)