diff --git a/.travis.yml b/.travis.yml index 6d060d0..f9dc0aa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,8 @@ language: php php: - - 5.6 - - 7.0 - - hhvm + - 7.1 + - 7.2 before_script: - composer install --no-interaction diff --git a/composer.json b/composer.json index fb59afe..416b633 100644 --- a/composer.json +++ b/composer.json @@ -21,12 +21,13 @@ }, "minimum-stability": "stable", "require": { - "php": ">=5.6.0", - "symfony/http-foundation": "^3.0", - "symfony/validator": "^3.0" + "php": ">=7.1.0", + "symfony/http-foundation": "^3.3|^4.0", + "symfony/validator": "^3.3|^4.0" }, "require-dev": { "phpunit/phpunit": "^5.3", - "symfony/framework-bundle": "^3.0" + "symfony/framework-bundle": "^3.3|^4.0", + "symfony/var-dumper": "^4.0" } } diff --git a/examples/App/config.yml b/examples/App/config.yml index 0a5b310..40d327e 100644 --- a/examples/App/config.yml +++ b/examples/App/config.yml @@ -17,4 +17,5 @@ framework: services: app_controller: - class: 'Fesor\RequestObject\Examples\App\AppController' \ No newline at end of file + class: 'Fesor\RequestObject\Examples\App\AppController' + public: true diff --git a/src/Bundle/DependeyInjection/RequestObjectExtension.php b/src/Bundle/DependeyInjection/RequestObjectExtension.php index 487e320..a596c10 100644 --- a/src/Bundle/DependeyInjection/RequestObjectExtension.php +++ b/src/Bundle/DependeyInjection/RequestObjectExtension.php @@ -6,9 +6,9 @@ use Fesor\RequestObject\HttpPayloadResolver; use Fesor\RequestObject\PayloadResolver; use Fesor\RequestObject\RequestObjectBinder; +use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; -use Symfony\Component\DependencyInjection\DefinitionDecorator; use Symfony\Component\DependencyInjection\Extension\Extension; use Symfony\Component\DependencyInjection\Reference; @@ -27,9 +27,11 @@ private function registerPayloadResolver(ContainerBuilder $container) $definition->setAbstract(true); $container->setDefinition('request_object.payload_resolver', $definition); - $implDefinition = new DefinitionDecorator('request_object.payload_resolver'); + $implDefinition = new ChildDefinition('request_object.payload_resolver'); $implDefinition->setClass(HttpPayloadResolver::class); $container->setDefinition('request_object.payload_resolver.http', $implDefinition); + + $container->setAlias(PayloadResolver::class, 'request_object.payload_resolver.http'); } private function registerRequestBinder(ContainerBuilder $container) diff --git a/src/RequestObjectBinder.php b/src/RequestObjectBinder.php index fe3e9c0..ff753a7 100644 --- a/src/RequestObjectBinder.php +++ b/src/RequestObjectBinder.php @@ -73,7 +73,7 @@ public function bind(Request $request, callable $action) $requestObject->setPayload($payload); if (array_key_exists('errors', $matchedArguments)) { $request->attributes->set($matchedArguments['errors']->name, $errors); - } elseif (0 !== count($errors)) { + } elseif ($errors && 0 !== $errors->count()) { return $this->providerErrorResponse($requestObject, $errors); } }