Repository navigation
Fix PHPStan errors in polylang-phpstan extension #26
Copy link
Copy link
Open
Description
What?
#24 introduced PHPStan analysis for the repo, but some errors remains on other extensions.
------ -------------------------------------------------------------------------------
Line LanguageReturnTypeExtension.php
------ -------------------------------------------------------------------------------
:20 Access to an undefined property
PhpParser\Node\Arg|PhpParser\Node\VariadicPlaceholder::$value.
🪪 property.notFound
💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-p
roperty
:20 Result of || is always true.
🪪 booleanOr.alwaysTrue
💡 Because the type is coming from a PHPDoc, you can turn off this check by
setting treatPhpDocTypesAsCertain: false in your phpstan.neon.dist.
:20 Strict comparison using !== between 'OBJECT' and PhpParser\Node\Expr will
always evaluate to true.
🪪 notIdentical.alwaysTrue
💡 Because the type is coming from a PHPDoc, you can turn off this check by
setting treatPhpDocTypesAsCertain: false in your phpstan.neon.dist.
:24 Unreachable statement - code above always terminates.
🪪 deadCode.unreachable
------ -------------------------------------------------------------------------------
------ -------------------------------------------------------------------------------
Line ModelLanguagesGetListDynamicMethodReturnTypeExtension.php
------ -------------------------------------------------------------------------------
:30 Class WP_Syntex\Polylang\Model\Languages not found.
🪪 class.notFound
💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
:42 Class PLL_Language not found.
🪪 class.notFound
💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
:49 Class PLL_Language not found.
🪪 class.notFound
💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
:52 Doing instanceof PHPStan\Type\IntersectionType is error-prone and deprecated.
🪪 phpstanApi.instanceofType
💡 Learn more: https://phpstan.org/blog/why-is-instanceof-type-wrong-and-gett
ing-deprecated
:52 Right side of && is always true.
🪪 booleanAnd.rightAlwaysTrue
💡 If PHPStan\TrinaryLogic::yes() is impure, add @phpstan-impure PHPDoc tag a
bove its declaration. Learn more: https://phpstan.org/blog/remembering-and-fo
rgetting-returned-values
:64 Class PLL_Language not found.
🪪 class.notFound
💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
:67 Call to an undefined method PHPStan\Type\Type::getValue().
🪪 method.notFound
:72 Right side of && is always true.
🪪 booleanAnd.rightAlwaysTrue
💡 If PHPStan\TrinaryLogic::yes() is impure, add @phpstan-impure PHPDoc tag a
bove its declaration. Learn more: https://phpstan.org/blog/remembering-and-fo
rgetting-returned-values
:76 Call to an undefined method PHPStan\Type\Type::getValueTypes().
🪪 method.notFound
:80 Class PLL_Language not found.
🪪 class.notFound
💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
:83 Call to an undefined method PHPStan\Type\Type::getValueTypes().
🪪 method.notFound
:88 Call to an undefined method PHPStan\Type\Type::getValueTypes().
🪪 method.notFound
:92 Class PLL_Language not found.
🪪 class.notFound
💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
------ -------------------------------------------------------------------------------
------ ----------------------------------------------------------------------
Line OptionsGetDynamicMethodReturnTypeExtension.php
------ ----------------------------------------------------------------------
:29 Class WP_Syntex\Polylang\Options\Options not found.
🪪 class.notFound
💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
------ ----------------------------------------------------------------------
------ ----------------------------------------------------------------------
Line PLLModelGetLanguagesListDynamicMethodReturnTypeExtension.php
------ ----------------------------------------------------------------------
:16 Class PLL_Model not found.
🪪 class.notFound
💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
------ ----------------------------------------------------------------------
------ -------------------------------------------------------------------------------
Line Rules/DeprecatedPllSwitcherRule.php
------ -------------------------------------------------------------------------------
:33 Instanceof between PhpParser\Node\Expr and PhpParser\Node\Expr will always
evaluate to true.
🪪 instanceof.alwaysTrue
💡 Because the type is coming from a PHPDoc, you can turn off this check by
setting treatPhpDocTypesAsCertain: false in your phpstan.neon.dist.
:38 Method
WPSyntex\Polylang\PHPStan\Rules\DeprecatedPllSwitcherRule::processNode()
should return list<PHPStan\Rules\IdentifierRuleError> but returns list<PHPSta
n\Rules\RuleError>.
🪪 return.type
💡 Error is missing an identifier. See:
https://phpstan.org/blog/using-rule-error-builder
:42 Method
WPSyntex\Polylang\PHPStan\Rules\DeprecatedPllSwitcherRule::processNode()
should return list<PHPStan\Rules\IdentifierRuleError> but returns list<PHPSta
n\Rules\RuleError>.
🪪 return.type
💡 Error is missing an identifier. See:
https://phpstan.org/blog/using-rule-error-builder
------ -------------------------------------------------------------------------------
[ERROR] Found 22 errors Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
[-]Fix PHPStan error in `polylang-phpstan` extension[/-][+]Fix PHPStan errors in `polylang-phpstan` extension[/+]