diff --git a/src/OpenClassrooms/UseCase/Application/Services/Event/EventFactory.php b/src/OpenClassrooms/UseCase/Application/Services/Event/EventFactory.php index 28408df..5c32506 100644 --- a/src/OpenClassrooms/UseCase/Application/Services/Event/EventFactory.php +++ b/src/OpenClassrooms/UseCase/Application/Services/Event/EventFactory.php @@ -17,8 +17,8 @@ interface EventFactory */ public function make( $eventName, - UseCaseRequest $useCaseRequest = null, - UseCaseResponse $useCaseResponse = null, - \Exception $exception = null + ?UseCaseRequest $useCaseRequest = null, + ?UseCaseResponse $useCaseResponse = null, + ?\Exception $exception = null ); } diff --git a/src/OpenClassrooms/UseCase/Application/Services/Proxy/Strategies/Impl/Cache/CacheProxyStrategy.php b/src/OpenClassrooms/UseCase/Application/Services/Proxy/Strategies/Impl/Cache/CacheProxyStrategy.php index e1c6a0d..8f844c4 100644 --- a/src/OpenClassrooms/UseCase/Application/Services/Proxy/Strategies/Impl/Cache/CacheProxyStrategy.php +++ b/src/OpenClassrooms/UseCase/Application/Services/Proxy/Strategies/Impl/Cache/CacheProxyStrategy.php @@ -67,7 +67,7 @@ public function postExecute(ProxyStrategyRequest $proxyStrategyRequest) return new ProxyStrategyResponseDTO($item->get(), false); } - private function fetchWithNamespace(string $id, string $namespace = null): CacheItemInterface + private function fetchWithNamespace(string $id, ?string $namespace = null): CacheItemInterface { if ($namespace !== null) { $namespaceId = $this->cache->getItem($namespace); @@ -78,7 +78,7 @@ private function fetchWithNamespace(string $id, string $namespace = null): Cache return $this->cache->getItem($id); } - private function saveWithNamespace(string $id, mixed $data, string $namespace = null, int $lifetime = null): CacheItemInterface + private function saveWithNamespace(string $id, mixed $data, ?string $namespace = null, ?int $lifetime = null): CacheItemInterface { if ($namespace !== null) { $namespaceId = $this->cache->getItem($namespace); diff --git a/src/OpenClassrooms/UseCase/Application/Services/Proxy/Strategies/Impl/Event/DTO/EventProxyStrategyRequestBuilderImpl.php b/src/OpenClassrooms/UseCase/Application/Services/Proxy/Strategies/Impl/Event/DTO/EventProxyStrategyRequestBuilderImpl.php index 40472cf..10fd394 100644 --- a/src/OpenClassrooms/UseCase/Application/Services/Proxy/Strategies/Impl/Event/DTO/EventProxyStrategyRequestBuilderImpl.php +++ b/src/OpenClassrooms/UseCase/Application/Services/Proxy/Strategies/Impl/Event/DTO/EventProxyStrategyRequestBuilderImpl.php @@ -52,7 +52,7 @@ public function withUseCaseRequest(UseCaseRequest $useCaseRequest) /** * @return EventProxyStrategyRequestBuilder */ - public function withUseCaseResponse(UseCaseResponse $useCaseResponse = null) + public function withUseCaseResponse(?UseCaseResponse $useCaseResponse = null) { $this->request->useCaseResponse = $useCaseResponse; diff --git a/src/OpenClassrooms/UseCase/Application/Services/Proxy/Strategies/Impl/ProxyStrategyRequestFactoryImpl.php b/src/OpenClassrooms/UseCase/Application/Services/Proxy/Strategies/Impl/ProxyStrategyRequestFactoryImpl.php index 7c13dd7..82c65f6 100644 --- a/src/OpenClassrooms/UseCase/Application/Services/Proxy/Strategies/Impl/ProxyStrategyRequestFactoryImpl.php +++ b/src/OpenClassrooms/UseCase/Application/Services/Proxy/Strategies/Impl/ProxyStrategyRequestFactoryImpl.php @@ -175,7 +175,7 @@ public function createPostExecuteRequest( $annotation, UseCase $useCase, UseCaseRequest $useCaseRequest, - UseCaseResponse $useCaseResponse = null + ?UseCaseResponse $useCaseResponse = null ) { $request = new ProxyStrategyRequestDTO(); switch ($annotation) { diff --git a/src/OpenClassrooms/UseCase/Application/Services/Proxy/UseCases/UseCaseProxy.php b/src/OpenClassrooms/UseCase/Application/Services/Proxy/UseCases/UseCaseProxy.php index 061a674..a401bf8 100644 --- a/src/OpenClassrooms/UseCase/Application/Services/Proxy/UseCases/UseCaseProxy.php +++ b/src/OpenClassrooms/UseCase/Application/Services/Proxy/UseCases/UseCaseProxy.php @@ -179,7 +179,7 @@ private function sortPreStrategies() usort( $this->strategies, function (ProxyStrategyBag $s1, ProxyStrategyBag $s2) { - return array_search($s1->getType(), UseCaseProxy::$strategyPreOrder) > + return array_search($s1->getType(), UseCaseProxy::$strategyPreOrder) <=> array_search($s2->getType(), UseCaseProxy::$strategyPreOrder); } ); @@ -215,7 +215,7 @@ private function sortPostStrategies() usort( $this->strategies, function (ProxyStrategyBag $s1, ProxyStrategyBag $s2) { - return array_search($s1->getType(), UseCaseProxy::$strategyPostOrder) > + return array_search($s1->getType(), UseCaseProxy::$strategyPostOrder) <=> array_search($s2->getType(), UseCaseProxy::$strategyPostOrder); } ); @@ -242,7 +242,7 @@ private function sortOnExceptionStrategies() usort( $this->strategies, function (ProxyStrategyBag $s1, ProxyStrategyBag $s2) { - return array_search($s1->getType(), UseCaseProxy::$strategyOnExceptionOrder) > + return array_search($s1->getType(), UseCaseProxy::$strategyOnExceptionOrder) <=> array_search($s2->getType(), UseCaseProxy::$strategyOnExceptionOrder); } ); diff --git a/src/OpenClassrooms/UseCase/Application/Services/Proxy/UseCases/UseCaseProxyBuilder.php b/src/OpenClassrooms/UseCase/Application/Services/Proxy/UseCases/UseCaseProxyBuilder.php index b58c02b..1bdc7b6 100644 --- a/src/OpenClassrooms/UseCase/Application/Services/Proxy/UseCases/UseCaseProxyBuilder.php +++ b/src/OpenClassrooms/UseCase/Application/Services/Proxy/UseCases/UseCaseProxyBuilder.php @@ -85,7 +85,7 @@ abstract public function create(UseCase $useCase); /** * @return UseCaseProxyBuilder */ - public function withCache(CacheItemPoolInterface $cache = null) + public function withCache(?CacheItemPoolInterface $cache = null) { $this->cache = $cache; @@ -95,7 +95,7 @@ public function withCache(CacheItemPoolInterface $cache = null) /** * @return UseCaseProxyBuilder */ - public function withEventSender(EventSender $event = null) + public function withEventSender(?EventSender $event = null) { $this->event = $event; @@ -105,7 +105,7 @@ public function withEventSender(EventSender $event = null) /** * @return UseCaseProxyBuilder */ - public function withEventFactory(EventFactory $eventFactory = null) + public function withEventFactory(?EventFactory $eventFactory = null) { $this->eventFactory = $eventFactory; @@ -132,7 +132,7 @@ public function withReader(Reader $reader) /** * @return UseCaseProxyBuilder */ - public function withSecurity(Security $security = null) + public function withSecurity(?Security $security = null) { $this->security = $security; @@ -142,7 +142,7 @@ public function withSecurity(Security $security = null) /** * @return UseCaseProxyBuilder */ - public function withTransaction(Transaction $transaction = null) + public function withTransaction(?Transaction $transaction = null) { $this->transaction = $transaction; diff --git a/tests/OpenClassrooms/UseCase/Application/Services/Event/EventFactorySpy.php b/tests/OpenClassrooms/UseCase/Application/Services/Event/EventFactorySpy.php index 726171b..cf32be5 100644 --- a/tests/OpenClassrooms/UseCase/Application/Services/Event/EventFactorySpy.php +++ b/tests/OpenClassrooms/UseCase/Application/Services/Event/EventFactorySpy.php @@ -36,9 +36,9 @@ class EventFactorySpy implements EventFactory */ public function make( $eventName, - UseCaseRequest $useCaseRequest = null, - UseCaseResponse $useCaseResponse = null, - \Exception $exception = null + ?UseCaseRequest $useCaseRequest = null, + ?UseCaseResponse $useCaseResponse = null, + ?\Exception $exception = null ) { $this->useCaseRequest = $useCaseRequest; $this->useCaseResponse = $useCaseResponse; diff --git a/tests/bootstrap.php b/tests/bootstrap.php index ff94591..97b0d28 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -4,7 +4,7 @@ use Composer\Autoload\ClassLoader; -error_reporting(E_ALL | E_STRICT); +error_reporting(E_ALL); /** @var ClassLoader $loader */ require __DIR__.'/../vendor/autoload.php';