Skip to content

Commit

Permalink
refactor: Fixing psalm issues
Browse files Browse the repository at this point in the history
  • Loading branch information
philipsorst committed Jun 20, 2024
1 parent cdad6d2 commit 279ccb2
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 60 deletions.
2 changes: 2 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
findUnusedCode="false"
findUnusedBaselineEntry="true"
ensureOverrideAttribute="true"
>
<projectFiles>
<directory name="src"/>
Expand Down
42 changes: 21 additions & 21 deletions src/DependencyInjection/DdrCrudAdminExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,28 @@

class DdrCrudAdminExtension extends Extension
{
final public const TAG_CONTROLLER = 'ddr_crud_admin.controller';
final public const TAG_FORM_TYPE_PROVIDER = 'ddr_crud_admin.form_type_provider';
final public const TAG_TEMPLATE_PROVIDER = 'ddr_crud_admin.template_provider';
final public const TAG_ROUTE_INFO_PROVIDER = 'ddr_crud_admin.route_info_provider';
final public const TAG_ID_PROVIDER = 'ddr_crud_admin.id_provider';
final public const TAG_FIELD_DEFINITIONS_PROVIDER = 'ddr_crud_admin.field_definitions_provider';
final public const TAG_QUERY_EXTENSION_PROVIDER = 'ddr_crud_admin.query_extension_provider';
final public const TAG_DEFAULT_SORT_PROVIDER = 'ddr_crud_admin.default_sort_provider';
final public const TAG_FIELD_RENDERER_PROVIDER = 'ddr_crud_admin.field_renderer_provider';
final public const TAG_PAGINATION_PROVIDER = 'ddr_crud_admin.pagination_provider';
final public const TAG_PAGINATION_TARGET_PROVIDER = 'ddr_crud_admin.pagination_target_provider';
final public const TAG_FORM_PROVIDER = 'ddr_crud_admin.form_provider';
final public const TAG_ITEM_PROVIDER = 'ddr_crud_admin.item_provider';
final public const TAG_TITLE_PROVIDER = 'ddr_crud_admin.title_provider';
final public const TAG_ITEM_PERSISTER_PROVIDER = 'ddr_crud_admin.item_persister_provider';
final public const TAG_URL_PROVIDER = 'ddr_crud_admin.url_provider';
final public const TAG_TRANSLATION_DOMAIN_PROVIDER = 'ddr_crud_admin.translation_domain_provider';
final public const TAG_QUERY_BUILDER_EXTENSION_PROVIDER = 'ddr_crud_admin.query_builder_extension_provider';
final public const string TAG_CONTROLLER = 'ddr_crud_admin.controller';
final public const string TAG_FORM_TYPE_PROVIDER = 'ddr_crud_admin.form_type_provider';
final public const string TAG_TEMPLATE_PROVIDER = 'ddr_crud_admin.template_provider';
final public const string TAG_ROUTE_INFO_PROVIDER = 'ddr_crud_admin.route_info_provider';
final public const string TAG_ID_PROVIDER = 'ddr_crud_admin.id_provider';
final public const string TAG_FIELD_DEFINITIONS_PROVIDER = 'ddr_crud_admin.field_definitions_provider';
final public const string TAG_QUERY_EXTENSION_PROVIDER = 'ddr_crud_admin.query_extension_provider';
final public const string TAG_DEFAULT_SORT_PROVIDER = 'ddr_crud_admin.default_sort_provider';
final public const string TAG_FIELD_RENDERER_PROVIDER = 'ddr_crud_admin.field_renderer_provider';
final public const string TAG_PAGINATION_PROVIDER = 'ddr_crud_admin.pagination_provider';
final public const string TAG_PAGINATION_TARGET_PROVIDER = 'ddr_crud_admin.pagination_target_provider';
final public const string TAG_FORM_PROVIDER = 'ddr_crud_admin.form_provider';
final public const string TAG_ITEM_PROVIDER = 'ddr_crud_admin.item_provider';
final public const string TAG_TITLE_PROVIDER = 'ddr_crud_admin.title_provider';
final public const string TAG_ITEM_PERSISTER_PROVIDER = 'ddr_crud_admin.item_persister_provider';
final public const string TAG_URL_PROVIDER = 'ddr_crud_admin.url_provider';
final public const string TAG_TRANSLATION_DOMAIN_PROVIDER = 'ddr_crud_admin.translation_domain_provider';
final public const string TAG_QUERY_BUILDER_EXTENSION_PROVIDER = 'ddr_crud_admin.query_builder_extension_provider';

final public const PRIORITY_LOW = -256;
final public const PRIORITY_MEDIUM = -192;
final public const PRIORITY_HIGH = -128;
final public const int PRIORITY_LOW = -256;
final public const int PRIORITY_MEDIUM = -192;
final public const int PRIORITY_HIGH = -128;

#[Override]
public function load(array $configs, ContainerBuilder $container): void
Expand Down
1 change: 0 additions & 1 deletion src/Service/Form/FormProviderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ interface FormProviderInterface extends ProviderInterface
{
/**
* @param class-string $entityClass
* @param object|null $entity
* @return FormInterface|null
*/
public function provideForm(string $entityClass, CrudOperation $crudOperation, ?object $entity): ?FormInterface;
Expand Down
4 changes: 2 additions & 2 deletions src/Service/Title/DefaultTitleProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

class DefaultTitleProvider implements TitleProviderInterface
{
final public const TYPE_AUTO = 'auto';
final public const TYPE_MANUAL = 'manual';
final public const string TYPE_AUTO = 'auto';
final public const string TYPE_MANUAL = 'manual';

public function __construct(
private readonly TranslationDomainResolverInterface $translationDomainResolver,
Expand Down
5 changes: 2 additions & 3 deletions tests/TestApp/DataFixtures/DepartmentOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Persistence\ObjectManager;
use Dontdrinkandroot\CrudAdminBundle\Tests\TestApp\Entity\Department;
use Override;

class DepartmentOne extends Fixture
{
/**
* {@inheritdoc}
*/
#[Override]
public function load(ObjectManager $manager): void
{
$department = new Department('one');
Expand Down
5 changes: 2 additions & 3 deletions tests/TestApp/DataFixtures/DepartmentTwo.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Persistence\ObjectManager;
use Dontdrinkandroot\CrudAdminBundle\Tests\TestApp\Entity\Department;
use Override;

class DepartmentTwo extends Fixture
{
/**
* {@inheritdoc}
*/
#[Override]
public function load(ObjectManager $manager): void
{
$department = new Department('two', '023');
Expand Down
5 changes: 2 additions & 3 deletions tests/TestApp/DataFixtures/ExampleEntities.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Persistence\ObjectManager;
use Dontdrinkandroot\CrudAdminBundle\Tests\TestApp\Entity\ExampleEntity;
use Override;

class ExampleEntities extends Fixture
{
/**
* {@inheritdoc}
*/
#[Override]
public function load(ObjectManager $manager): void
{
for ($i = 0; $i < 20; $i++) {
Expand Down
9 changes: 3 additions & 6 deletions tests/TestApp/Form/Type/DepartmentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,21 @@

use Dontdrinkandroot\Common\Asserted;
use Dontdrinkandroot\CrudAdminBundle\Tests\TestApp\Entity\Department;
use Override;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class DepartmentType extends AbstractType
{
/**
* {@inheritdoc}
*/
#[Override]
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add('name');
}

/**
* {@inheritdoc}
*/
#[Override]
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefault('data_class', Department::class);
Expand Down
9 changes: 3 additions & 6 deletions tests/TestApp/Security/DepartmentVoter.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Dontdrinkandroot\Common\CrudOperation;
use Dontdrinkandroot\CrudAdminBundle\Tests\TestApp\Entity\Department;
use Override;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
Expand All @@ -17,18 +18,14 @@ public function __construct(private readonly AuthorizationCheckerInterface $auth
{
}

/**
* {@inheritdoc}
*/
#[Override]
protected function supports(string $attribute, $subject): bool
{
return is_a($subject, Department::class, true)
&& in_array(CrudOperation::tryFrom($attribute), CrudOperation::all());
}

/**
* {@inheritdoc}
*/
#[Override]
protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token): bool
{
if ($this->authorizationChecker->isGranted('ROLE_ADMIN')) {
Expand Down
9 changes: 3 additions & 6 deletions tests/TestApp/Security/ExampleEntityVoter.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Dontdrinkandroot\Common\CrudOperation;
use Dontdrinkandroot\CrudAdminBundle\Tests\TestApp\Entity\ExampleEntity;
use Override;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
Expand All @@ -17,18 +18,14 @@ public function __construct(private readonly AuthorizationCheckerInterface $auth
{
}

/**
* {@inheritdoc}
*/
#[Override]
protected function supports(string $attribute, $subject): bool
{
return is_a($subject, ExampleEntity::class, true)
&& in_array(CrudOperation::tryFrom($attribute), CrudOperation::all());
}

/**
* {@inheritdoc}
*/
#[Override]
protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token): bool
{
if ($this->authorizationChecker->isGranted('ROLE_ADMIN')) {
Expand Down
13 changes: 4 additions & 9 deletions tests/TestApp/TestKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,27 @@

namespace Dontdrinkandroot\CrudAdminBundle\Tests\TestApp;

use Override;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\HttpKernel\Kernel;

class TestKernel extends Kernel
{
use MicroKernelTrait;

/**
* {@inheritdoc}
*/
#[Override]
public function getProjectDir(): string
{
return __DIR__;
}

/**
* {@inheritdoc}
*/
#[Override]
public function getCacheDir(): string
{
return sys_get_temp_dir() . '/ddr_crud_admin_bundle/cache/';
}

/**
* {@inheritdoc}
*/
#[Override]
public function getLogDir(): string
{
return sys_get_temp_dir() . '/ddr_crud_admin_bundle/logs/';
Expand Down

0 comments on commit 279ccb2

Please sign in to comment.