Skip to content

Commit

Permalink
IBX-8138: [Rector] Applied rules from Symfony 5 Rector set lists (#51)
Browse files Browse the repository at this point in the history
* [Rector] Applied all Symfony 5.x rectors to the production codebase

Applied rules:
 * AddReturnTypeDeclarationRector
 * RenameClassConstFetchRector
 * ResponseStatusCodeRector

* [Rector][Tests] Applied all Symfony 5.x rectors to the test codebase

Applied rules:
 * ResponseStatusCodeRector

* [Rector][Spec] Applied all Symfony 5.x rectors to the test codebase

Applied rules:
 * RenameClassConstFetchRector
  • Loading branch information
alongosz authored Aug 9, 2024
1 parent 5d0fafb commit 64f8418
Show file tree
Hide file tree
Showing 19 changed files with 71 additions and 63 deletions.
13 changes: 7 additions & 6 deletions spec/EventSubscriber/HiddenLocationExceptionSubscriberSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/

namespace spec\Ibexa\HttpCache\EventSubscriber;

use Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo;
use Ibexa\Contracts\Core\Repository\Values\Content\Location;
use Ibexa\Core\MVC\Exception\HiddenLocationException;
use Ibexa\HttpCache\ResponseTagger\Value\ContentInfoTagger;
use Ibexa\HttpCache\ResponseTagger\Value\LocationTagger;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Ibexa\Contracts\Core\Repository\Values\Content\Location;
use Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo;
use Ibexa\Core\MVC\Exception\HiddenLocationException;
use Prophecy\Argument;
use Symfony\Component\HttpKernel\HttpKernelInterface;

class HiddenLocationExceptionSubscriberSpec extends ObjectBehavior
Expand Down Expand Up @@ -43,7 +44,7 @@ public function it_tags_on_hidden_location_exception(
$event = new ExceptionEvent(
$kernel->getWrappedObject(),
$request->getWrappedObject(),
HttpKernelInterface::MASTER_REQUEST,
HttpKernelInterface::MAIN_REQUEST,
$exception->getWrappedObject()
);

Expand All @@ -64,7 +65,7 @@ public function it_does_not_tag_on_other_exceptions(
$event = new ExceptionEvent(
$kernel->getWrappedObject(),
$request->getWrappedObject(),
HttpKernelInterface::MASTER_REQUEST,
HttpKernelInterface::MAIN_REQUEST,
$exception->getWrappedObject()
);

Expand Down
11 changes: 6 additions & 5 deletions spec/EventSubscriber/HttpCacheResponseSubscriberSpec.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/

namespace spec\Ibexa\HttpCache\EventSubscriber;

use Ibexa\HttpCache\ResponseConfigurator\ResponseCacheConfigurator;
use Ibexa\Contracts\HttpCache\ResponseTagger\ResponseTagger;
use Ibexa\Core\MVC\Symfony\View\CachableView;
use Ibexa\Core\MVC\Symfony\View\View;
use Ibexa\HttpCache\ResponseConfigurator\ResponseCacheConfigurator;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface;

Expand Down Expand Up @@ -44,7 +45,7 @@ public function it_does_not_enable_cache_if_the_view_is_not_a_cachableview(
$event = new ResponseEvent(
$kernel->getWrappedObject(),
$request->getWrappedObject(),
HttpKernelInterface::MASTER_REQUEST,
HttpKernelInterface::MAIN_REQUEST,
$response->getWrappedObject()
);

Expand All @@ -67,7 +68,7 @@ public function it_does_not_enable_cache_if_it_is_disabled_in_the_view(
$event = new ResponseEvent(
$kernel->getWrappedObject(),
$request->getWrappedObject(),
HttpKernelInterface::MASTER_REQUEST,
HttpKernelInterface::MAIN_REQUEST,
$response->getWrappedObject()
);

Expand All @@ -91,7 +92,7 @@ public function it_enables_cache(
$event = new ResponseEvent(
$kernel->getWrappedObject(),
$request->getWrappedObject(),
HttpKernelInterface::MASTER_REQUEST,
HttpKernelInterface::MAIN_REQUEST,
$response->getWrappedObject()
);

Expand Down
46 changes: 23 additions & 23 deletions spec/EventSubscriber/RestKernelViewSubscriberSpec.php
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/

namespace spec\Ibexa\HttpCache\EventSubscriber;

use FOS\HttpCache\ResponseTagger;
use Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo;
use Ibexa\Contracts\Core\Repository\Values\Content\Section;
use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType;
use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeGroup;
use Ibexa\Core\Repository\Values\Content\VersionInfo;
use Ibexa\Rest\Server\Values\CachedValue;
use Ibexa\Rest\Server\Values\ContentTypeGroupList;
use Ibexa\Rest\Server\Values\ContentTypeGroupRefList;
use Ibexa\Rest\Server\Values\RestContentType;
use Ibexa\Rest\Server\Values\VersionList;
use FOS\HttpCache\ResponseTagger;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument\Token\AnyValueToken;
use Prophecy\Argument\Token\TypeToken;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\ParameterBag;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\HttpKernel\Event\ViewEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface;

Expand Down Expand Up @@ -50,7 +49,7 @@ public function it_does_nothing_on_uncachable_methods(
$event = new ViewEvent(
$kernel->getWrappedObject(),
$request->getWrappedObject(),
HttpKernelInterface::MASTER_REQUEST,
HttpKernelInterface::MAIN_REQUEST,
$response->getWrappedObject()
);

Expand All @@ -69,15 +68,15 @@ public function it_does_nothing_on_non_rest_requests(
$event = new ViewEvent(
$kernel->getWrappedObject(),
$request->getWrappedObject(),
HttpKernelInterface::MASTER_REQUEST,
HttpKernelInterface::MAIN_REQUEST,
$response->getWrappedObject()
);

$this->tagUIRestResult($event);
}

/**
* Section
* Section.
*/
public function it_writes_tags_on_section(
HttpKernelInterface $kernel,
Expand All @@ -96,15 +95,15 @@ public function it_writes_tags_on_section(
$event = new ViewEvent(
$kernel->getWrappedObject(),
$request->getWrappedObject(),
HttpKernelInterface::MASTER_REQUEST,
HttpKernelInterface::MAIN_REQUEST,
$restValue->getWrappedObject()
);

$this->tagUIRestResult($event);
}

/**
* ContentType
* ContentType.
*/
public function it_does_nothing_on_content_type_draft(
HttpKernelInterface $kernel,
Expand All @@ -124,7 +123,7 @@ public function it_does_nothing_on_content_type_draft(
$event = new ViewEvent(
$kernel->getWrappedObject(),
$request->getWrappedObject(),
HttpKernelInterface::MASTER_REQUEST,
HttpKernelInterface::MAIN_REQUEST,
$restValue->getWrappedObject()
);

Expand All @@ -148,15 +147,15 @@ public function it_writes_tags_on_content_type_defined(
$event = new ViewEvent(
$kernel->getWrappedObject(),
$request->getWrappedObject(),
HttpKernelInterface::MASTER_REQUEST,
HttpKernelInterface::MAIN_REQUEST,
$restValue->getWrappedObject()
);

$this->tagUIRestResult($event);
}

/**
* RestContentType
* RestContentType.
*/
public function it_does_nothing_on_rest_content_type_draft(
HttpKernelInterface $kernel,
Expand All @@ -177,7 +176,7 @@ public function it_does_nothing_on_rest_content_type_draft(
$event = new ViewEvent(
$kernel->getWrappedObject(),
$request->getWrappedObject(),
HttpKernelInterface::MASTER_REQUEST,
HttpKernelInterface::MAIN_REQUEST,
$restValue->getWrappedObject()
);

Expand All @@ -186,7 +185,8 @@ public function it_does_nothing_on_rest_content_type_draft(

public function it_writes_tags_on_rest_content_type_defined(
HttpKernelInterface $kernel,
Request $request, ParameterBag $attributes,
Request $request,
ParameterBag $attributes,
RestContentType $restValue,
ContentType $contentType,
ResponseTagger $tagHandler
Expand All @@ -202,15 +202,15 @@ public function it_writes_tags_on_rest_content_type_defined(
$event = new ViewEvent(
$kernel->getWrappedObject(),
$request->getWrappedObject(),
HttpKernelInterface::MASTER_REQUEST,
HttpKernelInterface::MAIN_REQUEST,
$restValue->getWrappedObject()
);

$this->tagUIRestResult($event);
}

/**
* ContentTypeGroupRefList
* ContentTypeGroupRefList.
*/
public function it_does_nothing_on_rest_content_type_group_ref_draft(
HttpKernelInterface $kernel,
Expand All @@ -233,7 +233,7 @@ public function it_does_nothing_on_rest_content_type_group_ref_draft(
$event = new ViewEvent(
$kernel->getWrappedObject(),
$request->getWrappedObject(),
HttpKernelInterface::MASTER_REQUEST,
HttpKernelInterface::MAIN_REQUEST,
$restValue->getWrappedObject()
);

Expand Down Expand Up @@ -263,15 +263,15 @@ public function it_writes_tags_on_rest_content_type_group_ref_defined(
$event = new ViewEvent(
$kernel->getWrappedObject(),
$request->getWrappedObject(),
HttpKernelInterface::MASTER_REQUEST,
HttpKernelInterface::MAIN_REQUEST,
$restValue->getWrappedObject()
);

$this->tagUIRestResult($event);
}

/**
* ContentTypeGroupList
* ContentTypeGroupList.
*/
public function it_writes_tags_on_rest_content_type_group_list(
HttpKernelInterface $kernel,
Expand All @@ -292,15 +292,15 @@ public function it_writes_tags_on_rest_content_type_group_list(
$event = new ViewEvent(
$kernel->getWrappedObject(),
$request->getWrappedObject(),
HttpKernelInterface::MASTER_REQUEST,
HttpKernelInterface::MAIN_REQUEST,
$restValue->getWrappedObject()
);

$this->tagUIRestResult($event);
}

/**
* VersionList
* VersionList.
*/
public function it_writes_tags_on_rest_version_list(
HttpKernelInterface $kernel,
Expand All @@ -323,7 +323,7 @@ public function it_writes_tags_on_rest_version_list(
$event = new ViewEvent(
$kernel->getWrappedObject(),
$request->getWrappedObject(),
HttpKernelInterface::MASTER_REQUEST,
HttpKernelInterface::MAIN_REQUEST,
$restValue->getWrappedObject()
);

Expand Down
18 changes: 11 additions & 7 deletions spec/EventSubscriber/UserContextSubscriberSpec.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/

namespace spec\Ibexa\HttpCache\EventSubscriber;

use Ibexa\HttpCache\EventSubscriber\UserContextSubscriber;
Expand All @@ -11,7 +16,6 @@
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\HttpKernel\Event\ViewEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface;

class UserContextSubscriberSpec extends ObjectBehavior
Expand All @@ -26,7 +30,7 @@ public function let(
$this->beConstructedWith($prefixService, 'xkey');
}

function it_is_initializable()
public function it_is_initializable()
{
$this->shouldHaveType(UserContextSubscriber::class);
}
Expand All @@ -46,7 +50,7 @@ public function it_does_nothing_on_uncachable_methods(
$event = new ResponseEvent(
$kernel->getWrappedObject(),
$request->getWrappedObject(),
HttpKernelInterface::MASTER_REQUEST,
HttpKernelInterface::MAIN_REQUEST,
$response->getWrappedObject()
);

Expand All @@ -68,7 +72,7 @@ public function it_does_nothing_on_wrong_content_type(
$event = new ResponseEvent(
$kernel->getWrappedObject(),
$request->getWrappedObject(),
HttpKernelInterface::MASTER_REQUEST,
HttpKernelInterface::MAIN_REQUEST,
$response->getWrappedObject()
);

Expand All @@ -90,7 +94,7 @@ public function it_does_nothing_on_empty_ttl(
$event = new ResponseEvent(
$kernel->getWrappedObject(),
$request->getWrappedObject(),
HttpKernelInterface::MASTER_REQUEST,
HttpKernelInterface::MAIN_REQUEST,
$response->getWrappedObject()
);

Expand All @@ -114,7 +118,7 @@ public function it_tags_response_with_no_prefix(
$event = new ResponseEvent(
$kernel->getWrappedObject(),
$request->getWrappedObject(),
HttpKernelInterface::MASTER_REQUEST,
HttpKernelInterface::MAIN_REQUEST,
$response->getWrappedObject()
);

Expand All @@ -138,7 +142,7 @@ public function it_tags_response_with_a_prefix(
$event = new ResponseEvent(
$kernel->getWrappedObject(),
$request->getWrappedObject(),
HttpKernelInterface::MASTER_REQUEST,
HttpKernelInterface::MAIN_REQUEST,
$response->getWrappedObject()
);

Expand Down
Loading

0 comments on commit 64f8418

Please sign in to comment.