Skip to content

Commit

Permalink
Added return types
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanvierkant committed Dec 8, 2021
1 parent 89e7563 commit 2078a4f
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 42 deletions.
2 changes: 1 addition & 1 deletion src/Binary/Loader/FileSystemLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function __construct(
/**
* {@inheritdoc}
*/
public function find($path)
public function find($path): FileBinary
{
$path = $this->locator->locate($path);
$mimeType = $this->mimeTypeGuesser->guessMimeType($path);
Expand Down
2 changes: 1 addition & 1 deletion src/Binary/Loader/FlysystemLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct(
/**
* {@inheritdoc}
*/
public function find($path)
public function find($path): Binary
{
if (false === $this->filesystem->has($path)) {
throw new NotLoadableException(sprintf('Source image "%s" not found.', $path));
Expand Down
2 changes: 1 addition & 1 deletion src/Binary/Loader/FlysystemV2Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct(
/**
* {@inheritdoc}
*/
public function find($path)
public function find($path): Binary
{
try {
$mimeType = $this->filesystem->mimeType($path);
Expand Down
2 changes: 1 addition & 1 deletion src/Binary/Loader/StreamLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function __construct(string $wrapperPrefix, $context = null)
/**
* {@inheritdoc}
*/
public function find($path)
public function find($path): string
{
$name = $this->wrapperPrefix.$path;

Expand Down
32 changes: 1 addition & 31 deletions src/Events/CacheResolveEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,75 +15,45 @@

class CacheResolveEvent extends Event
{
/**
* Resource path.
*/
protected string $path;

/**
* Filter name.
*/
protected string $filter;

/**
* Resource url.
*/
protected ?string $url;

/**
* Init default event state.
*/
public function __construct(string $path, string $filter, ?string $url = null)
{
$this->path = $path;
$this->filter = $filter;
$this->url = $url;
}

/**
* Sets resource path.
*/
public function setPath(string $path): void
{
$this->path = $path;
}

/**
* Returns resource path.
*/
public function getPath(): string
{
return $this->path;
}

/**
* Sets filter name.
*/
public function setFilter(string $filter): void
{
$this->filter = $filter;
}

/**
* Returns filter name.
*/
public function getFilter(): string
{
return $this->filter;
}

/**
* Sets resource url.
*/
public function setUrl(?string $url): void
{
$this->url = $url;
}

/**
* Returns resource url.
*/
public function getUrl(): ?string
public function getUrl(): string
{
return $this->url;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Imagine/Cache/CacheManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function addResolver(string $filter, ResolverInterface $resolver): void
*
* @param string $path The path where the resolved file is expected
*/
public function getBrowserPath(string $path, string $filter, array $runtimeConfig = [], ?string $resolver = null, int $referenceType = UrlGeneratorInterface::ABSOLUTE_URL): string
public function getBrowserPath(string $path, string $filter, array $runtimeConfig = [], ?string $resolver = null, int $referenceType = UrlGeneratorInterface::ABSOLUTE_URL): ?string
{
if (!empty($runtimeConfig)) {
$rcPath = $this->getRuntimePath($path, $runtimeConfig);
Expand Down
2 changes: 1 addition & 1 deletion src/Imagine/Cache/Resolver/ProxyResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function remove(array $paths, array $filters): void
$this->resolver->remove($paths, $filters);
}

protected function rewriteUrl(string $url): string
protected function rewriteUrl(string $url): ?string
{
if (empty($this->hosts)) {
return $url;
Expand Down
4 changes: 2 additions & 2 deletions src/Imagine/Filter/FilterManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function apply(BinaryInterface $binary, array $config): BinaryInterface
return $this->applyPostProcessors($this->applyFilters($binary, $config), $config);
}

public function applyFilters(BinaryInterface $binary, array $config): BinaryInterface
public function applyFilters(BinaryInterface $binary, array $config): Binary
{
if ($binary instanceof FileBinaryInterface) {
$image = $this->imagine->open($binary->getPath());
Expand Down Expand Up @@ -126,7 +126,7 @@ public function applyPostProcessors(BinaryInterface $binary, array $config): Bin
return $binary;
}

private function exportConfiguredImageBinary(BinaryInterface $binary, ImageInterface $image, array $config): BinaryInterface
private function exportConfiguredImageBinary(BinaryInterface $binary, ImageInterface $image, array $config): Binary
{
$options = [
'quality' => $config['quality'],
Expand Down
6 changes: 3 additions & 3 deletions src/Service/FilterService.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function warmUpCache(
return $warmedUp;
}

public function getUrlOfFilteredImage(string $path, string $filter, ?string $resolver = null, bool $webpSupported = false): string
public function getUrlOfFilteredImage(string $path, string $filter, ?string $resolver = null, bool $webpSupported = false): ?string
{
foreach ($this->buildFilterPathContainers($path) as $filterPathContainer) {
$this->warmUpCacheFilterPathContainer($filterPathContainer, $filter, $resolver);
Expand All @@ -107,7 +107,7 @@ public function getUrlOfFilteredImageWithRuntimeFilters(
array $runtimeFilters = [],
?string $resolver = null,
bool $webpSupported = false
): string {
): ?string {
$runtimePath = $this->cacheManager->getRuntimePath($path, $runtimeFilters);
$runtimeOptions = [
'filters' => $runtimeFilters,
Expand Down Expand Up @@ -147,7 +147,7 @@ private function resolveFilterPathContainer(
string $filter,
?string $resolver = null,
bool $webpSupported = false
): string {
): ?string {
$path = $filterPathContainer->getTarget();

if ($this->webpGenerate && $webpSupported) {
Expand Down

0 comments on commit 2078a4f

Please sign in to comment.