Skip to content

Commit b7bd079

Browse files
committed
add typed properties support
1 parent 6b34d01 commit b7bd079

14 files changed

+42
-66
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ using the [Keep a CHANGELOG](http://keepachangelog.com) principles.
1313
- `rdfkafka` extension is now supported by PHP 8.1
1414
- `bin/devkit.php` is made available into the Composer `bin-dir`
1515
- Add [platform](https://getcomposer.org/doc/06-config.md#platform) to `composer.json`
16+
- Support **Typed properties** features, now minimum PHP requirement is 7.4
17+
18+
Read more about this feature at :
19+
20+
- <https://stitcher.io/blog/typed-properties-in-php-74>
21+
- <https://php.watch/versions/7.4/typed-properties>
1622

1723
### Removed
1824

src/Collection/Filter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
final class Filter
1818
{
1919
/** @var string[] */
20-
private $excludedTags;
20+
private array $excludedTags;
2121

2222
/** @var string[] */
23-
private $tags;
23+
private array $tags;
2424

2525
/**
2626
* @param string[] $excludedTags

src/Collection/Tool.php

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,14 @@
1515
*/
1616
final class Tool
1717
{
18-
/** @var string */
19-
private $name;
20-
/** @var string */
21-
private $summary;
22-
/** @var string */
23-
private $website;
24-
/** @var CommandInterface|null */
25-
private $command;
26-
/** @var CommandInterface|null */
27-
private $testCommand;
18+
private string $name;
19+
private string $summary;
20+
private string $website;
21+
private ?CommandInterface $command;
22+
private ?CommandInterface $testCommand;
2823
/** @var string[] */
29-
private $tags;
30-
/** @var int */
31-
private $priority;
24+
private array $tags;
25+
private int $priority;
3226

3327
/**
3428
* Class constructor

src/Command/ComposerInstallCommand.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,11 @@
1616
*/
1717
final class ComposerInstallCommand implements CommandInterface
1818
{
19-
/** @var bool */
20-
private $scripts;
21-
22-
/** @var bool */
23-
private $devDependencies;
24-
25-
/** @var bool */
26-
private $global;
27-
19+
private bool $scripts;
20+
private bool $devDependencies;
21+
private bool $global;
2822
/** @var string[] */
29-
private $packages;
23+
private array $packages;
3024

3125
/**
3226
* @param array<string, mixed> $properties

src/Command/FileDownloadCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77
*/
88
namespace Bartlett\PHPToolbox\Command;
99

10+
use function sprintf;
11+
1012
/**
1113
* @since Release 1.0.0alpha1
1214
* @author Laurent Laville
1315
*/
1416
final class FileDownloadCommand implements CommandInterface
1517
{
16-
/** @var string */
17-
private $url;
18-
/** @var string */
19-
private $target;
18+
private string $url;
19+
private string $target;
2020

2121
/**
2222
* @param array<string, mixed> $properties

src/Command/GitInstallCommand.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,11 @@
1515
*/
1616
final class GitInstallCommand implements CommandInterface
1717
{
18-
/** @var string|null */
19-
private $repository;
20-
/** @var string */
21-
private $targetDir;
22-
/** @var string|null */
23-
private $version;
24-
/** @var int|null */
25-
private $abbreviate;
26-
/** @var string|null */
27-
private $matchPattern;
18+
private ?string $repository;
19+
private string $targetDir;
20+
private ?string $version;
21+
private ?string $abbreviate;
22+
private ?string $matchPattern;
2823

2924
/**
3025
* @param array<string, mixed> $properties
@@ -44,7 +39,7 @@ public function __toString(): string
4439

4540
$version = sprintf(
4641
'$(git describe %s %s --tags $(git rev-list --tags --max-count=1) 2>/dev/null)',
47-
$this->abbreviate ? sprintf('--abbrev=%d', $this->abbreviate) : '',
42+
$this->abbreviate ? sprintf('--abbrev=%d', (int) $this->abbreviate) : '',
4843
$this->matchPattern ? '--match "' . $this->matchPattern . '"' : ''
4944
);
5045

src/Command/MultiCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ final class MultiCommand implements CommandInterface
2020
{
2121
/** @var Collection<int, CommandInterface> */
2222
private $commands;
23-
/** @var string */
24-
private $glue;
23+
private string $glue;
2524

2625
/**
2726
* @param Collection<int, CommandInterface> $commands

src/Command/NpmInstallCommand.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@
1616
*/
1717
final class NpmInstallCommand implements CommandInterface
1818
{
19-
/** @var string */
20-
private $requirement;
21-
19+
private string $requirement;
2220
/** @var string[] */
23-
private $flags;
21+
private array $flags;
2422

2523
/**
2624
* @param array<string, mixed> $properties

src/Command/PeclInstallCommand.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@
1515
*/
1616
final class PeclInstallCommand implements CommandInterface
1717
{
18-
/** @var string */
19-
private $name;
20-
/** @var string|null */
21-
private $version;
18+
private string $name;
19+
private ?string $version;
2220

2321
/**
2422
* @param array<string, mixed> $properties

src/Command/PharDownloadCommand.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@
1515
*/
1616
final class PharDownloadCommand implements CommandInterface
1717
{
18-
/** @var string */
19-
private $phar;
20-
/** @var string */
21-
private $bin;
18+
private string $phar;
19+
private string $bin;
2220

2321
/**
2422
* @param array<string, mixed> $properties

0 commit comments

Comments
 (0)