Skip to content
This repository has been archived by the owner on Feb 24, 2023. It is now read-only.

Commit

Permalink
fix style with fabbot.io
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoann-TYT committed Feb 14, 2021
1 parent 6b59fc7 commit 4dff28f
Show file tree
Hide file tree
Showing 17 changed files with 33 additions and 27 deletions.
3 changes: 2 additions & 1 deletion src/Configuration/Cache.php
Expand Up @@ -11,13 +11,14 @@

namespace Sensio\Bundle\FrameworkExtraBundle\Configuration;

use Attribute;
/**
* The Cache class handles the Cache annotation parts.
*
* @author Fabien Potencier <fabien@symfony.com>
* @Annotation
*/
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD)]
#[Attribute(\Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD)]
class Cache extends ConfigurationAnnotation
{
/**
Expand Down
3 changes: 2 additions & 1 deletion src/Configuration/Entity.php
Expand Up @@ -11,13 +11,14 @@

namespace Sensio\Bundle\FrameworkExtraBundle\Configuration;

use Attribute;
/**
* Doctrine-specific ParamConverter with an easier syntax.
*
* @author Ryan Weaver <ryan@knpuniversity.com>
* @Annotation
*/
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD)]
#[Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD)]
class Entity extends ParamConverter
{
public function setExpr($expr)
Expand Down
3 changes: 2 additions & 1 deletion src/Configuration/IsGranted.php
Expand Up @@ -11,13 +11,14 @@

namespace Sensio\Bundle\FrameworkExtraBundle\Configuration;

use Attribute;
/**
* The Security class handles the Security annotation.
*
* @author Ryan Weaver <ryan@knpuniversity.com>
* @Annotation
*/
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD)]
#[Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD)]
class IsGranted extends ConfigurationAnnotation
{
/**
Expand Down
3 changes: 2 additions & 1 deletion src/Configuration/ParamConverter.php
Expand Up @@ -11,13 +11,14 @@

namespace Sensio\Bundle\FrameworkExtraBundle\Configuration;

use Attribute;
/**
* The ParamConverter class handles the ParamConverter annotation parts.
*
* @author Fabien Potencier <fabien@symfony.com>
* @Annotation
*/
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD)]
#[Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD)]
class ParamConverter extends ConfigurationAnnotation
{
/**
Expand Down
3 changes: 2 additions & 1 deletion src/Configuration/Security.php
Expand Up @@ -11,13 +11,14 @@

namespace Sensio\Bundle\FrameworkExtraBundle\Configuration;

use Attribute;
/**
* The Security class handles the Security annotation.
*
* @author Fabien Potencier <fabien@symfony.com>
* @Annotation
*/
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD)]
#[Attribute(\Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD)]
class Security extends ConfigurationAnnotation
{
/**
Expand Down
3 changes: 2 additions & 1 deletion src/Configuration/Template.php
Expand Up @@ -11,13 +11,14 @@

namespace Sensio\Bundle\FrameworkExtraBundle\Configuration;

use Attribute;
/**
* The Template class handles the Template annotation parts.
*
* @author Fabien Potencier <fabien@symfony.com>
* @Annotation
*/
#[\Attribute(\Attribute::TARGET_METHOD)]
#[Attribute(\Attribute::TARGET_METHOD)]
class Template extends ConfigurationAnnotation
{
/**
Expand Down
2 changes: 1 addition & 1 deletion tests/EventListener/ControllerListenerTest.php
Expand Up @@ -15,6 +15,7 @@
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Entity;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Sensio\Bundle\FrameworkExtraBundle\EventListener\ControllerListener;
Expand Down Expand Up @@ -43,7 +44,6 @@
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\ControllerEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;

class ControllerListenerTest extends \PHPUnit\Framework\TestCase
{
Expand Down
Expand Up @@ -2,7 +2,6 @@

namespace Sensio\Bundle\FrameworkExtraBundle\Tests\EventListener\Fixture;


use Sensio\Bundle\FrameworkExtraBundle\Configuration\Entity;

class FooControllerEntityAtMethod
Expand Down
Expand Up @@ -2,13 +2,11 @@

namespace Sensio\Bundle\FrameworkExtraBundle\Tests\EventListener\Fixture;


use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Entity;

class FooControllerEntityAttributeAtMethod
{
#[Entity("foo", expr: "repository.find(id)")]
#[Entity('foo', expr: 'repository.find(id)')]
public function barAction($foo)
{
}
Expand Down
Expand Up @@ -4,7 +4,7 @@

use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;

#[IsGranted("ROLE_USER")]
#[IsGranted('ROLE_USER')]
class FooControllerIsGrantedAttributeAtClass
{
public function barAction($foo)
Expand Down
Expand Up @@ -6,8 +6,8 @@

class FooControllerIsGrantedAttributeAtMethod
{
#[IsGranted("ROLE_USER")]
#[IsGranted("FOO_SHOW", subject: "foo")]
#[IsGranted('ROLE_USER')]
#[IsGranted('FOO_SHOW', subject: 'foo')]
public function barAction($foo)
{
}
Expand Down
Expand Up @@ -2,7 +2,6 @@

namespace Sensio\Bundle\FrameworkExtraBundle\Tests\EventListener\Fixture;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;

class FooControllerSecurityAtMethod
Expand Down
Expand Up @@ -2,7 +2,6 @@

namespace Sensio\Bundle\FrameworkExtraBundle\Tests\EventListener\Fixture;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;

#[Security("is_granted('ROLE_USER')")]
Expand Down
Expand Up @@ -2,7 +2,6 @@

namespace Sensio\Bundle\FrameworkExtraBundle\Tests\EventListener\Fixture;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;

class FooControllerSecurityAttributeAtMethod
Expand Down
Expand Up @@ -6,7 +6,7 @@

class FooControllerTemplateAttributeAtMethod
{
#[Template("templates/bar.html.twig", vars: ["foo"])]
#[Template('templates/bar.html.twig', vars: ['foo'])]
public function barAction($foo)
{
}
Expand Down
2 changes: 1 addition & 1 deletion tests/EventListener/IsGrantedListenerTest.php
Expand Up @@ -17,10 +17,10 @@
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\ControllerArgumentsEvent;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\HttpKernel\Exception\HttpException;

class IsGrantedListenerTest extends \PHPUnit\Framework\TestCase
{
Expand Down
22 changes: 14 additions & 8 deletions tests/EventListener/SecurityListenerTest.php
Expand Up @@ -18,8 +18,14 @@
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\ControllerArgumentsEvent;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface;
use Symfony\Component\Security\Core\Authentication\Token\AbstractToken;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\Security\Core\Role\RoleHierarchy;

class SecurityListenerTest extends \PHPUnit\Framework\TestCase
{
Expand All @@ -28,7 +34,7 @@ public function testAccessDenied()
$this->expectException(AccessDeniedException::class);

$request = $this->createRequest(new Security(['expression' => 'is_granted("ROLE_ADMIN") or is_granted("FOO")']));
$event = new ControllerArgumentsEvent($this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), function () {
$event = new ControllerArgumentsEvent($this->getMockBuilder(HttpKernelInterface::class)->getMock(), function () {
return new Response();
}, [], $request, null);

Expand All @@ -41,7 +47,7 @@ public function testNotFoundHttpException()
$this->expectExceptionMessage('Not found');

$request = $this->createRequest(new Security(['expression' => 'is_granted("ROLE_ADMIN") or is_granted("FOO")', 'statusCode' => 404, 'message' => 'Not found']));
$event = new ControllerArgumentsEvent($this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), function () {
$event = new ControllerArgumentsEvent($this->getMockBuilder(HttpKernelInterface::class)->getMock(), function () {
return new Response();
}, [], $request, null);

Expand All @@ -50,19 +56,19 @@ public function testNotFoundHttpException()

private function getListener()
{
$roleHierarchy = $this->getMockBuilder('Symfony\Component\Security\Core\Role\RoleHierarchy')->disableOriginalConstructor()->getMock();
$roleHierarchy = $this->getMockBuilder(RoleHierarchy::class)->disableOriginalConstructor()->getMock();
$roleHierarchy->expects($this->once())->method('getReachableRoleNames')->willReturn([]);

$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\AbstractToken')->getMock();
$token = $this->getMockBuilder(AbstractToken::class)->getMock();
$token->expects($this->once())->method('getRoleNames')->willReturn([]);

$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
$tokenStorage = $this->getMockBuilder(TokenStorageInterface::class)->getMock();
$tokenStorage->expects($this->exactly(2))->method('getToken')->willReturn($token);

$authChecker = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface')->getMock();
$authChecker = $this->getMockBuilder(AuthorizationCheckerInterface::class)->getMock();
$authChecker->expects($this->exactly(2))->method('isGranted')->willReturn(false);

$trustResolver = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface')->getMock();
$trustResolver = $this->getMockBuilder(AuthenticationTrustResolverInterface::class)->getMock();

$argNameConverter = $this->createArgumentNameConverter([]);

Expand Down

0 comments on commit 4dff28f

Please sign in to comment.