Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: apply rector rules for PHP 8.3 with typeDeclarations #2407

Open
wants to merge 2 commits into
base: 3.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Controller/AbstractFOSRestController.php
Expand Up @@ -45,7 +45,7 @@ abstract class BaseAbstractFOSRestController extends AbstractController
/**
* @return array
*/
public static function getSubscribedServices()
public static function getSubscribedServices(): array
{
$subscribedServices = parent::getSubscribedServices();
$subscribedServices['fos_rest.view_handler'] = ViewHandlerInterface::class;
Expand Down
2 changes: 1 addition & 1 deletion Controller/Annotations/AbstractParam.php
Expand Up @@ -68,7 +68,7 @@ public function getIncompatibilities()
}

/** {@inheritdoc} */
public function getConstraints()
public function getConstraints(): array
{
$constraints = [];
if (!$this->nullable) {
Expand Down
2 changes: 1 addition & 1 deletion Controller/Annotations/Copy.php
Expand Up @@ -23,7 +23,7 @@
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_METHOD)]
class Copy extends Route
{
public function getMethod()
public function getMethod(): string
{
return 'COPY';
}
Expand Down
2 changes: 1 addition & 1 deletion Controller/Annotations/Delete.php
Expand Up @@ -21,7 +21,7 @@
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_METHOD)]
class Delete extends Route
{
public function getMethod()
public function getMethod(): string
{
return 'DELETE';
}
Expand Down
2 changes: 1 addition & 1 deletion Controller/Annotations/Get.php
Expand Up @@ -21,7 +21,7 @@
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_METHOD)]
class Get extends Route
{
public function getMethod()
public function getMethod(): string
{
return 'GET';
}
Expand Down
2 changes: 1 addition & 1 deletion Controller/Annotations/Head.php
Expand Up @@ -21,7 +21,7 @@
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_METHOD)]
class Head extends Route
{
public function getMethod()
public function getMethod(): string
{
return 'HEAD';
}
Expand Down
2 changes: 1 addition & 1 deletion Controller/Annotations/Link.php
Expand Up @@ -21,7 +21,7 @@
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_METHOD)]
class Link extends Route
{
public function getMethod()
public function getMethod(): string
{
return 'LINK';
}
Expand Down
2 changes: 1 addition & 1 deletion Controller/Annotations/Lock.php
Expand Up @@ -23,7 +23,7 @@
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_METHOD)]
class Lock extends Route
{
public function getMethod()
public function getMethod(): string
{
return 'LOCK';
}
Expand Down
2 changes: 1 addition & 1 deletion Controller/Annotations/Mkcol.php
Expand Up @@ -23,7 +23,7 @@
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_METHOD)]
class Mkcol extends Route
{
public function getMethod()
public function getMethod(): string
{
return 'MKCOL';
}
Expand Down
2 changes: 1 addition & 1 deletion Controller/Annotations/Move.php
Expand Up @@ -23,7 +23,7 @@
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_METHOD)]
class Move extends Route
{
public function getMethod()
public function getMethod(): string
{
return 'MOVE';
}
Expand Down
2 changes: 1 addition & 1 deletion Controller/Annotations/Options.php
Expand Up @@ -21,7 +21,7 @@
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_METHOD)]
class Options extends Route
{
public function getMethod()
public function getMethod(): string
{
return 'OPTIONS';
}
Expand Down
2 changes: 1 addition & 1 deletion Controller/Annotations/Patch.php
Expand Up @@ -21,7 +21,7 @@
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_METHOD)]
class Patch extends Route
{
public function getMethod()
public function getMethod(): string
{
return 'PATCH';
}
Expand Down
2 changes: 1 addition & 1 deletion Controller/Annotations/Post.php
Expand Up @@ -21,7 +21,7 @@
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_METHOD)]
class Post extends Route
{
public function getMethod()
public function getMethod(): string
{
return 'POST';
}
Expand Down
2 changes: 1 addition & 1 deletion Controller/Annotations/PropFind.php
Expand Up @@ -23,7 +23,7 @@
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_METHOD)]
class PropFind extends Route
{
public function getMethod()
public function getMethod(): string
{
return 'PROPFIND';
}
Expand Down
2 changes: 1 addition & 1 deletion Controller/Annotations/PropPatch.php
Expand Up @@ -23,7 +23,7 @@
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_METHOD)]
class PropPatch extends Route
{
public function getMethod()
public function getMethod(): string
{
return 'PROPPATCH';
}
Expand Down
2 changes: 1 addition & 1 deletion Controller/Annotations/Put.php
Expand Up @@ -21,7 +21,7 @@
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_METHOD)]
class Put extends Route
{
public function getMethod()
public function getMethod(): string
{
return 'PUT';
}
Expand Down
4 changes: 2 additions & 2 deletions Controller/Annotations/Route.php
Expand Up @@ -24,7 +24,7 @@
class Route extends BaseRoute
{
public function __construct(
$data = [],
string|array|null $data = [],
$path = null,
string $name = null,
array $requirements = [],
Expand Down Expand Up @@ -123,7 +123,7 @@ public function __construct(
/**
* @return string|null
*/
public function getMethod()
public function getMethod(): void
{
return;
}
Expand Down
2 changes: 1 addition & 1 deletion Controller/Annotations/Unlink.php
Expand Up @@ -21,7 +21,7 @@
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_METHOD)]
class Unlink extends Route
{
public function getMethod()
public function getMethod(): string
{
return 'UNLINK';
}
Expand Down
2 changes: 1 addition & 1 deletion Controller/Annotations/Unlock.php
Expand Up @@ -23,7 +23,7 @@
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_METHOD)]
class Unlock extends Route
{
public function getMethod()
public function getMethod(): string
{
return 'UNLOCK';
}
Expand Down
6 changes: 3 additions & 3 deletions Controller/Annotations/View.php
Expand Up @@ -60,7 +60,7 @@ public function __construct(
/**
* @param int $statusCode
*/
public function setStatusCode($statusCode)
public function setStatusCode($statusCode): void
{
$this->statusCode = $statusCode;
}
Expand All @@ -76,7 +76,7 @@ public function getStatusCode()
/**
* @param array $serializerGroups
*/
public function setSerializerGroups($serializerGroups)
public function setSerializerGroups($serializerGroups): void
{
$this->serializerGroups = $serializerGroups;
}
Expand All @@ -92,7 +92,7 @@ public function getSerializerGroups()
/**
* @param bool $serializerEnableMaxDepthChecks
*/
public function setSerializerEnableMaxDepthChecks($serializerEnableMaxDepthChecks)
public function setSerializerEnableMaxDepthChecks($serializerEnableMaxDepthChecks): void
{
$this->serializerEnableMaxDepthChecks = $serializerEnableMaxDepthChecks;
}
Expand Down
8 changes: 4 additions & 4 deletions Controller/ControllerTrait.php
Expand Up @@ -25,7 +25,7 @@ trait ControllerTrait
{
private $viewhandler;

public function setViewHandler(ViewHandlerInterface $viewhandler)
public function setViewHandler(ViewHandlerInterface $viewhandler): void
{
$this->viewhandler = $viewhandler;
}
Expand All @@ -42,23 +42,23 @@ protected function getViewHandler()
/**
* @return View
*/
protected function view($data = null, ?int $statusCode = null, array $headers = [])
protected function view($data = null, ?int $statusCode = null, array $headers = []): \FOS\RestBundle\View\View
{
return View::create($data, $statusCode, $headers);
}

/**
* @return View
*/
protected function redirectView(string $url, int $statusCode = Response::HTTP_FOUND, array $headers = [])
protected function redirectView(string $url, int $statusCode = Response::HTTP_FOUND, array $headers = []): \FOS\RestBundle\View\View
{
return View::createRedirect($url, $statusCode, $headers);
}

/**
* @return View
*/
protected function routeRedirectView(string $route, array $parameters = [], int $statusCode = Response::HTTP_CREATED, array $headers = [])
protected function routeRedirectView(string $route, array $parameters = [], int $statusCode = Response::HTTP_CREATED, array $headers = []): \FOS\RestBundle\View\View
{
return View::createRouteRedirect($route, $parameters, $statusCode, $headers);
}
Expand Down
22 changes: 11 additions & 11 deletions DependencyInjection/Configuration.php
Expand Up @@ -51,7 +51,7 @@ public function getConfigTreeBuilder(): TreeBuilder
->arrayNode('param_fetcher_listener')
->beforeNormalization()
->ifString()
->then(function ($v) {
->then(function ($v): array {
return ['enabled' => in_array($v, ['force', 'true']), 'force' => 'force' === $v];
})
->end()
Expand Down Expand Up @@ -130,7 +130,7 @@ public function getConfigTreeBuilder(): TreeBuilder
->prototype('scalar')->end()
->end()
->arrayNode('ips')
->beforeNormalization()->ifString()->then(function ($v) {
->beforeNormalization()->ifString()->then(function ($v): array {
return [$v];
})->end()
->prototype('scalar')->end()
Expand Down Expand Up @@ -178,7 +178,7 @@ private function addViewSection(ArrayNodeDefinition $rootNode): void
->prototype('array')
->beforeNormalization()
->ifString()
->then(function ($v) { return [$v]; })
->then(function ($v): array { return [$v]; })
->end()
->prototype('scalar')->end()
->end()
Expand All @@ -193,7 +193,7 @@ private function addViewSection(ArrayNodeDefinition $rootNode): void
->arrayNode('view_response_listener')
->beforeNormalization()
->ifString()
->then(function ($v) {
->then(function ($v): array {
return ['enabled' => in_array($v, ['force', 'true']), 'force' => 'force' === $v];
})
->end()
Expand Down Expand Up @@ -245,7 +245,7 @@ private function addBodyListenerSection(ArrayNodeDefinition $rootNode): void
->arrayNode('array_normalizer')
->addDefaultsIfNotSet()
->beforeNormalization()
->ifString()->then(function ($v) {
->ifString()->then(function ($v): array {
return ['service' => $v];
})
->end()
Expand All @@ -268,13 +268,13 @@ private function addFormatListenerSection(ArrayNodeDefinition $rootNode): void
->addDefaultsIfNotSet()
->canBeUnset()
->beforeNormalization()
->ifTrue(function ($v) {
->ifTrue(function ($v): bool {
// check if we got an assoc array in rules
return isset($v['rules'])
&& is_array($v['rules'])
&& array_keys($v['rules']) !== range(0, count($v['rules']) - 1);
})
->then(function ($v) {
->then(function (array $v): array {
$v['rules'] = [$v['rules']];

return $v;
Expand Down Expand Up @@ -374,7 +374,7 @@ private function addExceptionSection(ArrayNodeDefinition $rootNode): void
->canBeEnabled()
->validate()
->always()
->then(function ($v) {
->then(function (array $v): array {
if (!$v['enabled']) {
return $v;
}
Expand Down Expand Up @@ -417,7 +417,7 @@ private function addExceptionSection(ArrayNodeDefinition $rootNode): void
->useAttributeAsKey('name')
->beforeNormalization()
->ifArray()
->then(function (array $items) {
->then(function (array $items): array {
foreach ($items as &$item) {
if (is_int($item)) {
continue;
Expand All @@ -437,7 +437,7 @@ private function addExceptionSection(ArrayNodeDefinition $rootNode): void

->validate()
->ifArray()
->then(function (array $items) {
->then(function (array $items): array {
foreach ($items as $class => $code) {
$this->testExceptionExists($class);
}
Expand All @@ -451,7 +451,7 @@ private function addExceptionSection(ArrayNodeDefinition $rootNode): void
->prototype('boolean')->end()
->validate()
->ifArray()
->then(function (array $items) {
->then(function (array $items): array {
foreach ($items as $class => $nomatter) {
$this->testExceptionExists($class);
}
Expand Down
2 changes: 1 addition & 1 deletion ErrorRenderer/SerializerErrorRenderer.php
Expand Up @@ -77,7 +77,7 @@ public function render(\Throwable $exception): FlattenException
*/
public static function getPreferredFormat(RequestStack $requestStack): \Closure
{
return static function () use ($requestStack) {
return static function () use ($requestStack): ?string {
if (!$request = $requestStack->getCurrentRequest()) {
throw class_exists(NotEncodableValueException::class) ? new NotEncodableValueException() : new UnsupportedFormatException();
}
Expand Down
2 changes: 1 addition & 1 deletion EventListener/ParamFetcherListener.php
Expand Up @@ -70,7 +70,7 @@ public function onKernelController(ControllerEvent $event): void

private function getAttributeName(callable $controller): string
{
list($object, $name) = $controller;
[$object, $name] = $controller;
$method = new \ReflectionMethod($object, $name);
foreach ($method->getParameters() as $param) {
if ($this->isParamFetcherType($param)) {
Expand Down
2 changes: 1 addition & 1 deletion EventListener/ZoneMatcherListener.php
Expand Up @@ -26,7 +26,7 @@ class ZoneMatcherListener
{
private $requestMatchers = [];

public function addRequestMatcher(RequestMatcherInterface $requestMatcher)
public function addRequestMatcher(RequestMatcherInterface $requestMatcher): void
{
$this->requestMatchers[] = $requestMatcher;
}
Expand Down
2 changes: 1 addition & 1 deletion Exception/InvalidParameterException.php
Expand Up @@ -30,7 +30,7 @@ public function getViolations()
return $this->violations;
}

public static function withViolations(ParamInterface $parameter, ConstraintViolationListInterface $violations)
public static function withViolations(ParamInterface $parameter, ConstraintViolationListInterface $violations): \FOS\RestBundle\Exception\InvalidParameterException
{
$message = '';

Expand Down
2 changes: 1 addition & 1 deletion FOSRestBundle.php
Expand Up @@ -27,7 +27,7 @@
*/
class FOSRestBundle extends Bundle
{
const ZONE_ATTRIBUTE = '_fos_rest_zone';
public const ZONE_ATTRIBUTE = '_fos_rest_zone';

/**
* {@inheritdoc}
Expand Down
2 changes: 1 addition & 1 deletion Negotiation/FormatNegotiator.php
Expand Up @@ -104,7 +104,7 @@ public function getBest($header, array $priorities = [], $strict = false): ?Acce

private function sanitize(array $values): array
{
return array_map(function ($value) {
return array_map(function ($value): ?string {
return preg_replace('/\s+/', '', strtolower($value));
}, $values);
}
Expand Down