Skip to content

Commit

Permalink
apply cs fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dbu committed Mar 15, 2024
1 parent 0d85982 commit bb86bc3
Show file tree
Hide file tree
Showing 28 changed files with 81 additions and 123 deletions.
2 changes: 1 addition & 1 deletion scripts/doctum-config.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

use Doctum\RemoteRepository\GitHubRemoteRepository;
use Doctum\Doctum;
use Doctum\RemoteRepository\GitHubRemoteRepository;
use Doctum\Version\GitVersionCollection;
use Symfony\Component\Finder\Finder;

Expand Down
2 changes: 0 additions & 2 deletions src/Core/DynamicMetadata/DynamicMetadataInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ public static function createFromDecodedJsonResponse($data);

/**
* Get the data, which should be json-fied later.
*
* @return mixed
*/
public function getForJson();

Check failure on line 27 in src/Core/DynamicMetadata/DynamicMetadataInterface.php

View workflow job for this annotation

GitHub Actions / phpstan 8.0

Method Rokka\Client\Core\DynamicMetadata\DynamicMetadataInterface::getForJson() has no return type specified.

Check failure on line 27 in src/Core/DynamicMetadata/DynamicMetadataInterface.php

View workflow job for this annotation

GitHub Actions / phpstan 8.1

Method Rokka\Client\Core\DynamicMetadata\DynamicMetadataInterface::getForJson() has no return type specified.

Check failure on line 27 in src/Core/DynamicMetadata/DynamicMetadataInterface.php

View workflow job for this annotation

GitHub Actions / phpstan 8.2

