Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to use PHP 8.1 syntax #100

Merged
merged 1 commit into from
Nov 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ final class Filesystem extends AbstractMetadataCapableAdapter implements
*/
private string $lastFileSpec = '';

private FilesystemInteractionInterface $filesystem;
private ClockInterface $clock;
private readonly FilesystemInteractionInterface $filesystem;
private readonly ClockInterface $clock;

/**
* @param null|iterable<string,mixed>|FilesystemOptions $options
Expand Down
2 changes: 1 addition & 1 deletion src/Filesystem/Exception/MetadataException.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class MetadataException extends RuntimeException
public const METADATA_MTIME = 'mtime';
public const METADATA_FILESIZE = 'filesize';

private ErrorException $error;
private readonly ErrorException $error;

/**
* @psalm-param MetadataException::METADATA_* $metadata
Expand Down
2 changes: 1 addition & 1 deletion src/Filesystem/Exception/UnlinkException.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

final class UnlinkException extends RuntimeException
{
private ErrorException $error;
private readonly ErrorException $error;

public function __construct(string $path, ErrorException $error)
{
Expand Down
33 changes: 15 additions & 18 deletions src/FilesystemIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@
*/
final class FilesystemIterator implements IteratorInterface
{
/**
* The Filesystem storage instance
*/
private Filesystem $storage;

/**
* The iterator mode
*
Expand All @@ -31,24 +26,26 @@ final class FilesystemIterator implements IteratorInterface
/**
* The GlobIterator instance
*/
private GlobIterator $globIterator;

/**
* The namespace sprefix
*/
private string $prefix;
private readonly GlobIterator $globIterator;

/**
* String length of namespace prefix
*/
private int $prefixLength;

public function __construct(Filesystem $storage, string $path, string $prefix)
{
$this->storage = $storage;
private readonly int $prefixLength;

public function __construct(
/**
* The Filesystem storage instance
*/
private readonly Filesystem $storage,
string $path,
/**
* The namespace sprefix
*/
private readonly string $prefix
) {
$this->globIterator = new GlobIterator($path, GlobIterator::KEY_AS_FILENAME);
$this->prefix = $prefix;
$this->prefixLength = strlen($prefix);
$this->prefixLength = strlen($this->prefix);
}

/**
Expand Down
5 changes: 3 additions & 2 deletions test/unit/FilesystemOptionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use function realpath;
use function rmdir;
use function str_replace;
use function str_starts_with;
use function strpos;
use function substr;
use function sys_get_temp_dir;
Expand Down Expand Up @@ -99,7 +100,7 @@ public function testNormalizeCacheDir(): void

public function testSetCacheDirNotWritableException(): void
{
if (substr(PHP_OS, 0, 3) === 'WIN') {
if (str_starts_with(PHP_OS, 'WIN')) {
self::markTestSkipped('Not testable on windows');
} else {
$out = [];
Expand Down Expand Up @@ -131,7 +132,7 @@ public function testSetCacheDirNotWritableException(): void

public function testSetCacheDirNotReadableException(): void
{
if (substr(PHP_OS, 0, 3) === 'WIN') {
if (str_starts_with(PHP_OS, 'WIN')) {
self::markTestSkipped('Not testable on windows');
} else {
@exec('whoami 2>&1', $out, $ret);
Expand Down