Coding-standard: Global php functions in the use section and disallow fqn

Created on 3 Jan 2020  路  4Comments  路  Source: slevomat/coding-standard

I need a rule that

  • disables fqn for global php functions (for example: \array_ke_exists() cannot be written)
  • disables using global php functions without placing them in the use section

I tried to use the rule SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly, but I was not successful.
It seems, when I write

<property name="allowFullyQualifiedGlobalFunctions" value="false"/>
<property name="allowFallbackGlobalFunctions" value="false"/>
<property name="allowFullyQualifiedNameForCollidingFunctions" value="true"/>

and

<property name="namespacesRequiredToUse" type="array">

with empty field (because without it, it is not possible using fqn classes without placing in the use section). Then the rule namespacesRequiredToUse overrides the rule allowFullyQualifiedGlobalFunctions.
(I found one solution when I write all existing global php functions into namespacesRequiredToUse, but it is very slow and difficult to maintain)

Any ideas how to achieve with slevomat/coding-standard of what I need?

Question

All 4 comments

@kukulich That solution disables fqn for all classes (for example \stdClass or \DateTimeImmutable).
I find rule for

  • disables fqn for global php functions (for example: \array_ke_exists() cannot be written)
  • disables using global php functions without placing them in the use section

without side effects.

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings