Skip to content

Commit

Permalink
Apply PHP 8.0 Syntax and constructor promotion
Browse files Browse the repository at this point in the history
Signed-off-by: Abdul Malik Ikhsan <[email protected]>
  • Loading branch information
samsonasik committed Jan 9, 2023
1 parent 4a0e201 commit a6093ed
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 32 deletions.
10 changes: 1 addition & 9 deletions src/AssetInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,11 @@ class AssetInstaller
{
use UnparseableTokensTrait;

/** @var Composer */
private $composer;

/** @var IOInterface */
private $io;

/** @var string Base path for project; default is current working dir. */
private $projectPath;

public function __construct(Composer $composer, IOInterface $io)
public function __construct(private Composer $composer, private IOInterface $io)
{
$this->composer = $composer;
$this->io = $io;
$this->projectPath = getcwd();
}

Expand Down
12 changes: 2 additions & 10 deletions src/AssetUninstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,14 @@ class AssetUninstaller
{
use UnparseableTokensTrait;

/** @var Composer */
private $composer;

/** @var string[] .gitignore rules */
private $gitignore = [];

/** @var IOInterface */
private $io;
private array $gitignore = [];

/** @var string Base path for project; default is current working dir. */
private $projectPath;

public function __construct(Composer $composer, IOInterface $io)
public function __construct(private Composer $composer, private IOInterface $io)
{
$this->composer = $composer;
$this->io = $io;
$this->projectPath = getcwd();
}

Expand Down
8 changes: 3 additions & 5 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,16 @@

class Plugin implements PluginInterface, EventSubscriberInterface
{
/** @var Composer */
private $composer;
private Composer $composer;

/**
* Array of installers to run following a dump-autoload operation.
*
* @var callable[]
*/
private $installers = [];
private array $installers = [];

/** @var IOInterface */
private $io;
private IOInterface $io;

/**
* Provide composer event listeners.
Expand Down
3 changes: 1 addition & 2 deletions test/AssetInstallerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ class AssetInstallerTest extends TestCase
/** @var IOInterface|ObjectProphecy */
private $io;

/** @var vfsStreamDirectory */
private $filesystem;
private vfsStreamDirectory $filesystem;

public function setUp(): void
{
Expand Down
3 changes: 1 addition & 2 deletions test/AssetUninstallerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ class AssetUninstallerTest extends TestCase
],
];

/** @var vfsStreamDirectory */
private $filesystem;
private vfsStreamDirectory $filesystem;

/** @var PackageInterface|ObjectProphecy */
private $package;
Expand Down
7 changes: 3 additions & 4 deletions test/PluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ class PluginTest extends TestCase
use DeprecatedAssertionsTrait;
use ProphecyTrait;

/** @var vfsStreamDirectory */
private $filesystem;
private vfsStreamDirectory $filesystem;

/** @var Composer|ObjectProphecy */
private $composer;
Expand Down Expand Up @@ -102,10 +101,10 @@ public function testOnPostAutoloadDumpTriggersInstallers(): void
/** @psalm-var object{operations: array<array-key,string>} $obj */
$spy = (object) ['operations' => []];

$installer1 = function () use ($spy): void {
$installer1 = static function () use ($spy): void {
$spy->operations[] = 'installer1';
};
$installer2 = function () use ($spy): void {
$installer2 = static function () use ($spy): void {
$spy->operations[] = 'installer2';
};

Expand Down

0 comments on commit a6093ed

Please sign in to comment.