Skip to content

Commit

Permalink
Merge pull request #71 from reinfi/master-6.x
Browse files Browse the repository at this point in the history
Master 6.x
  • Loading branch information
reinfi authored Oct 21, 2023
2 parents 2039ae0 + 717c52b commit 0e45088
Show file tree
Hide file tree
Showing 28 changed files with 46 additions and 86 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
fail-fast: false
max-parallel: 1
matrix:
php: ['8.0']
php: ['8.1']
name: PHP ${{ matrix.php }} ${{ matrix.description }}
steps:
- name: Checkout
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
## 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
Expand Down
4 changes: 2 additions & 2 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
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
4 changes: 1 addition & 3 deletions src/Service/Extractor/Factory/ExtractorFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ public function __invoke(ContainerInterface $container): ExtractorInterface
$extractors[] = $container->get(AnnotationExtractor::class);
}

if (version_compare(PHP_VERSION, '8.0.0') >= 0) {
$extractors[] = $container->get(AttributeExtractor::class);
}
$extractors[] = $container->get(AttributeExtractor::class);

return new ExtractorChain($extractors);
}
Expand Down
Loading

0 comments on commit 0e45088

Please sign in to comment.