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

Minimum php81 #64

Merged
merged 14 commits into from
Oct 21, 2023
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ on:

jobs:
run:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
env:
extensions: intl,mbstring
strategy:
fail-fast: false
max-parallel: 3
matrix:
php: ['7.4', '8.0', '8.1', '8.2']
php: ['8.1', '8.2']
name: PHP ${{ matrix.php }} ${{ matrix.description }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ on:

jobs:
run:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
env:
extensions: intl,mbstring
strategy:
fail-fast: false
max-parallel: 1
matrix:
php: ['8.0']
php: ['8.1']
name: PHP ${{ matrix.php }} ${{ matrix.description }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -45,7 +45,7 @@ jobs:

# https://github.com/marketplace/actions/codecov
- name: Submit coverage report
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v3
with:
files: build/coverage.xml
verbose: true
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
## Changelog
### v6.0.0
- minimum required PHP version 8.1
- added return types where possible
### v5.5.0
- extractor configuration can now contain an array of extractors
### v5.0.0
- deprecated PHP 7.3
- add PHP 8.1
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Heavily inspired by https://github.com/mikemix/mxdiModule.
### Installation

1. Install with Composer: `composer require reinfi/zf-dependency-injection`.
2. Enable the module via config in `appliation.config.php` under `modules` key:
2. Enable the module via config in `application.config.php` under `modules` key:

```php
return [
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
"bin/zf-dependency-injection-cache-warmup"
],
"require": {
"php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0",
"php": "~8.1.0 || ~8.2.0",
"laminas/laminas-servicemanager": "^2.7 | ^3.0",
"laminas/laminas-modulemanager": "^2.7",
"psr/simple-cache": "^1.0"
"psr/simple-cache": "^1.0 | ^2.0 | ^3.0"
},
"autoload": {
"psr-4": {
Expand Down Expand Up @@ -59,7 +59,7 @@
"laminas/laminas-form": "^3.0",
"laminas/laminas-inputfilter": "^2.12",
"bnf/phpstan-psr-container": "^1.0",
"symplify/easy-coding-standard": "^11.2",
"symplify/easy-coding-standard": "^12.0",
"doctrine/annotations": "^2.0"
},
"extra": {
Expand Down
2 changes: 1 addition & 1 deletion src/Annotation/AbstractInjectPluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct(array $values)
$this->name = $values['value'];
}

public function __invoke(ContainerInterface $container)
public function __invoke(ContainerInterface $container): mixed
{
$container = $this->determineContainer($container);
$pluginManagerImplementation = $container->get(static::PLUGIN_MANAGER);
Expand Down
7 changes: 2 additions & 5 deletions src/Annotation/Inject.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,9 @@
*/
final class Inject implements AnnotationInterface
{
/**
* @var string
*/
public $value;
public string $value;

public function __invoke(ContainerInterface $container)
public function __invoke(ContainerInterface $container): mixed
{
return $container->get($this->value);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Annotation/InjectConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct(array $values)
$this->configPath = $values['value'];
}

public function __invoke(ContainerInterface $container)
public function __invoke(ContainerInterface $container): mixed
{
$container = $this->determineContainer($container);

Expand Down
7 changes: 2 additions & 5 deletions src/Annotation/InjectConstant.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,9 @@
*/
final class InjectConstant implements AnnotationInterface
{
/**
* @var string
*/
public $value;
public string $value;

public function __invoke(ContainerInterface $container)
public function __invoke(ContainerInterface $container): mixed
{
return constant($this->value);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Annotation/InjectContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
final class InjectContainer implements AnnotationInterface
{
public function __invoke(ContainerInterface $container)
public function __invoke(ContainerInterface $container): mixed
{
return $container;
}
Expand Down
3 changes: 2 additions & 1 deletion src/Annotation/InjectDoctrineRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Reinfi\DependencyInjection\Annotation;

use Doctrine\ORM\EntityRepository;
use Psr\Container\ContainerInterface;
use Reinfi\DependencyInjection\Exception\AutoWiringNotPossibleException;

Expand Down Expand Up @@ -34,7 +35,7 @@ public function __construct(array $values)
$this->entity = $values['value'];
}

public function __invoke(ContainerInterface $container)
public function __invoke(ContainerInterface $container): EntityRepository
{
$container = $this->determineContainer($container);

Expand Down
7 changes: 2 additions & 5 deletions src/Annotation/InjectParent.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@
*/
final class InjectParent implements AnnotationInterface
{
/**
* @var string
*/
public $value;
public string $value;

public function __invoke(ContainerInterface $container)
public function __invoke(ContainerInterface $container): mixed
{
if ($container instanceof AbstractPluginManager) {
$container = $container->getServiceLocator();
Expand Down
2 changes: 1 addition & 1 deletion src/Attribute/AbstractInjectPluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function __construct(string $name, ?array $options = null)
$this->options = $options;
}

public function __invoke(ContainerInterface $container)
public function __invoke(ContainerInterface $container): mixed
{
$container = $this->determineContainer($container);
$pluginManagerImplementation = $container->get(static::PLUGIN_MANAGER);
Expand Down
2 changes: 1 addition & 1 deletion src/Attribute/Inject.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function __construct(string $value)
$this->value = $value;
}

public function __invoke(ContainerInterface $container)
public function __invoke(ContainerInterface $container): mixed
{
return $container->get($this->value);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Attribute/InjectConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function __construct(string $configPath, bool $asArray = false)
$this->asArray = $asArray;
}

public function __invoke(ContainerInterface $container)
public function __invoke(ContainerInterface $container): mixed
{
$container = $this->determineContainer($container);

Expand Down
2 changes: 1 addition & 1 deletion src/Attribute/InjectConstant.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function __construct(string $value)
$this->value = $value;
}

public function __invoke(ContainerInterface $container)
public function __invoke(ContainerInterface $container): mixed
{
return constant($this->value);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Attribute/InjectContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#[Attribute(Attribute::TARGET_METHOD | Attribute::TARGET_PROPERTY | Attribute::IS_REPEATABLE)]
final class InjectContainer implements InjectionInterface
{
public function __invoke(ContainerInterface $container)
public function __invoke(ContainerInterface $container): ContainerInterface
{
return $container;
}
Expand Down
3 changes: 2 additions & 1 deletion src/Attribute/InjectDoctrineRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Reinfi\DependencyInjection\Attribute;

use Attribute;
use Doctrine\ORM\EntityRepository;
use Psr\Container\ContainerInterface;
use Reinfi\DependencyInjection\Exception\AutoWiringNotPossibleException;

Expand All @@ -27,7 +28,7 @@ public function __construct(string $entity, ?string $entityManager = null)
}
}

public function __invoke(ContainerInterface $container)
public function __invoke(ContainerInterface $container): EntityRepository
{
$container = $this->determineContainer($container);

Expand Down
2 changes: 1 addition & 1 deletion src/Attribute/InjectParent.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function __construct(string $value)
$this->value = $value;
}

public function __invoke(ContainerInterface $container)
public function __invoke(ContainerInterface $container): mixed
{
if ($container instanceof AbstractPluginManager) {
$container = $container->getServiceLocator();
Expand Down
5 changes: 1 addition & 4 deletions src/Extension/PHPStan/ServiceManagerLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@

final class ServiceManagerLoader
{
/**
* @var ServiceManager|null
*/
private $serviceLocator = null;
private ?ServiceManager $serviceLocator = null;

public function __construct(?string $serviceManagerLoader)
{
Expand Down
3 changes: 1 addition & 2 deletions src/Injection/AutoWiring.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ public function __construct(string $serviceName)
}

/**
* @return mixed
* @throws AutoWiringNotPossibleException
*/
public function __invoke(ContainerInterface $container)
public function __invoke(ContainerInterface $container): mixed
{
if ($container->has($this->serviceName)) {
return $container->get($this->serviceName);
Expand Down
11 changes: 5 additions & 6 deletions src/Injection/AutoWiringPluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,20 @@ public function __construct(
}

/**
* @return mixed
* @throws AutoWiringNotPossibleException
*/
public function __invoke(ContainerInterface $container)
public function __invoke(ContainerInterface $container): mixed
{
if ($container instanceof AbstractPluginManager) {
$container = $container->getServiceLocator();
}

$pluginManagerImplemenation = $container->get($this->pluginManager);
$pluginManagerImplementation = $container->get($this->pluginManager);
if (
$pluginManagerImplemenation instanceof ContainerInterface
&& $pluginManagerImplemenation->has($this->serviceName)
$pluginManagerImplementation instanceof ContainerInterface
&& $pluginManagerImplementation->has($this->serviceName)
) {
return $pluginManagerImplemenation->get($this->serviceName);
return $pluginManagerImplementation->get($this->serviceName);
}

throw new AutoWiringNotPossibleException($this->serviceName);
Expand Down
5 changes: 1 addition & 4 deletions src/Injection/InjectionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,5 @@
*/
interface InjectionInterface
{
/**
* @return mixed
*/
public function __invoke(ContainerInterface $container);
public function __invoke(ContainerInterface $container): mixed;
}
12 changes: 3 additions & 9 deletions src/Injection/Value.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,14 @@
*/
class Value implements InjectionInterface
{
/**
* @var mixed
*/
private $value;
private mixed $value;

/**
* @param mixed $value
*/
public function __construct($value)
public function __construct(mixed $value)
{
$this->value = $value;
}

public function __invoke(ContainerInterface $container)
public function __invoke(ContainerInterface $container): mixed
{
return $this->value;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Service/AutoWiring/Factory/ResolverServiceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function __invoke(ContainerInterface $container): ResolverService
}

/**
* @return class-string[]
* @return class-string<ResolverInterface>[]
*/
private function getResolverStack(array $config): array
{
Expand Down
2 changes: 0 additions & 2 deletions src/Service/AutoWiring/LazyResolverService.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
use Psr\Container\ContainerInterface;

/**
* Class LazyResolverService
*
* @package Reinfi\DependencyInjection\Service\AutoWiring
*/
class LazyResolverService implements ResolverServiceInterface
Expand Down
2 changes: 1 addition & 1 deletion src/Service/Cache/Memory.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Memory implements CacheInterface
{
private array $cachedItems = [];

public function get($key, $default = null)
public function get($key, $default = null): mixed
{
return $this->cachedItems[$key] ?? $default;
}
Expand Down
Loading
Loading