Skip to content

Commit

Permalink
Merge 08d8db1 into c027699
Browse files Browse the repository at this point in the history
  • Loading branch information
Jalle19 committed Jun 27, 2019
2 parents c027699 + 08d8db1 commit 700a2c7
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
@@ -1,7 +1,6 @@
language: php

php:
- 7.0
- 7.1
- 7.2
- 7.3
Expand All @@ -21,6 +20,7 @@ install:

script:
- vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover
- vendor/bin/phpstan analyse src

after_success:
- wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.clover
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Expand Up @@ -23,7 +23,7 @@ We accept contributions via Pull Requests on [Github](https://github.com/thephpl
## Running Tests

``` bash
$ phpunit
$ composer test
```

**Happy coding**!
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -27,9 +27,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

## Documentation

Expand All @@ -40,7 +40,7 @@ Contribute to this documentation in the [gh-pages branch](https://github.com/the
## Testing

``` bash
$ vendor/bin/phpunit
$ composer test
```

## Contributing
Expand Down
11 changes: 9 additions & 2 deletions composer.json
Expand Up @@ -21,12 +21,13 @@
}
],
"require": {
"php": "^7.0",
"php": "^7.1",
"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 @@ -50,5 +51,11 @@
"dev-2.x": "2.x-dev",
"dev-1.x": "1.x-dev"
}
},
"scripts": {
"test": [
"phpunit",
"phpstan analyse src/"
]
}
}
2 changes: 2 additions & 0 deletions phpstan.neon
@@ -0,0 +1,2 @@
includes:
- vendor/phpstan/phpstan/conf/config.level7.neon
5 changes: 4 additions & 1 deletion src/Definition/Definition.php
Expand Up @@ -259,7 +259,10 @@ protected function invokeMethods($instance)
{
foreach ($this->methods as $method) {
$args = $this->resolveArguments($method['arguments']);
call_user_func_array([$instance, $method['method']], $args);

/** @var callable $callable */
$callable = [$instance, $method['method']];
call_user_func_array($callable, $args);
}

return $instance;
Expand Down
13 changes: 8 additions & 5 deletions src/Inflector/Inflector.php
Expand Up @@ -2,9 +2,9 @@

namespace League\Container\Inflector;

use League\Container\ContainerAwareTrait;
use League\Container\Argument\ArgumentResolverInterface;
use League\Container\Argument\ArgumentResolverTrait;
use League\Container\ContainerAwareTrait;

class Inflector implements ArgumentResolverInterface, InflectorInterface
{
Expand All @@ -17,7 +17,7 @@ class Inflector implements ArgumentResolverInterface, InflectorInterface
protected $type;

/**
* @var callable
* @var callable|null
*/
protected $callback;

Expand Down Expand Up @@ -103,17 +103,20 @@ public function inflect($object)
$properties = $this->resolveArguments(array_values($this->properties));
$properties = array_combine(array_keys($this->properties), $properties);

foreach ($properties as $property => $value) {
// array_combine() can technically return false
foreach ($properties ?: [] as $property => $value) {
$object->{$property} = $value;
}

foreach ($this->methods as $method => $args) {
$args = $this->resolveArguments($args);

call_user_func_array([$object, $method], $args);
/** @var callable $callable */
$callable = [$object, $method];
call_user_func_array($callable, $args);
}

if (! is_null($this->callback)) {
if ($this->callback !== null) {
call_user_func_array($this->callback, [$object]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Inflector/InflectorAggregate.php
Expand Up @@ -10,7 +10,7 @@ class InflectorAggregate implements InflectorAggregateInterface
use ContainerAwareTrait;

/**
* @var \League\Container\Inflector[]
* @var \League\Container\Inflector\Inflector[]
*/
protected $inflectors = [];

Expand Down
2 changes: 1 addition & 1 deletion src/ReflectionContainer.php
Expand Up @@ -98,7 +98,7 @@ public function call(callable $callable, array $args = [])
return $reflection->invokeArgs($callable, $this->reflectArguments($reflection, $args));
}

$reflection = new ReflectionFunction($callable);
$reflection = new ReflectionFunction(\Closure::fromCallable($callable));

return $reflection->invokeArgs($this->reflectArguments($reflection, $args));
}
Expand Down

0 comments on commit 700a2c7

Please sign in to comment.