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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
936 changes: 12 additions & 924 deletions phpstan-baseline.neon

Large diffs are not rendered by default.

8 changes: 0 additions & 8 deletions src/bundle/ApiLoader/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ class Factory

protected Repository $repository;

/**
* @param \Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface $configResolver
* @param \Ibexa\Contracts\Core\Repository\Repository $repository
*/
public function __construct(ConfigResolverInterface $configResolver, Repository $repository)
{
$this->configResolver = $configResolver;
Expand All @@ -49,10 +45,6 @@ public function getMediaFieldTypeProcessor(): MediaProcessor

/**
* Factory for ezpublish_rest.field_type_processor.ibexa_image.
*
* @param \Symfony\Component\Routing\RouterInterface $router
*
* @return \Ibexa\Rest\FieldTypeProcessor\ImageProcessor
*/
public function getImageFieldTypeProcessor(RouterInterface $router): ImageProcessor
{
Expand Down
4 changes: 2 additions & 2 deletions src/bundle/ApiPlatform/Head.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ public function __construct(
?bool $forceEager = null,
?int $priority = null,
?string $name = null,
$provider = null,
$processor = null,
callable|string|null $provider = null,
callable|string|null $processor = null,
?OptionsInterface $stateOptions = null,
array|Parameters|null $parameters = null,
array $extraProperties = [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class FieldTypeProcessorPass implements CompilerPassInterface
{
private const FIELD_TYPE_PROCESSOR_SERVICE_TAG = 'ibexa.rest.field_type.processor';
private const string FIELD_TYPE_PROCESSOR_SERVICE_TAG = 'ibexa.rest.field_type.processor';

public function process(ContainerBuilder $container): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
class InputParserPass implements CompilerPassInterface
{
public const INPUT_PARSER_SERVICE_TAG = 'ibexa.rest.input.parser';
public const string INPUT_PARSER_SERVICE_TAG = 'ibexa.rest.input.parser';

public function process(ContainerBuilder $container): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/
class OutputVisitorPass implements CompilerPassInterface
{
public const OUTPUT_VISITOR_SERVICE_TAG = 'ibexa.rest.output.visitor';
public const string OUTPUT_VISITOR_SERVICE_TAG = 'ibexa.rest.output.visitor';

public function process(ContainerBuilder $container): void
{
Expand Down
2 changes: 1 addition & 1 deletion src/bundle/DependencyInjection/IbexaRestExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*/
class IbexaRestExtension extends ConfigurableExtension implements PrependExtensionInterface
{
public const EXTENSION_NAME = 'ibexa_rest';
public const string EXTENSION_NAME = 'ibexa_rest';

public function getAlias(): string
{
Expand Down
2 changes: 1 addition & 1 deletion src/bundle/RestEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ final class RestEvents
/**
* The REST_CSRF_TOKEN_VALIDATED event occurs after CSRF token has been validated as correct.
*/
public const REST_CSRF_TOKEN_VALIDATED = 'ezpublish.rest.csrf_token_validated';
public const string REST_CSRF_TOKEN_VALIDATED = 'ezpublish.rest.csrf_token_validated';
}
7 changes: 1 addition & 6 deletions src/bundle/Routing/OptionsLoader/Mapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,8 @@ public function mapRoute(Route $route): Route

/**
* Merges the methods from $restRoute into the _method default of $optionsRoute.
*
* @param \Symfony\Component\Routing\Route $restRoute
* @param \Symfony\Component\Routing\Route $optionsRoute
*
* @return \Symfony\Component\Routing\Route $optionsRoute with the methods from $restRoute in the _methods default
*/
public function mergeMethodsDefault(Route $optionsRoute, Route $restRoute)
public function mergeMethodsDefault(Route $optionsRoute, Route $restRoute): Route
{
$mergedRoute = clone $optionsRoute;
$mergedRoute->setDefault(
Expand Down
4 changes: 0 additions & 4 deletions src/bundle/Routing/OptionsLoader/RouteCollectionMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ public function __construct(Mapper $mapper)

/**
* Iterates over $restRouteCollection, and returns the corresponding RouteCollection of OPTIONS REST routes.
*
* @param \Symfony\Component\Routing\RouteCollection $restRouteCollection
*
* @return \Symfony\Component\Routing\RouteCollection
*/
public function mapCollection(RouteCollection $restRouteCollection): RouteCollection
{
Expand Down
2 changes: 1 addition & 1 deletion src/bundle/UriParser/UriParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ final class UriParser implements UriParserInterface
* @see \Ibexa\Contracts\Rest\UriParser\UriParserInterface::isRestRequest()
* @see \Ibexa\Contracts\Rest\UriParser\UriParserInterface::hasRestPrefix()
*/
public const DEFAULT_REST_PREFIX_PATTERN = '/^\/api\/[a-zA-Z0-9-_]+\/v\d+(\.\d+)?\//';
public const string DEFAULT_REST_PREFIX_PATTERN = '/^\/api\/[a-zA-Z0-9-_]+\/v\d+(\.\d+)?\//';

private UrlMatcherInterface $urlMatcher;

Expand Down
9 changes: 4 additions & 5 deletions src/contracts/Event/BeforeParseEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ final class BeforeParseEvent extends BeforeEvent

private string $mediaType;

/** @var mixed|null */
private $valueObject = null;
private mixed $valueObject = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: Is it really mixed, not object?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


public function __construct(
array $data,
string $mediaType
string $mediaType,
) {
$this->data = $data;
$this->mediaType = $mediaType;
Expand All @@ -48,7 +47,7 @@ public function setMediaType(string $mediaType): void
$this->mediaType = $mediaType;
}

public function getValueObject()
public function getValueObject(): mixed
{
if (!$this->hasValueObject()) {
throw new UnexpectedValueException('Return value is not set. Check hasValueObject() or set it using setValueObject() before you call the getter.');
Expand All @@ -57,7 +56,7 @@ public function getValueObject()
return $this->valueObject;
}

public function setValueObject($valueObject): void
public function setValueObject(mixed $valueObject): void
{
$this->valueObject = $valueObject;
}
Expand Down
7 changes: 3 additions & 4 deletions src/contracts/Event/ParseEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@

final class ParseEvent extends AfterEvent
{
/** @var mixed */
private $valueObject;
private mixed $valueObject;

private array $data;

private string $mediaType;

public function __construct(
$valueObject,
mixed $valueObject,
array $data,
string $mediaType
) {
Expand All @@ -39,7 +38,7 @@ public function getMediaType(): string
return $this->mediaType;
}

public function getValueObject()
public function getValueObject(): mixed
{
return $this->valueObject;
}
Expand Down
28 changes: 8 additions & 20 deletions src/contracts/FieldTypeProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ abstract class FieldTypeProcessor
*
* @see \Ibexa\Rest\Input\FieldTypeParser
*
* @param mixed $incomingValueHash
*
* @return mixed Pre processed hash
*/
public function preProcessValueHash($incomingValueHash)
public function preProcessValueHash(mixed $incomingValueHash): mixed
{
return $incomingValueHash;
}
Expand All @@ -45,11 +43,9 @@ public function preProcessValueHash($incomingValueHash)
*
* @see \Ibexa\Rest\Output\FieldTypeSerializer
*
* @param mixed $outgoingValueHash
*
* @return mixed Post processed hash
*/
public function postProcessValueHash($outgoingValueHash)
public function postProcessValueHash(mixed $outgoingValueHash): mixed
{
return $outgoingValueHash;
}
Expand All @@ -66,11 +62,9 @@ public function postProcessValueHash($outgoingValueHash)
*
* @see \Ibexa\Rest\Input\FieldTypeParser
*
* @param mixed $incomingSettingsHash
*
* @return mixed Pre processed hash
* @return mixed Preprocessed hash
*/
public function preProcessFieldSettingsHash($incomingSettingsHash)
public function preProcessFieldSettingsHash(mixed $incomingSettingsHash): mixed
{
return $incomingSettingsHash;
}
Expand All @@ -87,11 +81,9 @@ public function preProcessFieldSettingsHash($incomingSettingsHash)
*
* @see \Ibexa\Rest\Output\FieldTypeSerializer
*
* @param mixed $outgoingSettingsHash
*
* @return mixed Post processed hash
*/
public function postProcessFieldSettingsHash($outgoingSettingsHash)
public function postProcessFieldSettingsHash(mixed $outgoingSettingsHash): mixed
{
return $outgoingSettingsHash;
}
Expand All @@ -108,11 +100,9 @@ public function postProcessFieldSettingsHash($outgoingSettingsHash)
*
* @see \Ibexa\Rest\Input\FieldTypeParser
*
* @param mixed $incomingValidatorConfigurationHash
*
* @return mixed Pre processed hash
* @return mixed Preprocessed hash
*/
public function preProcessValidatorConfigurationHash($incomingValidatorConfigurationHash)
public function preProcessValidatorConfigurationHash(mixed $incomingValidatorConfigurationHash): mixed
{
return $incomingValidatorConfigurationHash;
}
Expand All @@ -129,11 +119,9 @@ public function preProcessValidatorConfigurationHash($incomingValidatorConfigura
*
* @see \Ibexa\Rest\Output\FieldTypeSerializer
*
* @param mixed $outgoingValidatorConfigurationHash
*
* @return mixed Post processed hash
*/
public function postProcessValidatorConfigurationHash($outgoingValidatorConfigurationHash)
public function postProcessValidatorConfigurationHash(mixed $outgoingValidatorConfigurationHash): mixed
{
return $outgoingValidatorConfigurationHash;
}
Expand Down
6 changes: 1 addition & 5 deletions src/contracts/Input/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ abstract class Handler
{
/**
* Converts the given string to an array structure.
*
* @param string $string
*
* @return array
*/
abstract public function convert($string);
abstract public function convert(string $string): array|string|int|bool|float|null;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
*/
abstract class BaseCriterionProcessor implements CriterionProcessorInterface
{
private const CRITERION_SUFFIX = 'Criterion';
private const LOGICAL_OPERATOR_CRITERION_MAP = [
private const string CRITERION_SUFFIX = 'Criterion';
private const array LOGICAL_OPERATOR_CRITERION_MAP = [
'AND' => 'LogicalAnd',
'OR' => 'LogicalOr',
'NOT' => 'LogicalNot',
Expand Down
5 changes: 1 addition & 4 deletions src/contracts/Input/ParsingDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ public function __construct(EventDispatcherInterface $eventDispatcher, array $pa

/**
* Adds another parser for the given content type.
*
* @param string $mediaType
* @param \Ibexa\Contracts\Rest\Input\Parser $parser
*/
public function addParser(string $mediaType, Parser $parser): void
{
Expand Down Expand Up @@ -96,7 +93,7 @@ public function parse(array $data, string $mediaType)
/**
* Parses the given $data according to $mediaType.
*/
protected function internalParse(array $data, string $mediaType)
protected function internalParse(array $data, string $mediaType): mixed
{
list($mediaType, $version) = $this->parseMediaTypeVersion($mediaType);

Expand Down
17 changes: 7 additions & 10 deletions src/contracts/Output/Exceptions/AbstractExceptionVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace Ibexa\Contracts\Rest\Output\Exceptions;

use Exception;
use Ibexa\Contracts\Rest\Output\Generator;
use Ibexa\Contracts\Rest\Output\ValueObjectVisitor;
use Ibexa\Contracts\Rest\Output\Visitor;
Expand All @@ -22,7 +23,7 @@ abstract class AbstractExceptionVisitor extends ValueObjectVisitor
*
* @var array<int, string>
*/
protected static $httpStatusCodes = [
protected static array $httpStatusCodes = [
400 => 'Bad Request',
401 => 'Unauthorized',
402 => 'Payment Required',
Expand Down Expand Up @@ -62,20 +63,16 @@ abstract class AbstractExceptionVisitor extends ValueObjectVisitor

/**
* Returns HTTP status code.
*
* @return int
*/
protected function getStatus()
protected function getStatus(): int
{
return 500;
}

/**
* @param \Exception $data
*
* @return void
*/
public function visit(Visitor $visitor, Generator $generator, $data): void
public function visit(Visitor $visitor, Generator $generator, mixed $data): void
{
$generator->startObjectElement('ErrorMessage');

Expand Down Expand Up @@ -105,7 +102,7 @@ public function visit(Visitor $visitor, Generator $generator, $data): void
$generator->endObjectElement('ErrorMessage');
}

protected function generateErrorCode(Generator $generator, Visitor $visitor, \Exception $e): int
protected function generateErrorCode(Generator $generator, Visitor $visitor, Exception $e): int
{
$statusCode = $this->getStatus();
$visitor->setStatus($statusCode);
Expand All @@ -115,12 +112,12 @@ protected function generateErrorCode(Generator $generator, Visitor $visitor, \Ex
return $statusCode;
}

protected function getErrorMessage(\Exception $data, int $statusCode): string
protected function getErrorMessage(Exception $data, int $statusCode): string
{
return static::$httpStatusCodes[$statusCode] ?? static::$httpStatusCodes[500];
}

protected function getErrorDescription(\Exception $data, int $statusCode): string
protected function getErrorDescription(Exception $data, int $statusCode): string
{
$translator = $this->getTranslator();
if ($statusCode < 500 || $this->canDisplayExceptionMessage()) {
Expand Down
4 changes: 1 addition & 3 deletions src/contracts/Output/Exceptions/InvalidTypeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ class InvalidTypeException extends RuntimeException
{
/**
* Construct from invalid data.
*
* @param mixed $data
*/
public function __construct($data)
public function __construct(mixed $data)
{
parent::__construct(
'You must provide a ValueObject for visiting, "' . gettype($data) . '" provided.'
Expand Down
2 changes: 0 additions & 2 deletions src/contracts/Output/Exceptions/NoVisitorFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ class NoVisitorFoundException extends RuntimeException
{
/**
* Construct from tested classes.
*
* @param array $classes
*/
public function __construct(array $classes)
{
Expand Down
6 changes: 2 additions & 4 deletions src/contracts/Output/Exceptions/OutputGeneratorException.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@
class OutputGeneratorException extends RuntimeException
{
/**
* Construct from error message.
*
* @param string $message
* Construct from an error message.
*/
public function __construct($message)
public function __construct(string $message)
{
parent::__construct(
'Output visiting failed: ' . $message
Expand Down
Loading
Loading