Skip to content

Commit

Permalink
[TASK] Raise compatibility to PHP 7.1-8.4
Browse files Browse the repository at this point in the history
* drops PHP 7.0 compatibility (due to not having nullable types)
* introduces PHP 8.4 compatibility
  • Loading branch information
ohader committed Aug 7, 2024
1 parent 8e3d17d commit 30c2d81
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
php: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['7.4', '8.0', '8.1', '8.2', '8.3']
php: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4']

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"homepage": "https://typo3.org/",
"keywords": ["php", "phar", "stream-wrapper", "security"],
"require": {
"php": "^7.0 || ^8.0",
"php": "^7.1 || ^8.0",
"ext-json": "*"
},
"require-dev": {
Expand Down
4 changes: 2 additions & 2 deletions src/Collectable.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ public function has(PharInvocation $invocation): bool;
* @param int|null $flags
* @return bool
*/
public function collect(PharInvocation $invocation, int $flags = null): bool;
public function collect(PharInvocation $invocation, ?int $flags = null): bool;

/**
* @param callable $callback
* @param bool $reverse
* @return null|PharInvocation
*/
public function findByCallback(callable $callback, $reverse = false);
public function findByCallback(callable $callback, bool $reverse = false);
}
10 changes: 5 additions & 5 deletions src/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ class Manager
*/
public static function initialize(
Behavior $behaviour,
Resolvable $resolver = null,
Collectable $collection = null
?Resolvable $resolver = null,
?Collectable $collection = null
): self {
if (self::$instance === null) {
self::$instance = new self($behaviour, $resolver, $collection);
Expand Down Expand Up @@ -92,8 +92,8 @@ public static function destroy(): bool
*/
private function __construct(
Behavior $behaviour,
Resolvable $resolver = null,
Collectable $collection = null
?Resolvable $resolver = null,
?Collectable $collection = null
) {
$this->collection = $collection ?? new PharInvocationCollection();
$this->resolver = $resolver ?? new PharInvocationResolver();
Expand All @@ -115,7 +115,7 @@ public function assert(string $path, string $command): bool
* @param null|int $flags
* @return PharInvocation|null
*/
public function resolve(string $path, int $flags = null)
public function resolve(string $path, ?int $flags = null)
{
return $this->resolver->resolve($path, $flags);
}
Expand Down
2 changes: 1 addition & 1 deletion src/PharStreamWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public function stream_open(
string $path,
string $mode,
int $options,
string &$opened_path = null
?string &$opened_path = null
): bool {
$this->assert($path, Behavior::COMMAND_STREAM_OPEN);
$arguments = [$path, $mode, (bool) ($options & STREAM_USE_PATH)];
Expand Down
2 changes: 1 addition & 1 deletion src/Resolvable.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ interface Resolvable
* @param null|int $flags
* @return null|PharInvocation
*/
public function resolve(string $path, int $flags = null);
public function resolve(string $path, ?int $flags = null);
}
4 changes: 2 additions & 2 deletions src/Resolver/PharInvocationCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function has(PharInvocation $invocation): bool
* @param null|int $flags
* @return bool
*/
public function collect(PharInvocation $invocation, int $flags = null): bool
public function collect(PharInvocation $invocation, ?int $flags = null): bool
{
if ($flags === null) {
$flags = static::UNIQUE_INVOCATION | static::DUPLICATE_ALIAS_WARNING;
Expand All @@ -64,7 +64,7 @@ public function collect(PharInvocation $invocation, int $flags = null): bool
* @param bool $reverse
* @return null|PharInvocation
*/
public function findByCallback(callable $callback, $reverse = false)
public function findByCallback(callable $callback, bool $reverse = false)
{
foreach ($this->getInvocations($reverse) as $invocation) {
if (call_user_func($callback, $invocation) === true) {
Expand Down
2 changes: 1 addition & 1 deletion src/Resolver/PharInvocationResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class PharInvocationResolver implements Resolvable
* @param int|null $flags
* @return null|PharInvocation
*/
public function resolve(string $path, int $flags = null)
public function resolve(string $path, ?int $flags = null)
{
$hasPharPrefix = Helper::hasPharPrefix($path);
$flags = $flags ?? static::RESOLVE_REALPATH | static::RESOLVE_ALIAS;
Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/HelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function baseFileIsResolvedDataProvider(): array
* @test
* @dataProvider baseFileIsResolvedDataProvider
*/
public function baseFileIsResolved(string $path, string $expectation = null)
public function baseFileIsResolved(string $path, ?string $expectation = null)
{
static::assertSame(
$expectation,
Expand Down
7 changes: 3 additions & 4 deletions tests/Functional/Resolver/PharInvocationResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function invocationIsResolvedDataProvider(): array
* @test
* @dataProvider invocationIsResolvedDataProvider
*/
public function invocationIsResolved(string $path, $flags, array $expectations)
public function invocationIsResolved(string $path, ?int $flags, array $expectations)
{
$invocation = $this->subject->resolve($path, $flags);
static::assertSame($invocation->getBaseName(), $expectations['baseName']);
Expand All @@ -112,12 +112,11 @@ public function invocationIsNotResolvedDataProvider(): array
/**
* @param string $path
* @param int|null $flags
* @param PharInvocation|null $expectation
*
* @test
* @dataProvider invocationIsNotResolvedDataProvider
*/
public function invocationIsNotResolved(string $path, int $flags = null)
public function invocationIsNotResolved(string $path, ?int $flags = null)
{
$invocation = $this->subject->resolve($path, $flags);
static::assertNull($invocation);
Expand All @@ -135,4 +134,4 @@ private static function normalizeWindowsPath(string $path): string
{
return str_replace('\\', '/', $path);
}
}
}

0 comments on commit 30c2d81

Please sign in to comment.