Skip to content

Commit 3206cff

Browse files
authored
Merge pull request #2 from technically-php/feature/php-8
Feature - Raise minimum PHP version to 8.0
2 parents 2461af9 + 8d12762 commit 3206cff

File tree

7 files changed

+20
-23
lines changed

7 files changed

+20
-23
lines changed

.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: [ '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4' ]
9+
php: [ '8.0', '8.1', '8.2', '8.3', '8.4' ]
1010

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

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ or recursively instantiating them with *DependencyResolver* itself.
1010
## Features
1111

1212
- Based on PSR-11
13-
- Supports PHP 8 (8.0, 8.1, 8.2, 8.3 and 8.4) — full support of union type hints, and other modern features.
14-
- PHP 7.1+ compatible
13+
- Supports modern PHP 8 features (up to PHP 8.4) — full support of union type hints, and others.
1514
- Recursive dependencies autowiring
1615
- Semver
1716
- Tests

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
"auto-wiring"
1010
],
1111
"require": {
12-
"php": "^7.1|^8.0",
13-
"psr/container": "^1.0|^2.0",
14-
"technically/null-container": "^1.0",
15-
"technically/callable-reflection": "^0.4.0"
12+
"php": "^8.0",
13+
"psr/container": "^2.0",
14+
"technically/null-container": "^2.0",
15+
"technically/callable-reflection": "^0.4.2"
1616
},
1717
"require-dev": {
1818
"peridot-php/peridot": "^1.19",
19-
"technically/array-container": "^1.0"
19+
"technically/array-container": "^2.0"
2020
},
2121
"license": "MIT",
2222
"authors": [

src/DependencyResolver.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@
1616

1717
final class DependencyResolver
1818
{
19-
/**
20-
* @var ContainerInterface
21-
*/
22-
private $container;
19+
private ContainerInterface $container;
2320

2421
public function __construct(?ContainerInterface $container = null)
2522
{
@@ -28,14 +25,14 @@ public function __construct(?ContainerInterface $container = null)
2825

2926
/**
3027
* @param string $className
31-
* @return mixed|object|void
28+
* @return mixed
3229
*
3330
* @throws InvalidArgumentException If class does not exist.
3431
* @throws ContainerExceptionInterface If error occurs while retrieving the existing entry from the container.
3532
* @throws ClassCannotBeInstantiated If class cannot be instantiated.
3633
* @throws CannotAutowireDependencyArgument If a dependency (of any nesting level) cannot be resolved.
3734
*/
38-
public function resolve(string $className)
35+
public function resolve(string $className): mixed
3936
{
4037
if (! class_exists($className) && ! interface_exists($className)) {
4138
throw new InvalidArgumentException("`{$className}` is not a valid class name.");
@@ -51,11 +48,12 @@ public function resolve(string $className)
5148
/**
5249
* @param string $className
5350
* @param array $bindings
51+
* @return mixed
5452
*
5553
* @throws ClassCannotBeInstantiated
5654
* @throws CannotAutowireDependencyArgument
5755
*/
58-
public function construct(string $className, array $bindings = [])
56+
public function construct(string $className, array $bindings = []): mixed
5957
{
6058
if (! class_exists($className) && ! interface_exists($className)) {
6159
throw new InvalidArgumentException("`{$className}` is not a valid class name.");
@@ -84,7 +82,7 @@ public function construct(string $className, array $bindings = [])
8482
* @throws ArgumentCountError
8583
* @throws CannotAutowireArgument
8684
*/
87-
public function call(callable $callable, array $bindings = [])
85+
public function call(callable $callable, array $bindings = []): mixed
8886
{
8987
$reflection = CallableReflection::fromCallable($callable);
9088

@@ -130,7 +128,7 @@ private function resolveParameters(array $parameters, array $bindings = []): arr
130128
*
131129
* @throws CannotAutowireArgument
132130
*/
133-
private function resolveParameter(ParameterReflection $parameter)
131+
private function resolveParameter(ParameterReflection $parameter): mixed
134132
{
135133
foreach ($parameter->getTypes() as $type) {
136134
if ($type->isClassRequirement() && $this->container->has($class = $type->getClassRequirement())) {

src/Exceptions/CannotAutowireArgument.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ final class CannotAutowireArgument extends DependencyResolutionException
99
/**
1010
* @var string
1111
*/
12-
private $argumentName;
12+
private string $argumentName;
1313

1414
/**
1515
* @param string $argumentName

src/Exceptions/CannotAutowireDependencyArgument.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ final class CannotAutowireDependencyArgument extends DependencyResolutionExcepti
99
/**
1010
* @var string
1111
*/
12-
private $dependencyName;
12+
private string $dependencyName;
1313

1414
/**
1515
* @var string
1616
*/
17-
private $argumentName;
17+
private string $argumentName;
1818

1919
/**
2020
* @param string $dependencyName

src/Exceptions/ClassCannotBeInstantiated.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
final class ClassCannotBeInstantiated extends DependencyResolutionException
66
{
77
/**
8-
* @var string
8+
* @var class-string
99
*/
10-
private $className;
10+
private string $className;
1111

1212
public function __construct(string $className)
1313
{
@@ -17,7 +17,7 @@ public function __construct(string $className)
1717
}
1818

1919
/**
20-
* @return string
20+
* @return class-string
2121
*/
2222
public function getClassName(): string
2323
{

0 commit comments

Comments
 (0)