Skip to content

Commit 16b20c1

Browse files
authored
Merge pull request #16 from samsonasik/apply-php74
Apply PHP 7.4 syntax and typed property
2 parents ceef53b + 048e2da commit 16b20c1

File tree

6 files changed

+20
-29
lines changed

6 files changed

+20
-29
lines changed

src/Command/EnableCommand.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ final class EnableCommand extends AbstractCommand
2626
/** @var null|string */
2727
protected static $defaultName = 'composer:autoload:enable';
2828

29-
/** @var MoveModuleClassFileInterface */
30-
private $moduleFileMover;
29+
private MoveModuleClassFileInterface $moduleFileMover;
3130

3231
public function __construct(
3332
FileReaderInterface $fileReader,
@@ -72,7 +71,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7271
$resolvedModulesPath = sprintf('%s/%s', rtrim($options->projectPath, '\\/'), $options->modulesPath);
7372
$this->moduleFileMover->__invoke(
7473
$resolvedModulesPath,
75-
function (string $original, string $target) use ($output): void {
74+
static function (string $original, string $target) use ($output): void {
7675
$output->writeln(sprintf(
7776
'<info>Renamed %s to %s</info>',
7877
$original,

src/Composer.php

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
namespace Laminas\ComposerAutoloading;
66

77
use JsonException;
8+
use Laminas\ComposerAutoloading\AutoloadDumpInterface;
9+
use Laminas\ComposerAutoloading\FileWriterInterface;
810
use Webmozart\Assert\Assert;
911

1012
use function implode;
@@ -30,23 +32,16 @@ final class Composer
3032

3133
private const COMPOSER_FILE = 'composer.json';
3234

33-
/** @var AutoloadDumpInterface */
34-
private $autoloadDumper;
35+
private AutoloadDumpInterface $autoloadDumper;
3536

36-
/** @var bool */
37-
private $changed = false;
37+
private bool $changed = false;
3838

39-
/**
40-
* @var array
41-
* @psalm-var array<string, mixed>
42-
*/
43-
private $composer;
39+
/** @psalm-var array<string, mixed> */
40+
private array $composer;
4441

45-
/** @var FileWriterInterface */
46-
private $fileWriter;
42+
private FileWriterInterface $fileWriter;
4743

48-
/** @var string */
49-
private $composerJsonFile;
44+
private string $composerJsonFile;
5045

5146
public function __construct(
5247
string $projectDir,

test/AutoloadDumpViaSystemProcessTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function testInvokesSystemCommandWithProvidedComposerWithExpectedArgument
1818
$dumper = new AutoloadDumpViaSystemProcess();
1919

2020
/** @psalm-suppress InternalProperty */
21-
$dumper->systemCommand = function (string $command) use ($composerPath): void {
21+
$dumper->systemCommand = static function (string $command) use ($composerPath): void {
2222
$expected = sprintf('%s dump-autoload', $composerPath);
2323
Assert::assertSame($expected, $command);
2424
};

test/FileReaderViaFileGetContentsTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212

1313
class FileReaderViaFileGetContentsTest extends TestCase
1414
{
15-
/** @var vfsStreamDirectory */
16-
private $dir;
15+
private vfsStreamDirectory $dir;
1716

1817
public function setUp(): void
1918
{

test/FileWriterViaFilePutContentsTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414

1515
class FileWriterViaFilePutContentsTest extends TestCase
1616
{
17-
/** @var vfsStreamDirectory */
18-
private $dir;
17+
private vfsStreamDirectory $dir;
1918

2019
public function setUp(): void
2120
{

test/MoveModuleClassFileViaFileOperationsTest.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515

1616
class MoveModuleClassFileViaFileOperationsTest extends TestCase
1717
{
18-
/** @var vfsStreamDirectory */
19-
private $dir;
18+
private vfsStreamDirectory $dir;
2019

2120
public function setUp(): void
2221
{
@@ -37,7 +36,7 @@ public function setUp(): void
3736
*/
3837
private function createNoopReporter(): callable
3938
{
40-
return function (): void {
39+
return static function (): void {
4140
Assert::fail('Reporter was reached, but should not have been');
4241
};
4342
}
@@ -47,7 +46,7 @@ private function createNoopReporter(): callable
4746
*/
4847
private function createSpyReporter(string $expectedOriginal, string $expectedTarget): callable
4948
{
50-
return function (string $original, string $target) use ($expectedOriginal, $expectedTarget): void {
49+
return static function (string $original, string $target) use ($expectedOriginal, $expectedTarget): void {
5150
Assert::assertSame($expectedOriginal, $original, sprintf(
5251
'Did not receive expected original file "%s"; received "%s"',
5352
$expectedOriginal,
@@ -86,7 +85,7 @@ public function testReturnsEarlyIfTargetModuleClassFileAlreadyExists(): void
8685
$modulePath = $this->dir->getChild('module/TestModule');
8786
vfsStream::newFile('Module.php')->at($modulePath)->setContent(<<<'END'
8887
<?php
89-
88+
9089
namespace TestModule;
9190
9291
class Module
@@ -108,7 +107,7 @@ public function testMovesModuleClassFromModuleRootIntoModuleSourceDirectory(): v
108107
$modulePath = $this->dir->getChild('module/TestModule');
109108
$moduleClassFileContents = <<<'END'
110109
<?php
111-
110+
112111
namespace TestModule;
113112
114113
class Module
@@ -143,7 +142,7 @@ public function testMovesModuleClassFromModuleRootIntoModuleSourceDirectoryAndRe
143142
$modulePath = $this->dir->getChild('module/TestModule');
144143
$moduleClassFileContents = <<<'END'
145144
<?php
146-
145+
147146
namespace TestModule;
148147
149148
class Module
@@ -160,7 +159,7 @@ public function getConfig(): array
160159

161160
$expectedModuleClassFileContents = <<<'END'
162161
<?php
163-
162+
164163
namespace TestModule;
165164
166165
class Module

0 commit comments

Comments
 (0)