cs: Enable more risky rules.

This commit is contained in:
Pol Dellaiera
2021-11-30 11:37:57 +01:00
parent c8195e6df5
commit a9188355c5
193 changed files with 306 additions and 63 deletions

View File

@@ -19,6 +19,7 @@ use Symfony\Component\Routing\RouteCollection;
use function array_filter;
use function array_keys;
use function array_search;
use function count;
use function in_array;
class CRUDRoutesLoader extends Loader

View File

@@ -36,6 +36,7 @@ use function array_key_exists;
use function array_keys;
use function array_merge;
use function bin2hex;
use function count;
use function implode;
use function random_bytes;
use function trim;

View File

@@ -15,6 +15,7 @@ use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Intl\Intl;
use function in_array;
/*
* Load or update the languages entities command

View File

@@ -24,6 +24,7 @@ use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Validator\Validator\ValidatorInterface;
use function count;
class LoadPostalCodesCommand extends Command
{

View File

@@ -23,6 +23,7 @@ use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Translation\TranslatorInterface;
use function count;
use function serialize;
use function unserialize;

View File

@@ -24,6 +24,7 @@ use Symfony\Component\Security\Core\Role\Role;
use Symfony\Component\Security\Core\Role\RoleHierarchy;
use Symfony\Component\Validator\Validator\ValidatorInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use function array_key_exists;
/**
* Class PermissionsGroupController.

View File

@@ -25,6 +25,7 @@ use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Contracts\Translation\TranslatorInterface;
use function count;
use function key;
use function reset;
@@ -105,7 +106,7 @@ class SearchController extends AbstractController
$advancedSearchProviders = $searchProvider
->getHasAdvancedFormSearchServices();
if (\count($advancedSearchProviders) === 1) {
if (count($advancedSearchProviders) === 1) {
reset($advancedSearchProviders);
return $this->redirectToRoute('chill_main_advanced_search', [

View File

@@ -15,6 +15,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Security;
use function count;
class TimelineCenterController extends AbstractController
{

View File

@@ -87,7 +87,7 @@ class UserController extends CRUDController
return $this->redirect($this->generateUrl(
'chill_crud_admin_user_edit',
\array_merge(['id' => $uid], $returnPathParams)
array_merge(['id' => $uid], $returnPathParams)
));
}

View File

@@ -16,6 +16,7 @@ use Doctrine\Persistence\ObjectManager;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Intl\Intl;
use function in_array;
/**
* Load languages into database.

View File

@@ -42,6 +42,7 @@ use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use function count;
/**
* Class ChillMainExtension

View File

@@ -13,6 +13,7 @@ use LogicException;
use RuntimeException;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use function count;
/**
* Description of ConfigConsistencyCompilerPass.

View File

@@ -19,6 +19,11 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
use UnexpectedValueException;
use function array_key_exists;
use function count;
use function get_class;
use function in_array;
use function is_array;
/**
* Compile the configurations and inject required service into container.

View File

@@ -14,7 +14,10 @@ use Generator;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use function array_key_exists;
use function count;
use function implode;
use function in_array;
/**
* This trait allow to add automatic configuration for widget inside your config.

View File

@@ -14,6 +14,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\DateIntervalType;
use Exception;
use function count;
use function current;
use function preg_match;
use function reset;
@@ -84,7 +85,7 @@ class NativeDateIntervalType extends DateIntervalType
$current = current($strings);
if (is_numeric($current)) {
$next = \next($strings);
$next = next($strings);
switch ($next) {
case 'year':

View File

@@ -16,6 +16,7 @@ use RuntimeException;
use Symfony\Component\Security\Core\User\AdvancedUserInterface;
use Symfony\Component\Serializer\Annotation as Serializer;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use function in_array;
/**
* User.

View File

@@ -24,6 +24,11 @@ use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use UnexpectedValueException;
use function array_key_exists;
use function count;
use function get_class;
use function gettype;
use function in_array;
/**
* Collects all agregators, filters and export from
@@ -192,7 +197,7 @@ class ExportManager
} elseif ($element instanceof FormatterInterface) {
$this->addFormatter($element, $alias);
} else {
throw new LogicException('This element ' . \get_class($element) . ' '
throw new LogicException('This element ' . get_class($element) . ' '
. 'is not an instance of export element');
}
}

View File

@@ -20,6 +20,11 @@ use Symfony\Component\Form\Extension\Core\Type\FormType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Contracts\Translation\TranslatorInterface;
use function array_key_exists;
use function array_slice;
use function call_user_func;
use function count;
use function is_array;
/**
* Command to get the report with curl:

View File

@@ -20,6 +20,7 @@ use Symfony\Component\Translation\TranslatorInterface;
use function array_key_exists;
use function array_keys;
use function array_map;
use function count;
use function implode;
// command to get the report with curl : curl --user "center a_social:password" "http://localhost:8000/fr/exports/generate/count_person?export[filters][person_gender_filter][enabled]=&export[filters][person_nationality_filter][enabled]=&export[filters][person_nationality_filter][form][nationalities]=&export[aggregators][person_nationality_aggregator][order]=1&export[aggregators][person_nationality_aggregator][form][group_by_level]=country&export[submit]=&export[_token]=RHpjHl389GrK-bd6iY5NsEqrD5UKOTHH40QKE9J1edU" --globoff

View File

@@ -17,6 +17,7 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Translation\TranslatorInterface;
use function array_map;
use function count;
/**
* Create a CSV List for the export where the header are printed on the

View File

@@ -22,7 +22,10 @@ use function array_map;
use function array_merge;
use function array_multisort;
use function array_unique;
use function call_user_func;
use function count;
use function fopen;
use function is_array;
use function stream_get_contents;
use function sys_get_temp_dir;
use function tempnam;

View File

@@ -25,6 +25,7 @@ use Symfony\Component\Translation\TranslatorInterface;
use function array_key_exists;
use function array_keys;
use function array_map;
use function count;
use function fopen;
use function implode;
use function stream_get_contents;

View File

@@ -17,6 +17,7 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use function array_combine;
use function array_merge;
use function count;
class PermissionsGroupType extends AbstractType
{

View File

@@ -18,6 +18,7 @@ use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use function in_array;
/**
* Form to Edit/create a role scope. If the role scope does not

View File

@@ -16,6 +16,7 @@ use Symfony\Component\Form\DataTransformerInterface;
use Symfony\Component\Form\Exception\TransformationFailedException;
use Symfony\Component\Form\Exception\UnexpectedTypeException;
use Traversable;
use function count;
class CenterTransformer implements DataTransformerInterface
{

View File

@@ -19,7 +19,9 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\GreaterThan;
use function array_diff;
use function array_values;
use function count;
use function implode;
use function is_array;
/**
* Show a dateInterval type.

View File

@@ -25,6 +25,7 @@ use function array_intersect;
use function array_key_exists;
use function array_merge;
use function array_unique;
use function count;
use function in_array;
/**

View File

@@ -19,6 +19,7 @@ use Symfony\Component\Form\FormView;
use Symfony\Component\HttpFoundation\RequestStack;
use function array_combine;
use function array_map;
use function count;
final class FilterOrderType extends \Symfony\Component\Form\AbstractType
{

View File

@@ -25,6 +25,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Security;
use function array_merge;
use function array_values;
use function count;
/**
* Pick a center.

View File

@@ -28,6 +28,7 @@ use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInt
use Symfony\Component\Security\Core\Role\Role;
use Symfony\Component\Security\Core\Security;
use function array_map;
use function count;
/**
* Allow to pick amongst available scope for the current

View File

@@ -17,6 +17,7 @@ use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Translation\Translator;
use function in_array;
class TranslatableStringFormType extends AbstractType
{

View File

@@ -19,6 +19,7 @@ use function array_key_exists;
use function in_array;
use function json_decode;
use function preg_replace;
use function strlen;
/**
* Helper to some task linked to phonenumber.

View File

@@ -17,6 +17,7 @@ use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\QueryBuilder;
use Doctrine\Persistence\ObjectRepository;
use function count;
final class UserRepository implements ObjectRepository
{

View File

@@ -16,6 +16,7 @@ use Knp\Menu\ItemInterface;
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Translation\TranslatorInterface;
use function array_key_exists;
use function array_merge;
use function array_values;
@@ -128,7 +129,7 @@ class MenuComposer
*/
public function hasLocalMenuBuilder($menuId): bool
{
return \array_key_exists($menuId, $this->localMenuBuilders);
return array_key_exists($menuId, $this->localMenuBuilders);
}
/**

View File

@@ -10,6 +10,7 @@
namespace Chill\MainBundle\Search;
use DateTime;
use function array_key_exists;
use function strpos;
/**

View File

@@ -18,6 +18,7 @@ use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Query\ResultSetMappingBuilder;
use function array_map;
use function array_merge;
use function count;
use function implode;
use function strtr;

View File

@@ -10,6 +10,7 @@
namespace Chill\MainBundle\Search;
use function array_push;
use function count;
use function implode;
use function strtr;

View File

@@ -10,6 +10,8 @@
namespace Chill\MainBundle\Search;
use function array_key_exists;
use function chr;
use function count;
/**
* a service which gather all search services defined into the bundles

View File

@@ -10,6 +10,7 @@
namespace Chill\MainBundle\Search\Utils;
use LogicException;
use function count;
use function implode;
use function preg_match;
use function str_split;

View File

@@ -24,6 +24,7 @@ use Symfony\Component\Security\Core\User\UserInterface;
use Traversable;
use UnexpectedValueException;
use function array_merge;
use function get_class;
/**
* Helper for authorizations.

View File

@@ -13,6 +13,7 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Security\Core\Role\Role;
use Symfony\Component\Security\Core\Role\RoleHierarchyInterface;
use function array_keys;
use function in_array;
/**
* Helper which traverse all role to find parents.
@@ -54,7 +55,7 @@ class ParentRoleHelper
foreach ($roles as $r) {
$childRoles = $this->roleHierarchy->getReachableRoleNames([$r]);
if (\in_array($role, $childRoles)) {
if (in_array($role, $childRoles)) {
$parentRoles[] = $r;
}
}

View File

@@ -13,6 +13,7 @@ use Chill\MainBundle\Entity\User;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
use function in_array;
class PasswordRecoverVoter extends Voter
{

View File

@@ -13,6 +13,7 @@ namespace Chill\MainBundle\Security\Resolver;
use Chill\MainBundle\Entity\Center;
use UnexpectedValueException;
use function get_class;
use function is_array;
final class CenterResolverManager implements CenterResolverManagerInterface

View File

@@ -106,7 +106,7 @@ class RoleProvider
}
} else {
if ($provider->getRoles() !== null) {
$this->rolesTitlesCache = \array_merge(
$this->rolesTitlesCache = array_merge(
$this->rolesTitlesCache,
array_fill_keys($provider->getRoles(), null)
);

View File

@@ -17,6 +17,7 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use function array_key_exists;
use function is_array;
class DateNormalizer implements ContextAwareNormalizerInterface, DenormalizerInterface
@@ -98,7 +99,7 @@ class DateNormalizer implements ContextAwareNormalizerInterface, DenormalizerInt
if ('docgen' === $format) {
return $data instanceof DateTimeInterface || (
null === $data
&& \array_key_exists('docgen:expects', $context)
&& array_key_exists('docgen:expects', $context)
&& (
DateTimeInterface::class === $context['docgen:expects']
|| DateTime::class === $context['docgen:expects']

View File

@@ -14,6 +14,7 @@ use Symfony\Component\Serializer\Exception\RuntimeException;
use Symfony\Component\Serializer\Normalizer\ContextAwareDenormalizerInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait;
use function count;
use function implode;
/**

View File

@@ -15,6 +15,7 @@ use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface;
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use function array_key_exists;
use function count;
use function is_array;
class DoctrineExistingEntityNormalizer implements DenormalizerInterface

View File

@@ -13,6 +13,8 @@ use Chill\MainBundle\Doctrine\Model\Point;
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use function count;
use function is_array;
class PointNormalizer implements DenormalizerInterface
{

View File

@@ -14,6 +14,7 @@ use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use function array_merge;
use function count;
class FilterOrderHelper
{

View File

@@ -13,6 +13,7 @@ namespace Chill\MainBundle\Templating;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Contracts\Translation\TranslatorInterface;
use function array_key_exists;
final class TranslatableStringHelper implements TranslatableStringHelperInterface
{

View File

@@ -14,6 +14,7 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Twig\Environment;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
use function array_key_exists;
use function ksort;
/**

View File

@@ -13,6 +13,11 @@ use Doctrine\ORM\AbstractQuery;
use Doctrine\ORM\QueryBuilder;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Traversable;
use function call_user_func;
use function count;
use function is_array;
use function is_callable;
use function is_string;
/**
* Helper which creates a set of test for aggregators.

View File

@@ -17,6 +17,11 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Role\Role;
use Traversable;
use function call_user_func;
use function count;
use function is_array;
use function is_callable;
use function is_string;
/**
* This class provide a set of tests for exports.

View File

@@ -12,6 +12,10 @@ namespace Chill\MainBundle\Test\Export;
use Doctrine\ORM\QueryBuilder;
use Exception;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use function count;
use function get_class;
use function is_array;
use function is_string;
/**
* Helper to test filters.

View File

@@ -18,7 +18,7 @@ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
* @internal
* @coversNothing
*/
class ExportControllerTest extends KernelTestCase
class PointTest extends KernelTestCase
{
public function testFromArrayGeoJson()
{

View File

@@ -21,6 +21,7 @@ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Symfony\Component\Security\Core\Role\Role;
use function count;
/**
* Test the export manager.

View File

@@ -19,7 +19,7 @@ use Symfony\Component\Form\Test\TypeTestCase;
* @internal
* @coversNothing
*/
class CenterTypeTest extends TypeTestCase
class PickCenterTypeTest extends TypeTestCase
{
/**
* Test that a user which can reach multiple center

View File

@@ -12,6 +12,7 @@ namespace Chill\MainBundle\Tests\Pagination;
use Chill\MainBundle\Pagination\Paginator;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use function count;
/**
* Test the paginator class.

View File

@@ -23,6 +23,7 @@ use Chill\MainBundle\Test\ProphecyTrait;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Security\Core\Role\Role;
use function array_map;
use function in_array;
/**
* @internal

View File

@@ -20,7 +20,7 @@ use PHPUnit\Framework\TestCase;
* @internal
* @coversNothing
*/
class DefaultScopeResolverDispatcherTest extends TestCase
class ScopeResolverDispatcherTest extends TestCase
{
private ScopeResolverDispatcher $scopeResolverDispatcher;

View File

@@ -16,6 +16,8 @@ use Doctrine\ORM\Query;
use Doctrine\ORM\Query\ResultSetMapping;
use LogicException;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use function array_key_exists;
use function is_string;
/**
* Build timeline.

View File

@@ -10,6 +10,7 @@
namespace Chill\MainBundle\Util;
use UnexpectedValueException;
use function array_key_exists;
/**
* Get information about countries.

View File

@@ -20,6 +20,7 @@ use function array_key_exists;
use function array_merge;
use function array_unique;
use function array_values;
use function count;
use function ksort;
/**

View File

@@ -17,6 +17,7 @@ use RuntimeException;
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
use function in_array;
class RoleScopeScopePresence extends ConstraintValidator
{

View File

@@ -14,6 +14,7 @@ use Doctrine\Migrations\AbstractMigration;
use Doctrine\ORM\Query\ResultSetMapping;
use RuntimeException;
use Symfony\Component\DependencyInjection\ContainerInterface;
use function count;
/**
* Migrate association from