Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
17 changes: 9 additions & 8 deletions src/bundle/Core/URLChecker/Handler/HTTPHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<int, \Ibexa\Contracts\Core\Repository\Values\URL\URL> $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,
Expand All @@ -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;
}

Expand Down
31 changes: 31 additions & 0 deletions src/contracts/Repository/Values/URL/URL.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace Ibexa\Contracts\Core\Repository\Values\URL;

use DateTimeInterface;
use Ibexa\Contracts\Core\Repository\Values\ValueObject;

class URL extends ValueObject
Expand Down Expand Up @@ -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;
}
}