Skip to content

Commit ed55ee0

Browse files
authored
Merge pull request #4 from technically-php/chore/php8.5
PHP 8.5 Compatibility
2 parents 87e7af6 + edd3ac0 commit ed55ee0

29 files changed

Lines changed: 167 additions & 148 deletions

‎.github/workflows/test.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
runs-on: ubuntu-latest
77
strategy:
88
matrix:
9-
php: [ '8.0', '8.1', '8.2', '8.3', '8.4' ]
9+
php: [ '8.2', '8.3', '8.4', '8.5' ]
1010

1111
steps:
1212
- uses: actions/checkout@master

‎Makefile‎

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
.PHONY: tests
22

33
tests: vendor
4-
php -d zend.assertions=1 -d assert.exception=1 vendor/bin/peridot ./specs
4+
php vendor/bin/pest
55

6-
vendor: composer.json composer.phar
7-
php composer.phar install
6+
vendor: composer.json
7+
composer install
88
touch vendor
9-
10-
composer.phar:
11-
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
12-
php -r "if (hash_file('sha384', 'composer-setup.php') === 'dac665fdc30fdd8ec78b38b9800061b4150413ff2e3b6f88543c636f7cd84f6db9189d43a81e5503cda447da73c7e5b6') { echo 'Installer verified'.PHP_EOL; } else { echo 'Installer corrupt'.PHP_EOL; unlink('composer-setup.php'); exit(1); }"
13-
php composer-setup.php
14-
php -r "unlink('composer-setup.php');"

‎composer.json‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
"auto-wiring"
1010
],
1111
"require": {
12-
"php": "^8.0",
12+
"php": "^8.2",
1313
"psr/container": "^2.0",
1414
"technically/null-container": "^2.0",
15-
"technically/callable-reflection": "^0.4.2"
15+
"technically/callable-reflection": "^0.5.0"
1616
},
1717
"require-dev": {
18-
"peridot-php/peridot": "^1.19",
19-
"technically/array-container": "^2.0"
18+
"technically/array-container": "^2.0",
19+
"pestphp/pest": "^2.0 || ^3.0 || ^4.0"
2020
},
2121
"license": "MIT",
2222
"authors": [
@@ -33,7 +33,12 @@
3333
},
3434
"autoload-dev": {
3535
"psr-4": {
36-
"Technically\\DependencyResolver\\Specs\\": "specs"
36+
"Technically\\DependencyResolver\\Tests\\": "tests"
37+
}
38+
},
39+
"config": {
40+
"allow-plugins": {
41+
"pestphp/pest-plugin": true
3742
}
3843
}
3944
}

‎phpunit.xml‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
4+
bootstrap="vendor/autoload.php"
5+
colors="true"
6+
>
7+
<testsuites>
8+
<testsuite name="Test Suite">
9+
<directory suffix=".spec.php">./tests</directory>
10+
</testsuite>
11+
</testsuites>
12+
<source>
13+
<include>
14+
<directory>src</directory>
15+
</include>
16+
</source>
17+
</phpunit>

‎specs/Fixtures/MyAbstractClass.php‎

Lines changed: 0 additions & 8 deletions
This file was deleted.

‎specs/Fixtures/MySelfDependencyService.php‎

Lines changed: 0 additions & 13 deletions
This file was deleted.

‎src/Contracts/DependencyResolver.php‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ interface DependencyResolver
1717
* It can be either found in the container or constructed on the fly,
1818
* recursively auto-resolving the required parameters.
1919
*
20-
* @param class-string $className
21-
* @return mixed
20+
* @template T
21+
* @param class-string<T> $className
22+
* @return T
2223
*
2324
* @throws InvalidArgumentException If the class does not exist.
2425
* @throws ContainerExceptionInterface If an error occurs while retrieving the existing entry from the container.
@@ -33,9 +34,10 @@ public function resolve(string $className): mixed;
3334
* Even if the container already has the instance bound,
3435
* it will still be instantiated.
3536
*
36-
* @param class-string $className
37+
* @template T
38+
* @param class-string<T> $className
3739
* @param array<string,mixed> $bindings
38-
* @return mixed
40+
* @return T
3941
*
4042
* @throws ClassCannotBeInstantiated
4143
* @throws CannotAutowireDependencyArgument

‎src/DependencyResolver.php‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ public function __construct(?ContainerInterface $container = null)
2525
}
2626

2727
/**
28-
* @param class-string $className
29-
* @return mixed
28+
* @template T
29+
* @param class-string<T> $className
30+
* @return T
3031
*
3132
* @throws InvalidArgumentException If class does not exist.
3233
* @throws ContainerExceptionInterface If error occurs while retrieving the existing entry from the container.
@@ -47,9 +48,10 @@ public function resolve(string $className): mixed
4748
}
4849

4950
/**
50-
* @param class-string $className
51+
* @template T
52+
* @param class-string<T> $className
5153
* @param array<string,mixed> $bindings
52-
* @return mixed
54+
* @return T
5355
*
5456
* @throws ClassCannotBeInstantiated
5557
* @throws CannotAutowireDependencyArgument
@@ -125,7 +127,6 @@ private function resolveParameters(array $parameters, array $bindings = []): arr
125127
}
126128

127129
/**
128-
* @param ParameterReflection $parameter
129130
* @return mixed|null
130131
*
131132
* @throws CannotAutowireArgument
@@ -136,7 +137,7 @@ private function resolveParameter(ParameterReflection $parameter): mixed
136137
if ($type->isClassRequirement() && $this->container->has($class = $type->getClassRequirement())) {
137138
try {
138139
return $this->container->get($class);
139-
} catch (ContainerExceptionInterface $exception) {
140+
} catch (ContainerExceptionInterface) {
140141
throw new CannotAutowireArgument($parameter->getName());
141142
}
142143
}
@@ -155,7 +156,7 @@ private function resolveParameter(ParameterReflection $parameter): mixed
155156
$class = $type->getClassRequirement();
156157
try {
157158
return $this->construct($class);
158-
} catch (DependencyResolutionException $exception) {
159+
} catch (DependencyResolutionException) {
159160
// try another one
160161
}
161162
}

‎src/Exceptions/CannotAutowireArgument.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ final class CannotAutowireArgument extends DependencyResolutionException
1515
* @param string $argumentName
1616
* @param Throwable|null $previous
1717
*/
18-
public function __construct(string $argumentName, Throwable $previous = null)
18+
public function __construct(string $argumentName, Throwable | null $previous = null)
1919
{
2020
$this->argumentName = $argumentName;
2121

‎src/Exceptions/CannotAutowireDependencyArgument.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ final class CannotAutowireDependencyArgument extends DependencyResolutionExcepti
2121
* @param string $argumentName
2222
* @param Throwable|null $previous
2323
*/
24-
public function __construct(string $dependencyName, string $argumentName, Throwable $previous = null)
24+
public function __construct(string $dependencyName, string $argumentName, Throwable | null $previous = null)
2525
{
2626
$this->dependencyName = $dependencyName;
2727
$this->argumentName = $argumentName;
2828

29-
parent::__construct("Could not autowire argument `{$argumentName}` for `${dependencyName}`.", 0, $previous);
29+
parent::__construct("Could not autowire argument `{$argumentName}` for `{$dependencyName}`.", 0, $previous);
3030
}
3131

3232
/**

0 commit comments

Comments
 (0)