.. _ruleset-analyze: Analyze +++++++ This ruleset centralizes a large number of classic trap and pitfalls when writing PHP. Total : 501 analysis * :ref:`adding-zero` * :ref:`ambiguous-array-index` * :ref:`multiple-index-definition` * :ref:`empty-classes` * :ref:`forgotten-visibility` * :ref:`non-static-methods-called-in-a-static` * :ref:`old-style-constructor` * :ref:`static-methods-called-from-object` * :ref:`empty-function` * :ref:`redeclared-php-functions` * :ref:`methods-without-return` * :ref:`empty-interfaces` * :ref:`incompilable-files` * :ref:`error\_reporting()-with-integers` * :ref:`eval()-usage` * :ref:`exit()-usage` * :ref:`forgotten-whitespace` * :ref:`iffectations` * :ref:`multiply-by-one` * :ref:`@-operator` * :ref:`not-not` * :ref:`include\_once()-usage` * :ref:`strpos()-like-comparison` * :ref:`throws-an-assignement` * :ref:`var\_dump()...-usage` * :ref:`\_\_tostring()-throws-exception` * :ref:`non-ascii-variables` * :ref:`used-once-variables` * :ref:`bad-constants-names` * :ref:`empty-traits` * :ref:`use-with-fully-qualified-name` * :ref:`useless-instructions` * :ref:`abstract-static-methods` * :ref:`invalid-constant-name` * :ref:`multiple-constant-definition` * :ref:`wrong-optional-parameter` * :ref:`use-===-null` * :ref:`$this-is-not-an-array` * :ref:`one-variable-string` * :ref:`static-methods-can't-contain-$this` * :ref:`while(list()-=-each())` * :ref:`several-instructions-on-the-same-line` * :ref:`multiples-identical-case` * :ref:`switch-without-default` * :ref:`$this-belongs-to-classes-or-traits` * :ref:`nested-ternary` * :ref:`non-constant-index-in-array` * :ref:`undefined-constants` * :ref:`instantiating-abstract-class` * :ref:`class,-interface,-enum-or-trait-with-identical-names` * :ref:`empty-try-catch` * :ref:`undefined-classes` * :ref:`htmlentities-calls` * :ref:`undefined-class-constants` * :ref:`used-once-variables-(in-scope)` * :ref:`undefined-functions` * :ref:`deprecated-php-functions` * :ref:`dangling-array-references` * :ref:`queries-in-loops` * :ref:`var-keyword` * :ref:`native-alias-functions-usage` * :ref:`uses-default-values` * :ref:`wrong-number-of-arguments` * :ref:`hardcoded-passwords` * :ref:`unresolved-classes` * :ref:`useless-constructor` * :ref:`implements-is-for-interface` * :ref:`use-const` * :ref:`unresolved-use` * :ref:`undefined-parent` * :ref:`undefined-static-or-self` * :ref:`accessing-private` * :ref:`access-protected-structures` * :ref:`parent,-static-or-self-outside-class` * :ref:`list()-may-omit-variables` * :ref:`or-die` * :ref:`written-only-variables` * :ref:`must-return-methods` * :ref:`empty-instructions` * :ref:`overwritten-exceptions` * :ref:`foreach-reference-is-not-modified` * :ref:`don't-change-incomings` * :ref:`compared-comparison` * :ref:`useless-return` * :ref:`unused-classes` * :ref:`unpreprocessed-values` * :ref:`undefined-properties` * :ref:`short-open-tags` * :ref:`strict-comparison-with-booleans` * :ref:`lone-blocks` * :ref:`$this-is-not-for-static-methods` * :ref:`global-usage` * :ref:`logical-should-use-symbolic-operators` * :ref:`could-use-self` * :ref:`catch-overwrite-variable` * :ref:`deep-definitions` * :ref:`repeated-print()` * :ref:`avoid-parenthesis-with-language-construct` * :ref:`objects-don't-need-references` * :ref:`lost-references` * :ref:`constants-created-outside-its-namespace` * :ref:`fully-qualified-constants` * :ref:`never-used-properties` * :ref:`no-real-comparison` * :ref:`should-use-local-class` * :ref:`no-direct-call-to-magic-method` * :ref:`string-may-hold-a-variable` * :ref:`echo-with-concat` * :ref:`unused-global` * :ref:`useless-global` * :ref:`preprocessable` * :ref:`useless-final` * :ref:`use-constant-instead-of-function` * :ref:`useless-unset` * :ref:`buried-assignation` * :ref:`no-array\_merge()-in-loops` * :ref:`useless-parenthesis` * :ref:`unresolved-instanceof` * :ref:`use-php-object-api` * :ref:`unthrown-exception` * :ref:`old-style-\_\_autoload()` * :ref:`altering-foreach-without-reference` * :ref:`use-pathinfo` * :ref:`should-use-existing-constants` * :ref:`hash-algorithms` * :ref:`no-parenthesis-for-language-construct` * :ref:`no-hardcoded-path` * :ref:`no-hardcoded-port` * :ref:`use-constant-as-arguments` * :ref:`implied-if` * :ref:`overwritten-literals` * :ref:`assign-default-to-properties` * :ref:`no-public-access` * :ref:`should-chain-exception` * :ref:`useless-interfaces` * :ref:`undefined-interfaces` * :ref:`double-instructions` * :ref:`should-use-prepared-statement` * :ref:`print-and-die` * :ref:`unchecked-resources` * :ref:`no-hardcoded-ip` * :ref:`else-if-versus-elseif` * :ref:`unset-in-foreach` * :ref:`could-be-a-static-variable` * :ref:`multiple-class-declarations` * :ref:`empty-namespace` * :ref:`could-use-short-assignation` * :ref:`useless-abstract-class` * :ref:`static-loop` * :ref:`pre-increment` * :ref:`only-variable-returned-by-reference` * :ref:`indices-are-int-or-string` * :ref:`should-typecast` * :ref:`no-self-referencing-constant` * :ref:`no-direct-usage` * :ref:`break-outside-loop` * :ref:`avoid-substr()-one` * :ref:`double-assignation` * :ref:`empty-list` * :ref:`useless-brackets` * :ref:`preg\_replace-with-option-e` * :ref:`eval()-without-try` * :ref:`func\_get\_arg()-modified` * :ref:`avoid-get\_class()` * :ref:`silently-cast-integer` * :ref:`timestamp-difference` * :ref:`unused-parameter` * :ref:`switch-to-switch` * :ref:`wrong-parameter-type` * :ref:`wrong-fopen()-mode` * :ref:`negative-power` * :ref:`already-parents-interface` * :ref:`use-random\_int()` * :ref:`can't-extend-final` * :ref:`ternary-in-concat` * :ref:`using-$this-outside-a-class` * :ref:`undefined-trait` * :ref:`no-hardcoded-hash` * :ref:`identical-conditions` * :ref:`unkown-regex-options` * :ref:`no-choice` * :ref:`common-alternatives` * :ref:`logical-mistakes` * :ref:`uncaught-exceptions` * :ref:`same-conditions-in-condition` * :ref:`return-true-false` * :ref:`useless-switch` * :ref:`could-use-\_\_dir\_\_` * :ref:`should-use-coalesce` * :ref:`make-global-a-property` * :ref:`if-with-same-conditions` * :ref:`throw-functioncall` * :ref:`use-instanceof` * :ref:`results-may-be-missing` * :ref:`always-positive-comparison` * :ref:`empty-blocks` * :ref:`throw-in-destruct` * :ref:`use-system-tmp` * :ref:`dependant-trait` * :ref:`hidden-use-expression` * :ref:`should-make-alias` * :ref:`multiple-identical-trait-or-interface` * :ref:`multiple-alias-definitions` * :ref:`nested-ifthen` * :ref:`cast-to-boolean` * :ref:`failed-substr()-comparison` * :ref:`should-use-ternary-operator` * :ref:`unused-returned-value` * :ref:`modernize-empty-with-expression` * :ref:`use-positive-condition` * :ref:`drop-else-after-return` * :ref:`use-class-operator` * :ref:`don't-echo-error` * :ref:`useless-type-casting` * :ref:`no-isset()-with-empty()` * :ref:`useless-check` * :ref:`bail-out-early` * :ref:`don't-change-the-blind-var` * :ref:`avoid-using-stdclass` * :ref:`too-many-local-variables` * :ref:`illegal-name-for-method` * :ref:`long-arguments` * :ref:`assigned-twice` * :ref:`no-boolean-as-default` * :ref:`forgotten-thrown` * :ref:`multiple-alias-definitions-per-file` * :ref:`\_\_dir\_\_-then-slash` * :ref:`self,-parent,-static-outside-class` * :ref:`used-once-property` * :ref:`property-used-in-one-method-only` * :ref:`no-need-for-else` * :ref:`strange-name-for-constants` * :ref:`too-many-finds` * :ref:`should-use-setcookie()` * :ref:`check-all-types` * :ref:`missing-cases-in-switch` * :ref:`repeated-regex` * :ref:`no-class-in-global` * :ref:`crc32()-might-be-negative` * :ref:`could-use-str\_repeat()` * :ref:`suspicious-comparison` * :ref:`strings-with-strange-space` * :ref:`no-empty-regex` * :ref:`alternative-syntax-consistence` * :ref:`randomly-sorted-arrays` * :ref:`only-variable-passed-by-reference` * :ref:`no-return-used` * :ref:`no-reference-on-left-side` * :ref:`implemented-methods-must-be-public` * :ref:`mixed-concat-and-interpolation` * :ref:`too-many-injections` * :ref:`could-make-a-function` * :ref:`forgotten-interface` * :ref:`avoid-optional-properties` * :ref:`mismatched-ternary-alternatives` * :ref:`mismatched-default-arguments` * :ref:`mismatched-typehint` * :ref:`scalar-or-object-property` * :ref:`assign-and-lettered-logical-operator-precedence` * :ref:`no-magic-method-with-array` * :ref:`logical-to-in\_array` * :ref:`pathinfo()-returns-may-vary` * :ref:`multiple-type-variable` * :ref:`is-actually-zero` * :ref:`unconditional-break-in-loop` * :ref:`could-be-else` * :ref:`next-month-trap` * :ref:`printf-number-of-arguments` * :ref:`ambiguous-static` * :ref:`don't-send-$this-in-constructor` * :ref:`no-get\_class()-with-null` * :ref:`maybe-missing-new` * :ref:`unknown-pcre2-option` * :ref:`parent-first` * :ref:`invalid-regex` * :ref:`use-named-boolean-in-argument-definition` * :ref:`same-variable-foreach` * :ref:`never-called-parameter` * :ref:`identical-on-both-sides` * :ref:`identical-consecutive-expression` * :ref:`no-reference-for-ternary` * :ref:`unused-inherited-variable-in-closure` * :ref:`inclusion-wrong-case` * :ref:`missing-include` * :ref:`useless-referenced-argument` * :ref:`possible-infinite-loop` * :ref:`test-then-cast` * :ref:`foreach-on-object` * :ref:`property-could-be-local` * :ref:`too-many-native-calls` * :ref:`don't-unset-properties` * :ref:`strtr-arguments` * :ref:`missing-parenthesis` * :ref:`callback-function-needs-return` * :ref:`wrong-range-check` * :ref:`can't-instantiate-class` * :ref:`strpos()-too-much` * :ref:`class-typed-references` * :ref:`weak-typing` * :ref:`method-signature-must-be-compatible` * :ref:`mismatch-type-and-default` * :ref:`check-json` * :ref:`don't-mix-++` * :ref:`can't-throw-throwable` * :ref:`abstract-or-implements` * :ref:`incompatible-signature-methods` * :ref:`ambiguous-visibilities` * :ref:`undefined-class` * :ref:`assert-function-is-reserved` * :ref:`could-be-abstract-class` * :ref:`continue-is-for-loop` * :ref:`must-call-parent-constructor` * :ref:`undefined-variable` * :ref:`undefined-insteadof` * :ref:`method-collision-traits` * :ref:`class-could-be-final` * :ref:`only-variable-for-reference` * :ref:`wrong-access-style-to-property` * :ref:`invalid-pack-format` * :ref:`repeated-interface` * :ref:`don't-read-and-write-in-one-expression` * :ref:`should-yield-with-key` * :ref:`useless-method-alias` * :ref:`method-could-be-static` * :ref:`possible-missing-subpattern` * :ref:`assign-and-compare` * :ref:`variable-is-not-a-condition` * :ref:`insufficient-typehint` * :ref:`type-must-be-returned` * :ref:`clone-with-non-object` * :ref:`check-on-\_\_call-usage` * :ref:`avoid-option-arrays-in-constructors` * :ref:`already-parents-trait` * :ref:`trait-not-found` * :ref:`casting-ternary` * :ref:`concat-empty-string` * :ref:`concat-and-addition` * :ref:`useless-argument` * :ref:`no-append-on-source` * :ref:`memoize-magiccall` * :ref:`unused-class-constant` * :ref:`infinite-recursion` * :ref:`null-or-boolean-arrays` * :ref:`dependant-abstract-classes` * :ref:`wrong-type-returned` * :ref:`overwritten-source-and-value` * :ref:`avoid-mb\_dectect\_encoding()` * :ref:`array\_key\_exists()-works-on-arrays` * :ref:`class-without-parent` * :ref:`scalar-are-not-arrays` * :ref:`array\_merge()-and-variadic` * :ref:`implode()-arguments-order` * :ref:`strip\_tags()-skips-closed-tag` * :ref:`no-spread-for-hash` * :ref:`max-level-of-nesting` * :ref:`should-use-explode-args` * :ref:`use-array\_slice()` * :ref:`too-many-array-dimensions` * :ref:`coalesce-and-concat` * :ref:`comparison-is-always-the-same` * :ref:`incompatible-signature-methods-with-covariance` * :ref:`interfaces-is-not-implemented` * :ref:`no-literal-for-reference` * :ref:`interfaces-don't-ensure-properties` * :ref:`non-nullable-getters` * :ref:`too-many-dereferencing` * :ref:`can't-implement-traversable` * :ref:`is\_a()-with-string` * :ref:`mbstring-unknown-encoding` * :ref:`mbstring-third-arg` * :ref:`merge-if-then` * :ref:`wrong-type-with-call` * :ref:`not-equal-is-not-!==` * :ref:`don't-collect-void` * :ref:`wrong-typed-property-default` * :ref:`implicit-nullable-type` * :ref:`fn-argument-variable-confusion` * :ref:`missing-abstract-method` * :ref:`undefined-constant-name` * :ref:`using-deprecated-method` * :ref:`cyclic-references` * :ref:`double-object-assignation` * :ref:`wrong-argument-type` * :ref:`mismatch-properties-typehints` * :ref:`no-need-for-triple-equal` * :ref:`array\_merge-needs-array-of-arrays` * :ref:`wrong-type-for-native-php-function` * :ref:`catch-with-undefined-variable` * :ref:`swapped-arguments` * :ref:`different-argument-counts` * :ref:`unknown-parameter-name` * :ref:`missing-some-returntype` * :ref:`don't-pollute-global-space` * :ref:`mismatch-parameter-name` * :ref:`multiple-declaration-of-strict\_types` * :ref:`array\_fill()-with-objects` * :ref:`modified-typed-parameter` * :ref:`assumptions` * :ref:`unsupported-types-with-operators` * :ref:`wrong-attribute-configuration` * :ref:`cancelled-parameter` * :ref:`constant-typo-looks-like-a-variable` * :ref:`array\_map()-passes-by-value` * :ref:`missing-\_\_isset()-method` * :ref:`modify-immutable` * :ref:`cannot-use-static-for-closure` * :ref:`only-first-byte-` * :ref:`inherited-property-type-must-match` * :ref:`no-object-as-index` * :ref:`htmlentities-using-default-flag` * :ref:`wrong-argument-name-with-php-function` * :ref:`duplicate-named-parameter` * :ref:`php-native-class-type-compatibility` * :ref:`missing-attribute-attribute` * :ref:`no-null-for-native-php-functions` * :ref:`no-referenced-void` * :ref:`php-native-interfaces-and-return-type` * :ref:`new-functions-in-php-8.1` * :ref:`never-keyword` * :ref:`false-to-array-conversion` * :ref:`float-conversion-as-index` * :ref:`cannot-call-static-trait-method-directly` * :ref:`overwritten-foreach-var` * :ref:`recycled-variables` * :ref:`check-division-by-zero` * :ref:`don't-reuse-foreach-source` * :ref:`unreachable-method` * :ref:`unfinished-object` * :ref:`undefined-enumcase` * :ref:`don't-add-seconds` * :ref:`use-constants-as-returns` * :ref:`identical-variables-in-foreach` * :ref:`can't-overwrite-final-constant` * :ref:`unsupported-operand-types` * :ref:`version\_compare-operator` * :ref:`do-not-cast-to-int` * :ref:`could-be-spaceship` * :ref:`unused-enumeration-case` * :ref:`useless-null-coalesce` * :ref:`throw-raw-exceptions` * :ref:`implicit-conversion-to-int` * :ref:`use-same-types-for-comparisons` * :ref:`wrong-locale` * :ref:`parent-is-not-static` * :ref:`no-magic-method-for-enum` * :ref:`no-readonly-assignation-in-global` * :ref:`overload-existing-names` * :ref:`retyped-reference` * :ref:`wrong-type-with-default` * :ref:`sprintf-format-compilation` * :ref:`invalid-date-scanning-format` * :ref:`same-name-for-property-and-method` * :ref:`datetimeimmutable-is-not-immutable` * :ref:`no-default-for-referenced-parameter` * :ref:`clone-constant` * :ref:`could-inject-parameter` * :ref:`unused-public-methods` * :ref:`mbstring-unknown-encodings` * :ref:`coalesce-and-ternary-operators-order` * :ref:`useless-assignation-of-promoted-property` * :ref:`empty-loop` * :ref:`useless-method` * :ref:`weak-type-with-array` * :ref:`no-empty-string-with-explode()` * :ref:`array-access-on-literal-array` * :ref:`double-checks` * :ref:`strpos()-with-integers` * :ref:`missing-assignation-in-branches` * :ref:`no-valid-cast` * :ref:`misused-yield` * :ref:`no-null-for-index` * :ref:`useless-try` * :ref:`converted-exceptions` * :ref:`method-is-not-an-if` * :ref:`default-then-discard` * :ref:`identical-case-in-switch` * :ref:`standalonetype-true-false-null` * :ref:`could-use-yield-from` * :ref:`append-and-assign-arrays` * :ref:`static-methods-cannot-call-non-static-methods` * :ref:`trait-is-not-a-type` * :ref:`cannot-use-append-for-reading` * :ref:`void-is-not-a-reference` * :ref:`can't-call-generator` * :ref:`non-integer-nor-string-as-index` * :ref:`cant-instantiate-non-class` * :ref:`check-after-null-safe-operator` * :ref:`no-null-with-null-safe-operator` * :ref:`invalid-cast` * :ref:`new-object-then-immediate-call` * :ref:`wrong-precedence-in-expression` * :ref:`only-variable-passed-by-reference` * :ref:`nested-match` * :ref:`useless-short-ternary` * :ref:`empty-json-error` * :ref:`useless-coalesce` * :ref:`count()-is-not-negative` * :ref:`exit-without-argument` * :ref:`strpos()-less-than-one` * :ref:`static-inclusions` * :ref:`constant-used-only-once` Specs _____ +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Short name | Analyze | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Available in | `Entreprise Edition `_, `Community Edition `_, `Exakat Cloud `_ | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Reports | :ref:`report-ambassador`, :ref:`report-diplomat` | +--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+