Skip to content

Commit

Permalink
Merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
philipobenito committed May 18, 2020
1 parent 93238f7 commit bef3d8f
Show file tree
Hide file tree
Showing 24 changed files with 159 additions and 327 deletions.
2 changes: 1 addition & 1 deletion .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ tools:
php_code_coverage: false
php_code_sniffer:
config:
standard: PSR2
standard: PSR12
filter:
paths: ['src']
php_loc:
Expand Down
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
language: php

php:
- 7.0
- 7.1
- 7.2
- 7.3
- 7.4
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
[![Quality Score](https://img.shields.io/scrutinizer/g/thephpleague/container.svg?style=flat-square)](https://scrutinizer-ci.com/g/thephpleague/container)
[![Total Downloads](https://img.shields.io/packagist/dt/league/container.svg?style=flat-square)](https://packagist.org/packages/league/container)

This package is compliant with [PSR-1], [PSR-2], [PSR-4] and [PSR-11]. If you notice compliance oversights, please send a patch via pull request.
This package is compliant with [PSR-1], [PSR-2], [PSR-12], [PSR-4] and [PSR-11]. If you notice compliance oversights, please send a patch via pull request.

[PSR-1]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md
[PSR-2]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md
[PSR-12]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-12-extended-coding-style-guide.md
[PSR-4]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader.md
[PSR-11]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-11-container.md

Expand All @@ -27,10 +28,9 @@ $ composer require league/container

The following versions of PHP are supported by this version.

* PHP 7.0
* PHP 7.1
* PHP 7.2
* PHP 7.3
* PHP 7.4

## Documentation

Expand All @@ -40,6 +40,7 @@ Contribute to this documentation in the [docs/](https://github.com/thephpleague/

## Testing

Testing includes PHPUnit and PHPStan (Level 7).
``` bash
$ composer test
```
Expand Down
8 changes: 5 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@
}
],
"require": {
"php": "^7.0",
"php": "^7.2",
"psr/container": "^1.0"
},
"require-dev": {
"phpunit/phpunit" : "^6.0",
"squizlabs/php_codesniffer": "^3.3"
"squizlabs/php_codesniffer": "^3.3",
"phpstan/phpstan": "^0.11.8"
},
"provide": {
"psr/container-implementation": "^1.0"
Expand All @@ -53,7 +54,8 @@
},
"scripts": {
"test": [
"phpunit"
"phpunit",
"phpstan analyse --level 7 src"
]
}
}
10 changes: 0 additions & 10 deletions phpcs.xml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace League\Container\Argument;

interface RawArgumentInterface
interface ArgumentInterface
{
/**
* Return the value of the raw argument.
Expand Down
8 changes: 5 additions & 3 deletions src/Argument/ArgumentResolverInterface.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace League\Container\Argument;

Expand All @@ -14,7 +16,7 @@ interface ArgumentResolverInterface extends ContainerAwareInterface
*
* @return array
*/
public function resolveArguments(array $arguments) : array;
public function resolveArguments(array $arguments): array;

/**
* Resolves the correct arguments to be passed to a method.
Expand All @@ -24,5 +26,5 @@ public function resolveArguments(array $arguments) : array;
*
* @return array
*/
public function reflectArguments(ReflectionFunctionAbstract $method, array $args = []) : array;
public function reflectArguments(ReflectionFunctionAbstract $method, array $args = []): array;
}
50 changes: 19 additions & 31 deletions src/Argument/ArgumentResolverTrait.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace League\Container\Argument;

use League\Container\Container;
use League\Container\Exception\{ContainerException, NotFoundException};
use League\Container\DefinitionContainerInterface;
use League\Container\ReflectionContainer;
use Psr\Container\ContainerInterface;
use ReflectionFunctionAbstract;
Expand All @@ -14,41 +16,30 @@ trait ArgumentResolverTrait
/**
* {@inheritdoc}
*/
public function resolveArguments(array $arguments) : array
public function resolveArguments(array $arguments): array
{
try {
$container = $this->getContainer();
} catch (ContainerException $e) {
$container = ($this instanceof ReflectionContainer) ? $this : null;
}

foreach ($arguments as &$arg) {
if ($arg instanceof RawArgumentInterface) {
if ($arg instanceof ArgumentInterface) {
$arg = $arg->getValue();
continue;
}

if ($arg instanceof ClassNameInterface) {
$arg = $arg->getValue();
}

if (! is_string($arg)) {
continue;
}

$container = null;

try {
$container = $this->getLeagueContainer();
} catch (ContainerException $e) {
if ($this instanceof ReflectionContainer) {
$container = $this;
}
}


if ($container !== null && $container->has($arg)) {
if ($container instanceof ContainerInterface && $container->has($arg)) {
$arg = $container->get($arg);

if ($arg instanceof RawArgumentInterface) {
if ($arg instanceof ArgumentInterface) {
$arg = $arg->getValue();
}

continue;
}
}

Expand All @@ -58,7 +49,7 @@ public function resolveArguments(array $arguments) : array
/**
* {@inheritdoc}
*/
public function reflectArguments(ReflectionFunctionAbstract $method, array $args = []) : array
public function reflectArguments(ReflectionFunctionAbstract $method, array $args = []): array
{
$arguments = array_map(function (ReflectionParameter $param) use ($method, $args) {
$name = $param->getName();
Expand Down Expand Up @@ -87,12 +78,9 @@ public function reflectArguments(ReflectionFunctionAbstract $method, array $args
}

/**
* @return ContainerInterface
*/
abstract public function getContainer() : ContainerInterface;

/**
* @return Container
* Get the container.
*
* @return DefinitionContainerInterface
*/
abstract public function getLeagueContainer() : Container;
abstract public function getContainer(): DefinitionContainerInterface;
}
29 changes: 0 additions & 29 deletions src/Argument/ClassName.php

This file was deleted.

13 changes: 0 additions & 13 deletions src/Argument/ClassNameInterface.php

This file was deleted.

29 changes: 0 additions & 29 deletions src/Argument/RawArgument.php

This file was deleted.

Loading

0 comments on commit bef3d8f

Please sign in to comment.