diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 8dcdb95bee..c97998b454 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -3910,21 +3910,6 @@ parameters: count: 1 path: src/bundle/Core/URLChecker/Handler/AbstractURLHandler.php - - - message: "#^Access to protected property Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\URL\\\\URL\\:\\:\\$url\\.$#" - count: 1 - path: src/bundle/Core/URLChecker/Handler/HTTPHandler.php - - - - message: "#^Method Ibexa\\\\Bundle\\\\Core\\\\URLChecker\\\\Handler\\\\HTTPHandler\\:\\:createCurlHandlerForUrl\\(\\) has parameter \\$handlers with no value type specified in iterable type array\\.$#" - count: 1 - path: src/bundle/Core/URLChecker/Handler/HTTPHandler.php - - - - message: "#^Method Ibexa\\\\Bundle\\\\Core\\\\URLChecker\\\\Handler\\\\HTTPHandler\\:\\:createCurlHandlerForUrl\\(\\) should return resource but returns CurlHandle\\.$#" - count: 1 - path: src/bundle/Core/URLChecker/Handler/HTTPHandler.php - - message: "#^Method Ibexa\\\\Bundle\\\\Core\\\\URLChecker\\\\Handler\\\\HTTPHandler\\:\\:doValidate\\(\\) has no return type specified\\.$#" count: 1 @@ -3950,11 +3935,6 @@ parameters: count: 1 path: src/bundle/Core/URLChecker/Handler/HTTPHandler.php - - - message: "#^Parameter \\#2 \\$handle of function curl_multi_add_handle expects CurlHandle, resource given\\.$#" - count: 2 - path: src/bundle/Core/URLChecker/Handler/HTTPHandler.php - - message: "#^Access to protected property Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\URL\\\\URL\\:\\:\\$url\\.$#" count: 1 diff --git a/src/bundle/Core/URLChecker/Handler/HTTPHandler.php b/src/bundle/Core/URLChecker/Handler/HTTPHandler.php index 34e6ddd5f2..a121c2c2af 100644 --- a/src/bundle/Core/URLChecker/Handler/HTTPHandler.php +++ b/src/bundle/Core/URLChecker/Handler/HTTPHandler.php @@ -7,7 +7,9 @@ namespace Ibexa\Bundle\Core\URLChecker\Handler; +use CurlHandle; use Ibexa\Contracts\Core\Repository\Values\URL\URL; +use LogicException; use Symfony\Component\OptionsResolver\OptionsResolver; class HTTPHandler extends AbstractConfigResolverBasedURLHandler @@ -108,20 +110,15 @@ public function getOptions(): array /** * Initialize and return a cURL session for given URL. * - * @param \Ibexa\Contracts\Core\Repository\Values\URL\URL $url - * @param array $handlers - * @param int $connectionTimeout - * @param int $timeout - * - * @return resource + * @param array $handlers */ - private function createCurlHandlerForUrl(URL $url, array &$handlers, int $connectionTimeout, int $timeout) + private function createCurlHandlerForUrl(URL $url, array &$handlers, int $connectionTimeout, int $timeout): CurlHandle { $options = $this->getOptions(); $handler = curl_init(); curl_setopt_array($handler, [ - CURLOPT_URL => $url->url, + CURLOPT_URL => $url->getUrl(), CURLOPT_RETURNTRANSFER => false, CURLOPT_FOLLOWLOCATION => true, CURLOPT_CONNECTTIMEOUT => $connectionTimeout, @@ -139,6 +136,10 @@ private function createCurlHandlerForUrl(URL $url, array &$handlers, int $connec $handlers[(int)$handler] = $url; + if (false === $handler) { + throw new LogicException("Failed to create Curl handler for '{$url->getUrl()}' URL", 1); + } + return $handler; } diff --git a/src/contracts/Repository/Values/URL/URL.php b/src/contracts/Repository/Values/URL/URL.php index 3febc00d4a..721d6d1506 100644 --- a/src/contracts/Repository/Values/URL/URL.php +++ b/src/contracts/Repository/Values/URL/URL.php @@ -8,6 +8,7 @@ namespace Ibexa\Contracts\Core\Repository\Values\URL; +use DateTimeInterface; use Ibexa\Contracts\Core\Repository\Values\ValueObject; class URL extends ValueObject @@ -53,4 +54,34 @@ class URL extends ValueObject * @var \DateTimeInterface */ protected $modified; + + public function getId(): int + { + return $this->id; + } + + public function getUrl(): string + { + return $this->url; + } + + public function isValid(): bool + { + return $this->isValid; + } + + public function getLastChecked(): ?DateTimeInterface + { + return $this->lastChecked; + } + + public function getCreated(): ?DateTimeInterface + { + return $this->created; + } + + public function getModified(): ?DateTimeInterface + { + return $this->modified; + } }