Hello !
I ran Phpstan at max level and got these errors :
33/33 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
------ --------------------------------------------------------------------------------
Line modules/custom/entity_visibility_preview/entity_visibility_preview.install
------ --------------------------------------------------------------------------------
13 Function entity_visibility_preview_update_8101() has no return type specified.
------ --------------------------------------------------------------------------------
------ --------------------------------------------------------------------------------------------------------------------
Line modules/custom/entity_visibility_preview/entity_visibility_preview.module
------ --------------------------------------------------------------------------------------------------------------------
21 Function entity_visibility_preview_help() has no return type specified.
21 Function entity_visibility_preview_help() has parameter $route_name with no type specified.
35 Function entity_visibility_preview_entity_access() has no return type specified.
35 Function entity_visibility_preview_entity_access() has parameter $operation with no type specified.
36 Call to an undefined method object::process().
44 Function entity_visibility_preview_toolbar() has no return type specified.
45 Call to an undefined method object::process().
53 Function entity_visibility_preview_preprocess_page() has no return type specified.
53 Function entity_visibility_preview_preprocess_page() has parameter $variables with no type specified.
54 Call to an undefined method object::process().
62 Function entity_visibility_preview_form_field_config_edit_form_alter() has no return type specified.
62 Function entity_visibility_preview_form_field_config_edit_form_alter() has parameter $form with no type specified.
63 Call to an undefined method Drupal\Core\Form\FormInterface::getEntity().
------ --------------------------------------------------------------------------------------------------------------------
------ ------------------------------------------------------------------------------------------------------------------------------------------
Line modules/custom/entity_visibility_preview/modules/entity_visibility_preview_simple_grants/entity_visibility_preview_simple_grants.install
------ ------------------------------------------------------------------------------------------------------------------------------------------
13 Function entity_visibility_preview_simple_grants_install() has no return type specified.
20 Function entity_visibility_preview_simple_grants_uninstall() has no return type specified.
27 Function entity_visibility_preview_simple_grants_update_8101() has no return type specified.
34 Function entity_visibility_preview_simple_grants_schema() has no return type specified.
------ ------------------------------------------------------------------------------------------------------------------------------------------
------ -----------------------------------------------------------------------------------------------------------------------------------------
Line modules/custom/entity_visibility_preview/modules/entity_visibility_preview_simple_grants/entity_visibility_preview_simple_grants.module
------ -----------------------------------------------------------------------------------------------------------------------------------------
17 Function entity_visibility_preview_simple_grants_help() has no return type specified.
28 Function entity_visibility_preview_simple_grants_node_access_records() has no return type specified.
71 Function entity_visibility_preview_simple_grants_node_grants() has no return type specified.
------ -----------------------------------------------------------------------------------------------------------------------------------------
------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Line modules/custom/entity_visibility_preview/modules/entity_visibility_preview_simple_grants/src/Service/EntityVisibilityPreviewSimpleGrantsGrantsHelper.php
------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
89 Cannot call method fetchCol() on Drupal\Core\Database\StatementInterface|null.
91 Parameter #2 $value of method Drupal\Core\Database\Query\ConditionInterface::condition() expects array|Drupal\Core\Database\Query\SelectInterface|string|null, int given.
101 Parameter #2 $value of method Drupal\Core\Database\Query\Delete::condition() expects array|Drupal\Core\Database\Query\SelectInterface|string|null, int given.
125 Cannot cast 0|Drupal\Core\Database\StatementInterface|null to int.
142 Cannot access offset 'value' on mixed.
142 Cannot access offset 0 on mixed.
142 Parameter #1 $variable_representation of function unserialize expects string, mixed given.
145 Cannot access offset 'date_range_condition' on mixed.
145 Cannot access offset 'value' on mixed.
146 Cannot access offset 'date_range_condition' on mixed.
146 Cannot access offset 'value' on mixed.
146 Parameter #2 $time of static method Drupal\Component\Datetime\DateTimePlus::createFromFormat() expects string, mixed given.
150 Cannot access offset 'date_range_condition' on mixed.
150 Cannot access offset 'end_value' on mixed.
151 Cannot access offset 'date_range_condition' on mixed.
151 Cannot access offset 'end_value' on mixed.
151 Parameter #2 $time of static method Drupal\Component\Datetime\DateTimePlus::createFromFormat() expects string, mixed given.
155 Cannot access offset 'taxonomy_condition' on mixed.
156 Cannot access offset 'taxonomy_condition' on mixed.
156 Cannot access offset 'taxonomy_term_uuids' on mixed.
156 Parameter #1 $uuids of method Drupal\entity_visibility_preview\Service\EntityVisibilityPreviewTaxonomyHelperInterface::getTidsFromUuids() expects array, mixed given.
244 Parameter #2 $value of method Drupal\Core\Database\Query\ConditionInterface::condition() expects array|Drupal\Core\Database\Query\SelectInterface|string|null, int given.
250 Parameter #2 $value of method Drupal\Core\Database\Query\ConditionInterface::condition() expects array|Drupal\Core\Database\Query\SelectInterface|string|null, int given.
254 Cannot call method fetchCol() on Drupal\Core\Database\StatementInterface|null.
------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------ ---------------------------------------------------------------------------------------------------------------
Line modules/custom/entity_visibility_preview/src/Controller/PreviewMessage.php
------ ---------------------------------------------------------------------------------------------------------------
34 Method Drupal\entity_visibility_preview\Controller\PreviewMessage::create() has no return type specified.
46 Method Drupal\entity_visibility_preview\Controller\PreviewMessage::getMessage() has no return type specified.
------ ---------------------------------------------------------------------------------------------------------------
------ -------------------------------------------------------------------------------------------------------------------------------------------------------------
Line modules/custom/entity_visibility_preview/src/EntityVisibilityPreviewConditionPluginBase.php
------ -------------------------------------------------------------------------------------------------------------------------------------------------------------
54 Unsafe usage of new static().
💡 See: https://phpstan.org/blog/solving-phpstan-error-unsafe-usage-of-new-static
93 Method Drupal\entity_visibility_preview\EntityVisibilityPreviewConditionPluginBase::previewBuildForm() should return array but return statement is missing.
------ -------------------------------------------------------------------------------------------------------------------------------------------------------------
------ --------------------------------------------------------------------------------------------------------------------------------------------------------------
Line modules/custom/entity_visibility_preview/src/EntityVisibilityPreviewConditionPluginManager.php
------ --------------------------------------------------------------------------------------------------------------------------------------------------------------
39 Method Drupal\entity_visibility_preview\EntityVisibilityPreviewConditionPluginManager::alterDefinitions() has no return type specified.
39 Method Drupal\entity_visibility_preview\EntityVisibilityPreviewConditionPluginManager::alterDefinitions() has parameter $definitions with no type specified.
------ --------------------------------------------------------------------------------------------------------------------------------------------------------------
------ ------------------------------------------------------------------------------------------------------
Line modules/custom/entity_visibility_preview/src/Form/PreviewForm.php
------ ------------------------------------------------------------------------------------------------------
51 Method Drupal\entity_visibility_preview\Form\PreviewForm::create() has no return type specified.
52 Unsafe usage of new static().
💡 See: https://phpstan.org/blog/solving-phpstan-error-unsafe-usage-of-new-static
93 Method Drupal\entity_visibility_preview\Form\PreviewForm::submitForm() has no return type specified.
111 Method Drupal\entity_visibility_preview\Form\PreviewForm::resetForm() has no return type specified.
------ ------------------------------------------------------------------------------------------------------
------ -------------------------------------------------------------------------------------------------------
Line modules/custom/entity_visibility_preview/src/Form/SettingsForm.php
------ -------------------------------------------------------------------------------------------------------
47 Method Drupal\entity_visibility_preview\Form\SettingsForm::submitForm() has no return type specified.
------ -------------------------------------------------------------------------------------------------------
------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Line modules/custom/entity_visibility_preview/src/Form/TaxonomyConditionGlobalConfigurationForm.php
------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
95 Method Drupal\entity_visibility_preview\Form\TaxonomyConditionGlobalConfigurationForm::create() has no return type specified.
96 Unsafe usage of new static().
💡 See: https://phpstan.org/blog/solving-phpstan-error-unsafe-usage-of-new-static
150 Parameter #1 $configuration of method Drupal\entity_visibility_preview\EntityVisibilityPreviewConditionPluginManager::getEnabledDefinitions() expects array, mixed given.
168 Parameter #1 $ids of method Drupal\Core\Entity\EntityStorageBase::loadMultiple() expects array|null, mixed given.
181 Cannot access offset 'bundles' on mixed.
181 Cannot access offset (int|string) on mixed.
200 Method Drupal\entity_visibility_preview\Form\TaxonomyConditionGlobalConfigurationForm::submitForm() has no return type specified.
------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------ ------------------------------------------------------------------------------------------------------------------------------------------------------
Line modules/custom/entity_visibility_preview/src/HookHandler/EntityAccessHookHandler.php
------ ------------------------------------------------------------------------------------------------------------------------------------------------------
70 Method Drupal\entity_visibility_preview\HookHandler\EntityAccessHookHandler::create() has no return type specified.
71 Unsafe usage of new static().
💡 See: https://phpstan.org/blog/solving-phpstan-error-unsafe-usage-of-new-static
114 Cannot access offset 'value' on mixed.
114 Cannot access offset 0 on mixed.
114 Parameter #1 $variable_representation of function unserialize expects string, mixed given.
115 Argument of an invalid type mixed supplied for foreach, only iterables are supported.
119 Parameter #2 $haystack of function in_array expects array, mixed given.
120 Cannot access offset mixed on mixed.
121 Parameter #1 $plugin_id of method Drupal\Core\Plugin\DefaultPluginManager::hasDefinition() expects string, mixed given.
123 Cannot access offset mixed on mixed.
123 Cannot access offset mixed on mixed.
125 Parameter #1 $plugin_id of method Drupal\Component\Plugin\PluginManagerBase::createInstance() expects string, mixed given.
125 Parameter #2 $configuration of method Drupal\Component\Plugin\PluginManagerBase::createInstance() expects array, mixed given.
126 Parameter #1 $values of method Drupal\entity_visibility_preview\EntityVisibilityPreviewConditionInterface::accessCheck() expects array, mixed given.
141 Call to an undefined method Drupal\Core\Access\AccessResultInterface::addCacheableDependency().
142 Call to an undefined method Drupal\Core\Access\AccessResultInterface::addCacheContexts().
------ ------------------------------------------------------------------------------------------------------------------------------------------------------
------ -----------------------------------------------------------------------------------------------------------------------
Line modules/custom/entity_visibility_preview/src/HookHandler/PreprocessPageHookHandler.php
------ -----------------------------------------------------------------------------------------------------------------------
56 Method Drupal\entity_visibility_preview\HookHandler\PreprocessPageHookHandler::create() has no return type specified.
57 Unsafe usage of new static().
💡 See: https://phpstan.org/blog/solving-phpstan-error-unsafe-usage-of-new-static
------ -----------------------------------------------------------------------------------------------------------------------
------ ----------------------------------------------------------------------------------------------------------------
Line modules/custom/entity_visibility_preview/src/HookHandler/ToolbarHookHandler.php
------ ----------------------------------------------------------------------------------------------------------------
57 Method Drupal\entity_visibility_preview\HookHandler\ToolbarHookHandler::create() has no return type specified.
58 Unsafe usage of new static().
💡 See: https://phpstan.org/blog/solving-phpstan-error-unsafe-usage-of-new-static
------ ----------------------------------------------------------------------------------------------------------------
------ --------------------------------------------------------------------------------------------------------------------------------------------------------
Line modules/custom/entity_visibility_preview/src/Plugin/EntityVisibilityPreviewCondition/DateRangeCondition.php
------ --------------------------------------------------------------------------------------------------------------------------------------------------------
64 Method Drupal\entity_visibility_preview\Plugin\EntityVisibilityPreviewCondition\DateRangeCondition::value() should return string but returns mixed.
73 Method Drupal\entity_visibility_preview\Plugin\EntityVisibilityPreviewCondition\DateRangeCondition::setValue() has no return type specified.
84 Method Drupal\entity_visibility_preview\Plugin\EntityVisibilityPreviewCondition\DateRangeCondition::endValue() should return string but returns mixed.
93 Method Drupal\entity_visibility_preview\Plugin\EntityVisibilityPreviewCondition\DateRangeCondition::setEndValue() has no return type specified.
210 Parameter #2 $time of static method Drupal\Component\Datetime\DateTimePlus::createFromFormat() expects string, mixed given.
304 Cannot access offset 'end_value' on mixed.
304 Cannot access offset 'value' on mixed.
306 Cannot access offset 'value' on mixed.
307 Cannot access offset 'end_value' on mixed.
310 Cannot access offset 'value' on mixed.
312 Cannot access offset 'value' on mixed.
315 Cannot access offset 'end_value' on mixed.
317 Cannot access offset 'end_value' on mixed.
------ --------------------------------------------------------------------------------------------------------------------------------------------------------
------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Line modules/custom/entity_visibility_preview/src/Plugin/EntityVisibilityPreviewCondition/TaxonomyCondition.php
------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
255 Call to an undefined method Drupal\Core\Field\FieldItemListInterface::referencedEntities().
264 Method Drupal\entity_visibility_preview\Plugin\EntityVisibilityPreviewCondition\TaxonomyCondition::getActualTaxonomy() should return array but returns mixed.
275 Parameter #1 $ids of method Drupal\Core\Entity\EntityStorageBase::loadMultiple() expects array|null, mixed given.
316 Argument of an invalid type mixed supplied for foreach, only iterables are supported.
317 Cannot access offset 'target_id' on mixed.
338 Parameter #1 $ids of method Drupal\Core\Entity\EntityStorageBase::loadMultiple() expects array|null, mixed given.
408 Cannot access offset 'taxonomy_term_uuids' on mixed.
409 Cannot access offset 'taxonomy_term_uuids' on mixed.
409 Parameter #1 $uuids of method Drupal\entity_visibility_preview\Service\EntityVisibilityPreviewTaxonomyHelperInterface::getTermsFromUuids() expects array, mixed given.
479 Binary operation "." between '<div class=\'term…' and Drupal\Core\Field\FieldItemListInterface results in an error.
------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------ -------------------------------------------------------------------------------------------------------------------------------
Line modules/custom/entity_visibility_preview/src/Plugin/Field/FieldFormatter/EntityVisibilityPreviewFormatter.php
------ -------------------------------------------------------------------------------------------------------------------------------
55 Unsafe usage of new static().
💡 See: https://phpstan.org/blog/solving-phpstan-error-unsafe-usage-of-new-static
75 Cannot call method getValue() on Drupal\Core\TypedData\TypedDataInterface|null.
76 Cannot access offset 'value' on mixed.
77 Cannot access offset 'value' on mixed.
77 Parameter #1 $variable_representation of function unserialize expects string, mixed given.
82 Argument of an invalid type mixed supplied for foreach, only iterables are supported.
86 Parameter #2 $haystack of function in_array expects array, mixed given.
87 Cannot access offset mixed on mixed.
88 Parameter #1 $plugin_id of method Drupal\Core\Plugin\DefaultPluginManager::hasDefinition() expects string, mixed given.
90 Cannot access offset mixed on mixed.
90 Cannot access offset mixed on mixed.
92 Parameter #1 $plugin_id of method Drupal\Component\Plugin\PluginManagerBase::createInstance() expects string, mixed given.
92 Parameter #2 $configuration of method Drupal\Component\Plugin\PluginManagerBase::createInstance() expects array, mixed given.
------ -------------------------------------------------------------------------------------------------------------------------------
------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Line modules/custom/entity_visibility_preview/src/Plugin/Field/FieldType/EntityVisibilityPreviewItem.php
------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
42 Parameter #1 $definition of method Drupal\Core\Field\FieldItemBase::__construct() expects Drupal\Core\TypedData\ComplexDataDefinitionInterface, Drupal\Core\TypedData\DataDefinitionInterface given.
91 Cannot access offset (int|string) on mixed.
91 Cannot access offset (int|string) on mixed.
94 Parameter #2 $configuration of method Drupal\Component\Plugin\PluginManagerBase::createInstance() expects array, mixed given.
101 Cannot access offset 'label' on mixed.
101 Cannot call method render() on mixed.
132 Cannot access offset 'label' on mixed.
132 Cannot call method render() on mixed.
163 Method Drupal\entity_visibility_preview\Plugin\Field\FieldType\EntityVisibilityPreviewItem::preSave() has no return type specified.
167 Access to an undefined property Drupal\entity_visibility_preview\Plugin\Field\FieldType\EntityVisibilityPreviewItem::$value.
174 Access to an undefined property Drupal\entity_visibility_preview\Plugin\Field\FieldType\EntityVisibilityPreviewItem::$value.
174 Variable $current_conditions might not be defined.
------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Line modules/custom/entity_visibility_preview/src/Plugin/Field/FieldWidget/EntityVisibilityPreviewWidget.php
------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
39 Unsafe usage of new static().
💡 See: https://phpstan.org/blog/solving-phpstan-error-unsafe-usage-of-new-static
112 Parameter #1 $configuration of method Drupal\entity_visibility_preview\EntityVisibilityPreviewConditionPluginManager::getEnabledDefinitions() expects array, mixed given.
115 Cannot access offset (int|string) on mixed.
115 Cannot access offset (int|string) on mixed.
117 Parameter #2 $configuration of method Drupal\Component\Plugin\PluginManagerBase::createInstance() expects array, mixed given.
118 Cannot access offset (int|string) on mixed.
118 Cannot access offset (int|string) on mixed.
119 Parameter #1 $values of method Drupal\entity_visibility_preview\EntityVisibilityPreviewConditionInterface::form() expects array, mixed given.
------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Line modules/custom/entity_visibility_preview/src/Service/EntityVisibilityPreviewFieldHelper.php
------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
78 Parameter #1 $configuration of method Drupal\entity_visibility_preview\EntityVisibilityPreviewConditionPluginManager::getEnabledDefinitions() expects array, mixed given.
------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------ -------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Line modules/custom/entity_visibility_preview/src/Service/EntityVisibilityPreviewTaxonomyHelper.php
------ -------------------------------------------------------------------------------------------------------------------------------------------------------------------------
57 Method Drupal\entity_visibility_preview\Service\EntityVisibilityPreviewTaxonomyHelper::getTidsFromUuids() should return array but returns array|int.
92 Method Drupal\entity_visibility_preview\Service\EntityVisibilityPreviewTaxonomyHelper::getTermsFromUuids() should return array<Drupal\taxonomy\Entity\Term> but returns
array<Drupal\Core\Entity\EntityInterface>.
------ -------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------ -----------------------------------------------------------------------------------------------------------------------------------------------------------------
Line modules/custom/entity_visibility_preview/src/Service/SessionManager.php
------ -----------------------------------------------------------------------------------------------------------------------------------------------------------------
37 Property Drupal\entity_visibility_preview\Service\SessionManager::$session (Symfony\Component\HttpFoundation\Session\SessionInterface) in empty() is not falsy.
39 Cannot access offset string on mixed.
39 Cannot access offset string on mixed.
48 Method Drupal\entity_visibility_preview\Service\SessionManager::setFromSession() has no return type specified.
49 Property Drupal\entity_visibility_preview\Service\SessionManager::$session (Symfony\Component\HttpFoundation\Session\SessionInterface) in empty() is not falsy.
51 Cannot access offset string on mixed.
60 Property Drupal\entity_visibility_preview\Service\SessionManager::$session (Symfony\Component\HttpFoundation\Session\SessionInterface) in empty() is not falsy.
62 Cannot access offset string on mixed.
71 Property Drupal\entity_visibility_preview\Service\SessionManager::$session (Symfony\Component\HttpFoundation\Session\SessionInterface) in empty() is not falsy.
73 Cannot access offset 'entity_visibility…' on mixed.
82 Property Drupal\entity_visibility_preview\Service\SessionManager::$session (Symfony\Component\HttpFoundation\Session\SessionInterface) in empty() is not falsy.
84 Cannot access offset 'entity_visibility…' on mixed.
84 Cannot access offset 'entity_visibility…' on mixed.
84 Method Drupal\entity_visibility_preview\Service\SessionManager::isPreviewActive() should return bool but returns mixed.
94 Property Drupal\entity_visibility_preview\Service\SessionManager::$session (Symfony\Component\HttpFoundation\Session\SessionInterface) in empty() is not falsy.
------ -----------------------------------------------------------------------------------------------------------------------------------------------------------------
------ -------------------------------------------------------------------------------------------------------------------------
Line modules/custom/entity_visibility_preview/src/Service/SessionManagerInterface.php
------ -------------------------------------------------------------------------------------------------------------------------
41 Method Drupal\entity_visibility_preview\Service\SessionManagerInterface::setFromSession() has no return type specified.
------ -------------------------------------------------------------------------------------------------------------------------
[ERROR] Found 158 errors
@phpstan-ignore-next-line cases :
- some "undefined methods" object::process()
- more "undefined methods" Drupal\Core\Form\FormInterface::getEntity()
- very "undefined methods" Drupal\Core\Access\AccessResultInterface::addCacheableDependency() & ::addCacheContexts()
- such "undefined methods" Drupal\Core\Field\FieldItemListInterface::referencedEntities()
- all the "return new static()" calls
- a case of untyped function param because extended from a Core class that didn't typehint it
- a few "undefined property" Drupal\entity_visibility_preview\Plugin\Field\FieldType\EntityVisibilityPreviewItem::$value.
I managed to fix everything, checked phpcs for any regression, it should be okay, thanks for the review !
Issue fork entity_visibility_preview-3250202
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
grimreaperComment #5
grimreaperMerged!
Thanks.