File tree Expand file tree Collapse file tree 1 file changed +69
-0
lines changed
Expand file tree Collapse file tree 1 file changed +69
-0
lines changed Original file line number Diff line number Diff line change @@ -1769,6 +1769,75 @@ rules:
17691769
17701770<br>
17711771
1772+ # ## NoBareAndSecurityIsGrantedContentsRule
1773+
1774+ Instead of using one long "and" condition join, split into multiple standalone # [IsGranted] attributes
1775+
1776+ ` ` ` yaml
1777+ rules:
1778+ - Symplify\P HPStanRules\R ules\S ymfony\N oBareAndSecurityIsGrantedContentsRule
1779+ ` ` `
1780+
1781+ ` ` ` php
1782+ use Symfony\C omponent\S ecurity\H ttp\A ttribute\I sGranted;
1783+
1784+ #[IsGranted('has_role(ROLE_USER) and has_role(ROLE_ADMIN)')]
1785+ class SomeController
1786+ {
1787+ }
1788+ ` ` `
1789+
1790+ :x :
1791+
1792+ <br>
1793+
1794+ ` ` ` php
1795+ use Symfony\C omponent\S ecurity\H ttp\A ttribute\I sGranted;
1796+
1797+ #[IsGranted('ROLE_USER')]
1798+ #[IsGranted('ROLE_ADMIN')]
1799+ class SomeController
1800+ {
1801+ }
1802+ ` ` `
1803+
1804+ :+1 :
1805+
1806+
1807+ # ## RequireIsGrantedEnumRule
1808+
1809+ Instead of string, use enum constant for # [IsGranted]
1810+
1811+ ` ` ` yaml
1812+ rules:
1813+ - Symplify\P HPStanRules\R ules\S ymfony\R equireIsGrantedEnumRule
1814+ ` ` `
1815+
1816+ ` ` ` php
1817+ use Symfony\C omponent\S ecurity\H ttp\A ttribute\I sGranted;
1818+
1819+ #[IsGranted('ROLE_USER')]
1820+ class SomeController
1821+ {
1822+ }
1823+ ` ` `
1824+
1825+ :x :
1826+
1827+ <br>
1828+
1829+ ` ` ` php
1830+ use Symfony\C omponent\S ecurity\H ttp\A ttribute\I sGranted;
1831+
1832+ #[IsGranted(SomeEnum::ROLE_USER)]
1833+ class SomeController
1834+ {
1835+ }
1836+ ` ` `
1837+
1838+ :+1 :
1839+
1840+
17721841# ## NoRoutingPrefixRule
17731842
17741843Avoid global route prefixing. Use single place for paths in @Route/#[Route] and improve static analysis instead.
You can’t perform that action at this time.
0 commit comments