From e919db5a6639a4f4dbb30ea3f2f51449a99363c1 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Tue, 22 Dec 2020 00:29:12 +0100 Subject: [PATCH] Add missing typehint --- src/Admin/AdminInterface.php | 1 - .../Admin/AbstractTaggedAdmin.php | 39 +++++++++++++++++-- .../Admin/TaggedAdminInterface.php | 2 - 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/Admin/AdminInterface.php b/src/Admin/AdminInterface.php index b40e6e21009..41b3677c167 100644 --- a/src/Admin/AdminInterface.php +++ b/src/Admin/AdminInterface.php @@ -74,7 +74,6 @@ * @method void defineFormBuilder(FormBuilderInterface $formBuilder) * * @phpstan-template T of object - * @phpstan-extends TaggedAdminInterface * @phpstan-extends AccessRegistryInterface * @phpstan-extends UrlGeneratorInterface * @phpstan-extends LifecycleHookProviderInterface diff --git a/src/DependencyInjection/Admin/AbstractTaggedAdmin.php b/src/DependencyInjection/Admin/AbstractTaggedAdmin.php index f82f85ebd10..66e2f2c3817 100644 --- a/src/DependencyInjection/Admin/AbstractTaggedAdmin.php +++ b/src/DependencyInjection/Admin/AbstractTaggedAdmin.php @@ -32,7 +32,6 @@ /** * @phpstan-template T of object - * @phpstan-implements TaggedAdminInterface */ abstract class AbstractTaggedAdmin implements TaggedAdminInterface { @@ -69,7 +68,7 @@ abstract class AbstractTaggedAdmin implements TaggedAdminInterface /** * @var array> * - * @phpstan-var array{list: array{class: string}, mosaic: array{class: string}} + * @phpstan-var array{list: array{class: string}, mosaic?: array{class: string}} */ protected $listModes = [ 'list' => ['class' => 'fa fa-list fa-fw'], @@ -248,6 +247,8 @@ public function setLabel($label) /** * @final since sonata-admin/admin-bundle 3.84 + * + * @return string|null */ public function getLabel() { @@ -257,7 +258,7 @@ public function getLabel() final public function showMosaicButton($isShown) { if ($isShown) { - $this->listModes['mosaic'] = ['class' => static::MOSAIC_ICON_CLASS]; + $this->listModes['mosaic'] = ['class' => self::MOSAIC_ICON_CLASS]; } else { unset($this->listModes['mosaic']); } @@ -265,6 +266,8 @@ final public function showMosaicButton($isShown) /** * @final since sonata-admin/admin-bundle 3.84 + * + * @return array> */ public function getListModes() { @@ -299,6 +302,8 @@ public function setManagerType($type) /** * @final since sonata-admin/admin-bundle 3.84 + * + * @return string|null // NEXT_MAJOR: Remove null */ public function getManagerType() { @@ -372,6 +377,8 @@ public function setModelManager(ModelManagerInterface $modelManager) /** * @final since sonata-admin/admin-bundle 3.84 + * + * @return ModelManagerInterface|null // NEXT_MAJOR: Remove null */ public function getModelManager() { @@ -401,6 +408,8 @@ public function setDataSource(DataSourceInterface $dataSource) /** * NEXT_MAJOR: Change typehint for DataSourceInterface. + * + * @return DataSourceInterface|null // NEXT_MAJOR: Remove null */ public function getDataSource(): ?DataSourceInterface { @@ -430,6 +439,8 @@ public function setFormContractor(FormContractorInterface $formBuilder) /** * @final since sonata-admin/admin-bundle 3.84 + * + * @return FormContractorInterface|null // NEXT_MAJOR: Remove null */ public function getFormContractor() { @@ -459,6 +470,8 @@ public function setShowBuilder(ShowBuilderInterface $showBuilder) /** * @final since sonata-admin/admin-bundle 3.84 + * + * @return ShowBuilderInterface|null // NEXT_MAJOR: Remove null */ public function getShowBuilder() { @@ -488,6 +501,8 @@ public function setListBuilder(ListBuilderInterface $listBuilder) /** * @final since sonata-admin/admin-bundle 3.84 + * + * @return ListBuilderInterface|null // NEXT_MAJOR: Remove null */ public function getListBuilder() { @@ -517,6 +532,8 @@ public function setDatagridBuilder(DatagridBuilderInterface $datagridBuilder) /** * @final since sonata-admin/admin-bundle 3.84 + * + * @return DatagridBuilderInterface|null // NEXT_MAJOR: Remove null */ public function getDatagridBuilder() { @@ -546,6 +563,8 @@ public function setTranslator(TranslatorInterface $translator) /** * @final since sonata-admin/admin-bundle 3.83 + * + * @return TranslatorInterface|null // NEXT_MAJOR: Remove null */ public function getTranslator() { @@ -575,6 +594,8 @@ public function setConfigurationPool(Pool $configurationPool) /** * @final since sonata-admin/admin-bundle 3.84 + * + * @return Pool|null // NEXT_MAJOR: Remove null */ public function getConfigurationPool() { @@ -606,6 +627,8 @@ public function setRouteGenerator(RouteGeneratorInterface $routeGenerator) /** * @final since sonata-admin/admin-bundle 3.84 + * + * @return RouteGeneratorInterface|null // NEXT_MAJOR: Remove null */ public function getRouteGenerator() { @@ -647,6 +670,8 @@ public function setValidator($validator) * NEXT_MAJOR: Remove this method. * * @deprecated since sonata-project/admin-bundle 3.83 and will be removed in 4.0 + * + * @return ValidatorInterface|null // NEXT_MAJOR: Remove null */ public function getValidator() { @@ -668,6 +693,8 @@ public function setSecurityHandler(SecurityHandlerInterface $securityHandler) /** * @final since sonata-admin/admin-bundle 3.84 + * + * @return SecurityHandlerInterface|null // NEXT_MAJOR: Remove null */ public function getSecurityHandler() { @@ -697,6 +724,8 @@ public function setMenuFactory(FactoryInterface $menuFactory) /** * @final since sonata-admin/admin-bundle 3.84 + * + * @return FactoryInterface|null // NEXT_MAJOR: Remove null */ public function getMenuFactory() { @@ -726,6 +755,8 @@ public function setRouteBuilder(RouteBuilderInterface $routeBuilder) /** * @final since sonata-admin/admin-bundle 3.84 + * + * @return RouteBuilderInterface|null // NEXT_MAJOR: Remove null */ public function getRouteBuilder() { @@ -755,6 +786,8 @@ public function setLabelTranslatorStrategy(LabelTranslatorStrategyInterface $lab /** * @final since sonata-admin/admin-bundle 3.84 + * + * @return LabelTranslatorStrategyInterface|null // NEXT_MAJOR: Remove null */ public function getLabelTranslatorStrategy() { diff --git a/src/DependencyInjection/Admin/TaggedAdminInterface.php b/src/DependencyInjection/Admin/TaggedAdminInterface.php index e1e20cb7334..c881f31f2cf 100644 --- a/src/DependencyInjection/Admin/TaggedAdminInterface.php +++ b/src/DependencyInjection/Admin/TaggedAdminInterface.php @@ -41,8 +41,6 @@ * - The first and third argument are automatically injected by the AddDependencyCallsCompilerPass. * - The second one is used as a reference of the Admin in the Pool, with the `setAdminClasses` call. * - * @phpstan-template T of object - * * @method void initialize() * @method void setLabel(?string $label) * @method void showMosaicButton(bool $isShown)