Skip to content

Commit 06f51eb

Browse files
committed
Adds support for GrumPHP and updates script installation commands in composer.json
1 parent 9fa3d1b commit 06f51eb

18 files changed

+105
-84
lines changed

.docheader

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@
1010
* @see https://github.com/php-fast-forward/dev-tools
1111
* @see https://github.com/php-fast-forward
1212
* @see https://datatracker.ietf.org/doc/html/rfc2119
13-
*/
13+
*/
14+

bin/dev-tools.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
* @see https://datatracker.ietf.org/doc/html/rfc2119
1717
*/
1818

19-
$projectVendorAutoload = dirname(__DIR__, 4) . '/vendor/autoload.php';
20-
$pluginVendorAutoload = dirname(__DIR__) . '/vendor/autoload.php';
19+
namespace FastForward\DevTools;
2120

22-
require_once file_exists($projectVendorAutoload) ? $projectVendorAutoload : $pluginVendorAutoload;
21+
$projectVendorAutoload = \dirname(__DIR__, 4) . '/vendor/autoload.php';
22+
$pluginVendorAutoload = \dirname(__DIR__) . '/vendor/autoload.php';
2323

24-
use FastForward\DevTools\DevTools;
24+
require_once file_exists($projectVendorAutoload) ? $projectVendorAutoload : $pluginVendorAutoload;
2525

2626
$application = new DevTools();
2727
$application->run();

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,6 @@
7676
},
7777
"scripts": {
7878
"dev-tools": "dev-tools",
79-
"dev-tools:fix": "dev-tools --fix"
79+
"dev-tools:fix": "@dev-tools --fix"
8080
}
8181
}

src/Command/InstallScriptsCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7272

7373
$scripts = [
7474
'dev-tools' => 'dev-tools',
75-
'dev-tools:fix' => 'dev-tools --fix',
75+
'dev-tools:fix' => '@dev-tools --fix',
7676
];
7777

7878
$extra = [
7979
'grumphp' => [
8080
'config-default-path' => Path::makeRelative(
81-
dirname(__DIR__, 2) . '/grumphp.yml',
81+
\dirname(__DIR__, 2) . '/grumphp.yml',
8282
$this->getCurrentWorkingDirectory(),
8383
),
8484
],

src/Command/ReportsCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
use Symfony\Component\Console\Input\InputInterface;
2222
use Symfony\Component\Console\Output\OutputInterface;
2323

24-
2524
/**
2625
* Coordinates the generation of Fast Forward documentation frontpage and related reports.
2726
* This class MUST NOT be overridden and SHALL securely combine docs and testing commands.
@@ -77,6 +76,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7776

7877
$output->writeln('<info>Frontpage generation completed!</info>');
7978

80-
return in_array(self::FAILURE, $results, true) ? self::FAILURE : self::SUCCESS;
79+
return \in_array(self::FAILURE, $results, true) ? self::FAILURE : self::SUCCESS;
8180
}
8281
}

src/Command/StandardsCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7777

7878
$output->writeln('<info>All code standards checks completed!</info>');
7979

80-
return in_array(self::FAILURE, $results, true) ? self::FAILURE : self::SUCCESS;
80+
return \in_array(self::FAILURE, $results, true) ? self::FAILURE : self::SUCCESS;
8181
}
8282
}

src/Composer/Plugin.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ public static function getSubscribedEvents(): array
7777
*/
7878
public function onPostInstall(Event $event): void
7979
{
80-
$event->getComposer()->getEventDispatcher()->dispatchScript('install-scripts', true);
80+
$event->getComposer()
81+
->getEventDispatcher()
82+
->dispatchScript('install-scripts', true);
8183
}
8284

8385
/**
@@ -92,7 +94,9 @@ public function onPostInstall(Event $event): void
9294
*/
9395
public function onPostUpdate(Event $event): void
9496
{
95-
$event->getComposer()->getEventDispatcher()->dispatchScript('install-scripts', true);
97+
$event->getComposer()
98+
->getEventDispatcher()
99+
->dispatchScript('install-scripts', true);
96100
}
97101

98102
/**

src/Rector/AddMissingClassPhpDocRector.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,7 @@ final class AddMissingClassPhpDocRector extends AbstractRector
4141
public function getRuleDefinition(): RuleDefinition
4242
{
4343
return new RuleDefinition('Add basic PHPDoc to classes without docblock', [
44-
new CodeSample(
45-
'class SomeClass {}',
46-
"/**\n * SomeClass\n */\nclass SomeClass {}"
47-
),
44+
new CodeSample('class SomeClass {}', "/**\n * SomeClass\n */\nclass SomeClass {}"),
4845
]);
4946
}
5047

src/Rector/AddMissingMethodPhpDocRector.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,7 @@ final class AddMissingMethodPhpDocRector extends AbstractRector
5959
public function getRuleDefinition(): RuleDefinition
6060
{
6161
return new RuleDefinition('Add basic PHPDoc to methods without docblock', [
62-
new CodeSample(
63-
'public function foo() {}',
64-
"/**\n * \n */\npublic function foo() {}"
65-
),
62+
new CodeSample('public function foo() {}', "/**\n * \n */\npublic function foo() {}"),
6663
]);
6764
}
6865

src/Rector/RemoveEmptyDocBlockRector.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,7 @@ final class RemoveEmptyDocBlockRector extends AbstractRector
4545
public function getRuleDefinition(): RuleDefinition
4646
{
4747
return new RuleDefinition('Remove empty docblocks from classes and methods', [
48-
new CodeSample(
49-
"/**\n *\n */\nclass SomeClass {}",
50-
'class SomeClass {}'
51-
),
48+
new CodeSample("/**\n *\n */\nclass SomeClass {}", 'class SomeClass {}'),
5249
]);
5350
}
5451

@@ -130,9 +127,11 @@ private function isEmptyDocBlock(string $docBlock): bool
130127
if ('/**' === $normalizedLine) {
131128
continue;
132129
}
130+
133131
if ('*/' === $normalizedLine) {
134132
continue;
135133
}
134+
136135
if ('*' === $normalizedLine) {
137136
continue;
138137
}

0 commit comments

Comments
 (0)