Your project should not use dependencies with incompatible licenses
- Read doc
- Legal
- Critical
More information: https://insight.symfony.com/what-we-analyse/composer.incompatible_license
Your project controllers should only contains actions as public methods
- Read doc
- Productivity
- Major
More information: https://insight.symfony.com/what-we-analyse/symfony.controller.non_action_public_method_in_controller_class
- private EntityManagerInterface $em,
- ) {
- $this->config = $config;
- }
- #[Route('/refresh-cache')]
- public function refreshCache(): Response
- {
- $this->denyAccessUnlessGranted('ROLE_CONFIG_REFRESH_CACHE');
- $configs = $this->em->getRepository(ConfigInterface::class)
Your project must not contain invalid function or method calls 10
- Read doc
- Reliability
- Major
More information: https://insight.symfony.com/what-we-analyse/php.invalid_call
- {
- /** @var AbstractConfigRepository $configRepository */
- $configRepository = $this->em->getRepository(ConfigInterface::class);
- foreach ($this->warmups as $warmup) {
- $warmup->warmup($configRepository);
- }
- $this->em->flush();
- $io = new SymfonyStyle($input, $output);
- ->setValueString($resource->getValueString())
- ->setValueText($resource->getValueText())
- ->setValueInt($resource->getValueInt())
- ->setValueFloat($resource->getValueFloat())
- ->setTri($resource->getTri())
- ->setTenantId($this->tenantService ? $this->tenantService->getTenantId() : null);
- $this->entityManager->refresh($resource);
- parent::save($config);
- $loader->load("services.yaml");
- $configuration = new Configuration();
- $processedConfig = $this->processConfiguration($configuration, $configs);
- $container->setParameter('lle_config.using_tenant', $processedConfig['using_tenant']);
- if ($processedConfig['tenant_service']) {
- $container->setAlias('lle_config.tenant_service', $processedConfig['tenant_service']);
- }
- }
- }
- $configuration = new Configuration();
- $processedConfig = $this->processConfiguration($configuration, $configs);
- $container->setParameter('lle_config.using_tenant', $processedConfig['using_tenant']);
- if ($processedConfig['tenant_service']) {
- $container->setAlias('lle_config.tenant_service', $processedConfig['tenant_service']);
- }
- }
- }
- $item = new $configClass();
- $item
- ->setGroup($group)
- ->setLabel($label)
- ->setValueType($valueType)
- ->setTenantId($tenantId);
- return $item;
- }
- #[Required]
- /** @var AbstractConfigRepository $configRepository */
- $configRepository = $this->em->getRepository(ConfigInterface::class);
- switch ($type) {
- case ConfigInterface::BOOL:
- return $configRepository->getBool($group, $name, $default);
- case ConfigInterface::STRING:
- return $configRepository->getString($group, $name, $default);
- case ConfigInterface::TEXT:
- return $configRepository->getText($group, $name, $default);
- case ConfigInterface::INT:
- switch ($type) {
- case ConfigInterface::BOOL:
- return $configRepository->getBool($group, $name, $default);
- case ConfigInterface::STRING:
- return $configRepository->getString($group, $name, $default);
- case ConfigInterface::TEXT:
- return $configRepository->getText($group, $name, $default);
- case ConfigInterface::INT:
- return $configRepository->getInt($group, $name, $default);
- case ConfigInterface::FLOAT:
- case ConfigInterface::BOOL:
- return $configRepository->getBool($group, $name, $default);
- case ConfigInterface::STRING:
- return $configRepository->getString($group, $name, $default);
- case ConfigInterface::TEXT:
- return $configRepository->getText($group, $name, $default);
- case ConfigInterface::INT:
- return $configRepository->getInt($group, $name, $default);
- case ConfigInterface::FLOAT:
- return $configRepository->getFloat($group, $name, $default);
- default:
- case ConfigInterface::STRING:
- return $configRepository->getString($group, $name, $default);
- case ConfigInterface::TEXT:
- return $configRepository->getText($group, $name, $default);
- case ConfigInterface::INT:
- return $configRepository->getInt($group, $name, $default);
- case ConfigInterface::FLOAT:
- return $configRepository->getFloat($group, $name, $default);
- default:
- return null;
- }
- case ConfigInterface::TEXT:
- return $configRepository->getText($group, $name, $default);
- case ConfigInterface::INT:
- return $configRepository->getInt($group, $name, $default);
- case ConfigInterface::FLOAT:
- return $configRepository->getFloat($group, $name, $default);
- default:
- return null;
- }
- }
- }
Your project should not use invalid parameter and return typehints
- Read doc
- Reliability
- Major
More information: https://insight.symfony.com/what-we-analyse/php.invalid_typehint
- use Symfony\Component\DependencyInjection\Attribute\AutowireIterator;
- #[AsCommand('lle:config:warmup')]
- class WarmupCommand extends Command
- {
- public function __construct(
- private EntityManagerInterface $em,
- #[AutowireIterator('lle.config.warmup')]
- /** @var iterable<WarmupInterface> */
- private iterable $warmups,
- ) {
Your project should use return types 4
- Read doc
- Reliability
- Major
More information: https://insight.symfony.com/what-we-analyse/php.missing_return_typehint
- $metadata = $this->entityManager->getClassMetadata(ConfigInterface::class);
- return $metadata->name;
- }
- public function list(?DatasourceParams $requestParams): iterable
- {
- /** @var ConfigInterface[] $list */
- $list = parent::list($requestParams);
- $resultWithTenant = [];
- )
- {
- $this->datasource = $datasource;
- }
- public function getFields(string $key): array
- {
- $group = Field::new('group')->setRuptGroup(1);
- $label = Field::new('label')->setLabel('field.code');
- $transLabel = Field::new('label')
- ->setTemplate('@LleConfig/_trans_label.html.twig')
- public function getNbItems(): int
- {
- return 500;
- }
- public function getListActions(): array
- {
- return [];
- }
- public function getItemActions(): array
- public function getListActions(): array
- {
- return [];
- }
- public function getItemActions(): array
- {
- return [];
- }
- public function getRootRoute(): string
Your project uses non-strict array lookups 5
- Read doc
- Reliability
- Major
More information: https://insight.symfony.com/what-we-analyse/php.strict_array_lookup
- }
- }
- $result = [];
- foreach ($list as $item) {
- if ($item->getTenantId() || !in_array($item->getLabel() . '-' . $item->getGroup(), $resultWithTenant)) {
- $result[] = $item;
- }
- }
- return $result;
- * @param ConfigInterface $resource
- */
- public function save(object $resource): bool
- {
- // input type password or string set null on empty field
- if (in_array($resource->getValueType(), [ConfigInterface::PASSWORD, ConfigInterface::STRING]) && !$resource->getValueString()) {
- $resource->setValueString('');
- }
- if (in_array($resource->getValueType(), [ConfigInterface::TEXT]) && !$resource->getValueText()) {
- $resource->setValueText('');
- }
- {
- // input type password or string set null on empty field
- if (in_array($resource->getValueType(), [ConfigInterface::PASSWORD, ConfigInterface::STRING]) && !$resource->getValueString()) {
- $resource->setValueString('');
- }
- if (in_array($resource->getValueType(), [ConfigInterface::TEXT]) && !$resource->getValueText()) {
- $resource->setValueText('');
- }
- if (in_array($resource->getValueType(), [ConfigInterface::INT]) && !$resource->getValueInt()) {
- return true;
- }
- $resource->setValueString('');
- }
- if (in_array($resource->getValueType(), [ConfigInterface::TEXT]) && !$resource->getValueText()) {
- $resource->setValueText('');
- }
- if (in_array($resource->getValueType(), [ConfigInterface::INT]) && !$resource->getValueInt()) {
- return true;
- }
- if (in_array($resource->getValueType(), [ConfigInterface::FLOAT]) && !$resource->getValueFloat()) {
- return true;
- }
- $resource->setValueText('');
- }
- if (in_array($resource->getValueType(), [ConfigInterface::INT]) && !$resource->getValueInt()) {
- return true;
- }
- if (in_array($resource->getValueType(), [ConfigInterface::FLOAT]) && !$resource->getValueFloat()) {
- return true;
- }
- /** @var bool $usingTenant */
- $usingTenant = $this->parameterBag->get('lle_config.using_tenant');
Your project should not use invalid return types
- Read doc
- Reliability
- Major
More information: https://insight.symfony.com/what-we-analyse/php.invalid_return_typehint
- (int) $tenantId
- );
- $item = $this->cache->getItem($cacheKey);
- if ($item->isHit()) {
- return $item->get();
- }
- return null;
- }
Text files should end with a valid new line character. 4
- Read doc
- Productivity
- Info
More information: https://insight.symfony.com/what-we-analyse/missing_e_o_l
- - name: 'PHPStan Static Analysis'
- uses: php-actions/phpstan@v3
- with:
- configuration: tests/phpstan.neon
- memory_limit: 256M
- with:
- php_version: ${{ matrix.php_version }}
- php_extensions: xdebug
- version: 10.3
- configuration: tests/phpunit/phpunit.xml
- bootstrap: vendor/autoload.php
- php_version: ${{ matrix.php_version }}
- version: 2
- args: --profile --ignore-platform-reqs
- - name: 'PHP CodeSniffer Validations'
- run: vendor/bin/phpcs
- {% set transLabel = resource.getTransLabel|trans %}
- {% if 'config.' not in transLabel %}
- {{ transLabel }}
- {% endif %}