Method Rokka\Client\Core\DynamicMetadata\DynamicMetadataInterface::getForJson() has no return type specified.
}
3 changes: 1 addition & 2 deletions src/Core/SourceImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ class SourceImage
* @param string $shortHash The short hash
* @param bool $protected Is image protected
* @param bool $locked Is image locked
* @param mixed $mimetype
*/
public function __construct(

Check failure on line 117 in src/Core/SourceImage.php

View workflow job for this annotation

GitHub Actions / phpstan 8.0

Method Rokka\Client\Core\SourceImage::__construct() has parameter $mimetype with no type specified.

Check failure on line 117 in src/Core/SourceImage.php

View workflow job for this annotation

GitHub Actions / phpstan 8.1

Method Rokka\Client\Core\SourceImage::__construct() has parameter $mimetype with no type specified.

Check failure on line 117 in src/Core/SourceImage.php

View workflow job for this annotation

GitHub Actions / phpstan 8.2

Method Rokka\Client\Core\SourceImage::__construct() has parameter $mimetype with no type specified.
$organization,
Expand Down Expand Up @@ -165,7 +164,7 @@ public static function createFromDecodedJsonResponse(array $data): self
$data['user_metadata'] = [];
} else {
foreach ($data['user_metadata'] as $key => $value) {
if (0 === strpos($key, 'date:')) {
if (str_starts_with($key, 'date:')) {
$data['user_metadata'][$key] = new \DateTime($value);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Stack.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Stack extends AbstractStack
* @param array $stackOptions Collection of stack options
* @param \DateTime $created Created at
*/
public function __construct($organization = null, $name = null, array $stackOperations = [], array $stackOptions = [], \DateTime $created = null)
public function __construct($organization = null, $name = null, array $stackOperations = [], array $stackOptions = [], ?\DateTime $created = null)
{
parent::__construct($name, $stackOperations, $stackOptions);
$this->organization = $organization;
Expand Down
2 changes: 1 addition & 1 deletion src/Core/StackCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class StackCollection implements \Countable, \Iterator
*
* @param array $stacks Array of stacks
*/
public function __construct(array $stacks, string $cursor = null)
public function __construct(array $stacks, ?string $cursor = null)
{
foreach ($stacks as $stack) {
if (!($stack instanceof Stack)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Core/StackUri.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __construct($name = null, array $stackOperations = [], array $st
{
parent::__construct($name, $stackOperations, $stackOptions, $stackVariables);

if (null !== $name && false !== strpos($name, '/')) {
if (null !== $name && str_contains($name, '/')) {
// Some part of a rokka URL can have // in it, but it means nothing, remove them here.
$name = preg_replace('#/{2,}#', '/', $name);
if (!\is_string($name)) {
Expand Down
2 changes: 0 additions & 2 deletions src/Core/UriComponents.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ public function __construct($stack, $hash = null, $format = null, $filename = nu
* Creates a UriComponent object from an array with 'stack', 'hash', 'format', 'filename' and 'stack' as keys.
*
* @since 1.2.0
*
* @param mixed $config
*/
public static function createFromArray($config): self

Check failure on line 55 in src/Core/UriComponents.php

View workflow job for this annotation

GitHub Actions / phpstan 8.0

Method Rokka\Client\Core\UriComponents::createFromArray() has parameter $config with no type specified.

Check failure on line 55 in src/Core/UriComponents.php

View workflow job for this annotation

GitHub Actions / phpstan 8.1

Method Rokka\Client\Core\UriComponents::createFromArray() has parameter $config with no type specified.

Check failure on line 55 in src/Core/UriComponents.php

View workflow job for this annotation

GitHub Actions / phpstan 8.2

Method Rokka\Client\Core\UriComponents::createFromArray() has parameter $config with no type specified.
{
Expand Down
2 changes: 1 addition & 1 deletion src/Core/UserApiKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function __construct($id, $created, $accessed, $comment, $apiKey)
*
* @param array $apiKeys
*
* @return \Rokka\Client\Core\UserApiKey
* @return UserApiKey
*/
public static function createFromArray($apiKeys)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Core/UserApiToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct($token, $payload)
*
* @param array $resonse
*
* @return \Rokka\Client\Core\UserApiToken
* @return UserApiToken
*/
public static function createFromArray($resonse)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Factory
*
* @throws \RuntimeException
*
* @return Image
* @return ImageClient
*/
public static function getImageClient($organization, $apiKey, $options = [])
{
Expand Down Expand Up @@ -152,8 +152,8 @@ private static function retryDecider()
return function (
$retries,
Request $request,
Response $response = null,
TransferException $exception = null
?Response $response = null,
?TransferException $exception = null
) {
// Limit the number of retries to 10
if ($retries >= 10) {
Expand Down
16 changes: 8 additions & 8 deletions src/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Image extends Base
/**
* @var string|null the render base url like foo-org.rokka.io
*/
private $renderBaseUrl = null;
private $renderBaseUrl;

/**
* Constructor.
Expand Down Expand Up @@ -470,13 +470,13 @@ public function createStack(
*
* Example:
* ```language-php
$stack = new Stack(null, 'teststack');
$stack->addStackOperation(new StackOperation('resize', ['width' => 200, 'height' => 200]));
$stack->addStackOperation(new StackOperation('rotate', ['angle' => 45]));
$stack->setStackOptions(['jpg.quality' => 80]);
$requestConfig = ['overwrite' => true];
$stack = $client->saveStack($stack, $requestConfig);
echo 'Created stack ' . $stack->getName() . PHP_EOL;
* $stack = new Stack(null, 'teststack');
* $stack->addStackOperation(new StackOperation('resize', ['width' => 200, 'height' => 200]));
* $stack->addStackOperation(new StackOperation('rotate', ['angle' => 45]));
* $stack->setStackOptions(['jpg.quality' => 80]);
* $requestConfig = ['overwrite' => true];
* $stack = $client->saveStack($stack, $requestConfig);
* echo 'Created stack ' . $stack->getName() . PHP_EOL;
* ```
* The only requestConfig option currently can be
* ['overwrite' => true|false] (false is the default)
Expand Down
12 changes: 6 additions & 6 deletions src/LocalImage/AbstractLocalImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
*
* See some implementation of the abstract class for examples.
*
* @see \Rokka\Client\LocalImage\FileInfo
* @see \Rokka\Client\LocalImage\RokkaHash
* @see \Rokka\Client\LocalImage\StringContent
* @see FileInfo
* @see RokkaHash
* @see StringContent
* @since 1.3.0
*/
abstract class AbstractLocalImage
Expand All @@ -21,14 +21,14 @@ abstract class AbstractLocalImage
*
* @var mixed|null
*/
protected $context = null;
protected $context;

/**
* The rokka hash from the rokka API.
*
* @var string|null
*/
protected $rokkaHash = null;
protected $rokkaHash;

/**
* A unique identifier for this image, can be any string.
Expand All @@ -37,7 +37,7 @@ abstract class AbstractLocalImage
*
* @var string|null
*/
protected $identifier = null;
protected $identifier;

/**
* @since 1.3.0
Expand Down
6 changes: 3 additions & 3 deletions src/LocalImage/FileInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* $image = new StringContent($content, $identifier, $context);
* ```
*
* @see \Rokka\Client\LocalImage\StringContent
* @see StringContent
* @since 1.3.0
*/
class FileInfo extends AbstractLocalImage
Expand All @@ -34,12 +34,12 @@ class FileInfo extends AbstractLocalImage
/**
* @var string|null
*/
private $content = null;
private $content;

/**
* @var string|null
*/
private $filename = null;
private $filename;

public function __construct(\SplFileInfo $image, $identifier = null, $context = null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/LocalImage/RokkaHash.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class RokkaHash extends AbstractLocalImage
/**
* @var string|null
*/
private $content = null;
private $content;

/**
* @var TemplateHelper|null
Expand Down
4 changes: 2 additions & 2 deletions src/LocalImage/StringContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
* $image = new StringContent($content, $identifier, $context);
* ```
*
* @see \Rokka\Client\LocalImage\FileInfo
* @see FileInfo
* @since 1.3.0
*/
class StringContent extends AbstractLocalImage
{
/**
* @var string|null
*/
private $content = null;
private $content;

/**
* @param string|null $image
Expand Down
1 change: 1 addition & 0 deletions src/SearchHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public static function validateFieldName($fieldName)
if ('deletedDate' === $fieldName) {
return true;
}

// Field names must be shorter than 54 chars, and match the given format.
return 54 > \strlen($fieldName) && (1 === preg_match('/^(user:((str|array|date|latlon|int|double):)?)?[a-z0-9_]{1,54}$/', $fieldName)
|| 1 === preg_match('/^((dynamic|static):((str|array|date|latlon|int|double):))?[a-z0-9_]+:[a-z0-9_]{1,54}$/', $fieldName));
Expand Down
33 changes: 16 additions & 17 deletions src/TemplateHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class TemplateHelper
private $rokkaClientOptions;

/**
* @var \Rokka\Client\Image
* @var Image
*/
private $imageClient;

Expand All @@ -61,7 +61,7 @@ class TemplateHelper
public function __construct(
$organization,
$apiKey,
AbstractCallbacks $callbacks = null,
?AbstractCallbacks $callbacks = null,
$publicRokkaDomain = null,
$options = []
) {
Expand Down Expand Up @@ -136,11 +136,11 @@ public function getHashMaybeUpload(AbstractLocalImage $image)
* @return string
*/
public function getStackUrl(
$image,
$stack,
$format = 'jpg',
$seo = null,
$seoLanguage = 'de'
$image,
$stack,
$format = 'jpg',
$seo = null,
$seoLanguage = 'de'
) {
if (null == $image) {
return '';
Expand Down Expand Up @@ -327,7 +327,7 @@ public static function getBackgroundImageStyle($url, array $sizes = ['2x'])
*
* @return string
*/
public function getImagename(AbstractLocalImage $image = null)
public function getImagename(?AbstractLocalImage $image = null)
{
if (null === $image) {
return '';
Expand Down Expand Up @@ -357,11 +357,11 @@ public function getImagename(AbstractLocalImage $image = null)
* @return string
*/
public function generateRokkaUrl(
$hash,
$stack,
$format = 'jpg',
$seo = null,
$seoLanguage = 'de'
$hash,
$stack,
$format = 'jpg',
$seo = null,
$seoLanguage = 'de'
) {
if (null === $format) {
$format = 'jpg';
Expand All @@ -385,7 +385,7 @@ public function generateRokkaUrl(
*
* @throws \RuntimeException
*
* @return \Rokka\Client\Image
* @return Image
*/
public function getRokkaClient()
{
Expand Down Expand Up @@ -439,7 +439,6 @@ public static function slugify($text, $language = 'de')
*
* @param AbstractLocalImage|string|\SplFileInfo $input
* @param string|null $identifier
* @param mixed $context
*
* @throws \RuntimeException
*
Expand Down Expand Up @@ -470,7 +469,7 @@ public function getImageObject($input, $identifier = null, $context = null)

// we can't trust callers to only provide $input in one of the supported types
// @phpstan-ignore-next-line
$inputType = \is_object($input) ? \get_class($input) : \gettype($input);
$inputType = \is_object($input) ? $input::class : \gettype($input);

throw new \RuntimeException('Can not create a source image from input of type '.$inputType);
}
Expand Down Expand Up @@ -525,7 +524,7 @@ private function generateRokkaUrlWithImage(
$hash,
$stack,
$format = 'jpg',
AbstractLocalImage $image = null,
?AbstractLocalImage $image = null,
$seoLanguage = 'de'
) {
return $this->generateRokkaUrl($hash, $stack, $format, $this->getImagename($image), $seoLanguage);
Expand Down
12 changes: 6 additions & 6 deletions src/UriHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public static function addOptionsToUri(UriInterface $uri, $options, $shortNames
*
* @return UriInterface
*/
public static function composeUri($components, UriInterface $uri = null, $shortNames = true)
public static function composeUri($components, ?UriInterface $uri = null, $shortNames = true)
{
if (\is_array($components)) {
$components = UriComponents::createFromArray($components);
Expand Down Expand Up @@ -160,13 +160,13 @@ public static function decomposeUri(UriInterface $uri)
$pathPattern = '(?<hash>-.+-)';
$path = $uri->getPath();
// hash with seo-filename
if (preg_match('#^/'.$stackPattern.'/'.$hashPattern.'/'.$filenamePattern.'\.'.$formatPattern.'$#', $path, $matches) ||
if (preg_match('#^/'.$stackPattern.'/'.$hashPattern.'/'.$filenamePattern.'\.'.$formatPattern.'$#', $path, $matches)
// hash without seo-filename
preg_match('#^/'.$stackPattern.'/'.$hashPattern.'.'.$formatPattern.'$#', $path, $matches) ||
|| preg_match('#^/'.$stackPattern.'/'.$hashPattern.'.'.$formatPattern.'$#', $path, $matches)
// remote_path with seo-filename
preg_match('#^/'.$stackPattern.'/'.$pathPattern.'/'.$filenamePattern.'\.'.$formatPattern.'$#', $path, $matches) ||
|| preg_match('#^/'.$stackPattern.'/'.$pathPattern.'/'.$filenamePattern.'\.'.$formatPattern.'$#', $path, $matches)
// remote_path without seo-filename
preg_match('#^/'.$stackPattern.'/'.$pathPattern.'.'.$formatPattern.'$#', $path, $matches)) {
|| preg_match('#^/'.$stackPattern.'/'.$pathPattern.'.'.$formatPattern.'$#', $path, $matches)) {
$uriComponents = UriComponents::createFromArray($matches);

$inQuery = Query::parse($uri->getQuery());
Expand Down Expand Up @@ -269,7 +269,7 @@ public static function signUrl($url, $signKey, $until = null, $roundDateUpTo = 3
*
* @return array<string>
*/
private static function getUriStringFromStackConfig(array $config, $shortNames = true, UriInterface $uri = null)
private static function getUriStringFromStackConfig(array $config, $shortNames = true, ?UriInterface $uri = null)
{
$newOptions = [];

Expand Down
Loading

0 comments on commit bb86bc3

Please sign in to comment.