From e5d0f026d25a2c19c655186c01a10f2fb25123cf Mon Sep 17 00:00:00 2001 From: dev Date: Tue, 31 Mar 2026 19:06:36 +0300 Subject: [PATCH 1/4] [fix] Cast entity id to string in navbar to fix active state on update --- src/Controller/AbstractCrudController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Controller/AbstractCrudController.php b/src/Controller/AbstractCrudController.php index b5d7598..eb3af21 100644 --- a/src/Controller/AbstractCrudController.php +++ b/src/Controller/AbstractCrudController.php @@ -721,7 +721,7 @@ public function createNavigation(?object $entity = null, array $options = []): ? 'label' => $this->getEntityLabel($parent, $parentOptions), ], 'cms'), 'route' => $parentUpdate['route'], - 'route_params' => $parentUpdateRouteParams + ['id' => $parent->getId()], // @phpstan-ignore method.notFound + 'route_params' => $parentUpdateRouteParams + ['id' => (string) $parent->getId()], // @phpstan-ignore method.notFound ]); } } @@ -732,7 +732,7 @@ public function createNavigation(?object $entity = null, array $options = []): ? /** @var array $params */ $params = $prefixOptions['route_params']; if (null !== $entity) { - $params['id'] = $entity->getId(); // @phpstan-ignore method.notFound + $params['id'] = (string) $entity->getId(); // @phpstan-ignore method.notFound } /** @var string $transId */ From ad51050ea998d5902d50d26752aea4dfb8587b4e Mon Sep 17 00:00:00 2001 From: dev Date: Wed, 1 Apr 2026 09:35:42 +0300 Subject: [PATCH 2/4] [fix] Cast parent id to string in route_params to fix navbar active state --- src/Configurator/CrudControllerConfigurator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Configurator/CrudControllerConfigurator.php b/src/Configurator/CrudControllerConfigurator.php index f6fd2a7..1b80674 100644 --- a/src/Configurator/CrudControllerConfigurator.php +++ b/src/Configurator/CrudControllerConfigurator.php @@ -328,7 +328,7 @@ private function configureRoutes(OptionsResolver $resolver): void /** @var string $parentRouteParam */ $parentRouteParam = $options['parent_route_param']; - return \array_replace($value, $parent ? [$parentRouteParam => $parent->getId()] : []); // @phpstan-ignore method.notFound + return \array_replace($value, $parent ? [$parentRouteParam => (string) $parent->getId()] : []); // @phpstan-ignore method.notFound }); } From ccb8314429b8c3e6ebf0b7e900da9195cf76039d Mon Sep 17 00:00:00 2001 From: dev Date: Wed, 1 Apr 2026 09:37:24 +0300 Subject: [PATCH 3/4] [fix] Resolve PHPStan errors: cast.mixed, stale paramOut.type ignore, implode type --- src/Controller/AbstractCrudController.php | 4 ++-- src/Form/Type/FileType.php | 2 +- src/PropertyAccessor/ReflectionPropertyAccessor.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Controller/AbstractCrudController.php b/src/Controller/AbstractCrudController.php index eb3af21..43f6b96 100644 --- a/src/Controller/AbstractCrudController.php +++ b/src/Controller/AbstractCrudController.php @@ -721,7 +721,7 @@ public function createNavigation(?object $entity = null, array $options = []): ? 'label' => $this->getEntityLabel($parent, $parentOptions), ], 'cms'), 'route' => $parentUpdate['route'], - 'route_params' => $parentUpdateRouteParams + ['id' => (string) $parent->getId()], // @phpstan-ignore method.notFound + 'route_params' => $parentUpdateRouteParams + ['id' => (string) $parent->getId()], // @phpstan-ignore method.notFound, cast.mixed ]); } } @@ -732,7 +732,7 @@ public function createNavigation(?object $entity = null, array $options = []): ? /** @var array $params */ $params = $prefixOptions['route_params']; if (null !== $entity) { - $params['id'] = (string) $entity->getId(); // @phpstan-ignore method.notFound + $params['id'] = (string) $entity->getId(); // @phpstan-ignore method.notFound, cast.mixed } /** @var string $transId */ diff --git a/src/Form/Type/FileType.php b/src/Form/Type/FileType.php index 9dcf72f..192a1e4 100644 --- a/src/Form/Type/FileType.php +++ b/src/Form/Type/FileType.php @@ -40,7 +40,7 @@ public function configureOptions(OptionsResolver $resolver): void 'multiple' => false, 'mime_types' => [], 'attr' => static fn (Options $options): array => [ - 'accept' => \implode(',', (array) $options['mime_types']), + 'accept' => \implode(',', (array) $options['mime_types']), // @phpstan-ignore argument.type ], 'constraints' => static function (Options $options): array { /** @var array $mimeTypes */ diff --git a/src/PropertyAccessor/ReflectionPropertyAccessor.php b/src/PropertyAccessor/ReflectionPropertyAccessor.php index a026f8a..077eaf2 100644 --- a/src/PropertyAccessor/ReflectionPropertyAccessor.php +++ b/src/PropertyAccessor/ReflectionPropertyAccessor.php @@ -31,7 +31,7 @@ public function __construct(private readonly PropertyAccessorInterface $decorate */ public function setValue(object|array &$objectOrArray, string|PropertyPathInterface $propertyPath, mixed $value): void { - try { // @phpstan-ignore paramOut.type + try { $this->decorated->setValue($objectOrArray, $propertyPath, $value); // @phpstan-ignore paramOut.type } catch (NoSuchPropertyException $exception) { if (!\is_object($objectOrArray)) { From 34292163175ea5b14f804966df0f034d1b80c180 Mon Sep 17 00:00:00 2001 From: dev Date: Wed, 1 Apr 2026 09:40:04 +0300 Subject: [PATCH 4/4] [fix] Use @var annotation to resolve mixed cast errors in PHPStan --- src/Configurator/CrudControllerConfigurator.php | 8 +++++++- src/Controller/AbstractCrudController.php | 8 ++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Configurator/CrudControllerConfigurator.php b/src/Configurator/CrudControllerConfigurator.php index 1b80674..825fc58 100644 --- a/src/Configurator/CrudControllerConfigurator.php +++ b/src/Configurator/CrudControllerConfigurator.php @@ -328,7 +328,13 @@ private function configureRoutes(OptionsResolver $resolver): void /** @var string $parentRouteParam */ $parentRouteParam = $options['parent_route_param']; - return \array_replace($value, $parent ? [$parentRouteParam => (string) $parent->getId()] : []); // @phpstan-ignore method.notFound + if (null === $parent) { + return $value; + } + /** @var string|\Stringable $parentId */ + $parentId = $parent->getId(); // @phpstan-ignore method.notFound + + return \array_replace($value, [$parentRouteParam => (string) $parentId]); }); } diff --git a/src/Controller/AbstractCrudController.php b/src/Controller/AbstractCrudController.php index 43f6b96..df49bda 100644 --- a/src/Controller/AbstractCrudController.php +++ b/src/Controller/AbstractCrudController.php @@ -715,13 +715,15 @@ public function createNavigation(?object $entity = null, array $options = []): ? if ($parentUpdate && isset($parentUpdate['route'])) { /** @var array $parentUpdateRouteParams */ $parentUpdateRouteParams = $parentUpdate['route_params']; + /** @var string|\Stringable $parentId */ + $parentId = $parent->getId(); // @phpstan-ignore method.notFound $root->add('common.nav.parent', [ 'label' => $this->translator->trans('common.nav.parent', [ 'type' => $parentOptions['title'], 'label' => $this->getEntityLabel($parent, $parentOptions), ], 'cms'), 'route' => $parentUpdate['route'], - 'route_params' => $parentUpdateRouteParams + ['id' => (string) $parent->getId()], // @phpstan-ignore method.notFound, cast.mixed + 'route_params' => $parentUpdateRouteParams + ['id' => (string) $parentId], ]); } } @@ -732,7 +734,9 @@ public function createNavigation(?object $entity = null, array $options = []): ? /** @var array $params */ $params = $prefixOptions['route_params']; if (null !== $entity) { - $params['id'] = (string) $entity->getId(); // @phpstan-ignore method.notFound, cast.mixed + /** @var string|\Stringable $entityId */ + $entityId = $entity->getId(); // @phpstan-ignore method.notFound + $params['id'] = (string) $entityId; } /** @var string $transId */