Skip to content

Roadmap #408

Open
Open
@jrfnl

Description

@jrfnl

These are preliminary roadmap notes for future PHPCSUtils versions

PHPCSUtils 1.1.0

  • Add utility method to retrieve an array with stack pointers + names of all constants declared in an OO structure. - PR ✨ New ObjectDeclarations::getDeclared*() utility methods #592
  • Add utility method to retrieve an array with stack pointers + names of all properties declared in an OO structure. - PR ✨ New ObjectDeclarations::getDeclared*() utility methods #592
  • Add utililty method to retrieve an array with stack pointers + names of all methods declared in an OO structure. - PR ✨ New ObjectDeclarations::getDeclared*() utility methods #592
  • Add utililty method to retrieve an array with stack pointers + names of all cases declared in an enum. - PR ✨ New ObjectDeclarations::getDeclared*() utility methods #592
  • Add utililty method to retrieve an array with stack pointers + names of all functions declared in a file in the current namespace (outside OO). (see Trackers)
  • Add utility class Constants for working with (OO) constant declarations. - PR ✨ New PHPCSUtils\Utils\Constants class + associated token collection #562
    Initial list of methods:
    • getMemberProperties(File $phpcsFile, int $stackPtr): array to retrieve the modifier information for an OO constant declaration, i.e. returns an array with is_final, final_token, visibility, visibility_token keys (can be false if visibility is not explicitly specified).
  • Add utility class TypeString for working with type declaration strings. - ✨ New TypeString utility class #588
    Preliminary list of methods:
    • isSingularType(string $typeString): bool
    • isComplexType(string $typeString): bool
    • isUnionType(string $typeString): bool
    • isIntersectionType(string $typeString): bool
    • isDNFType(string $typeString): bool (PHP 8.2+ disjunctive normal form)
    • getTypes(string $typeString): array to split a type string into its individual parts
      (Note to self: mind whitespace (and comments) within types! - Confirmed that BCFile, FunctionDeclarations and Variables methods return a type string without comments and whitespace)
    • getOOTypes(string $typeString): array to get only the OO names from a type string

PHPCSUtils 1.2.0

  • Add isUseOfGlobalConstant() method to determine whether an arbitrary name token (in PHPCS 3.x always T_STRING) is the use of a "global" constant, with the caveats that unless the constant is declared in the current file or imported via a use const statement, the method will not be able to distinguish between a global and a namespaced token when the constant is declared in the current namespace.
  • Add utililty class for resolving inline names to fully qualified names.
  • Add a number of "tracker" classes which keep track of certain information seen in a file, like seen namespaces, current namespace, seen use statements etc
    • NamespaceTracker
    • ImportUseTracker
    • DeclaredFunctionsTracker (non-OO)
  • Add abstract sniff classes for a couple of frequently occurring situations, like:
    • Detecting all places a certain class name is used (extends, new, instanceof, catch, use statements, type declarations etc).
    • Detecting all places a certain interface name is used (extends (for interface declarations), implements, instanceof, use statements, type declarations etc).
    • Detecting all places a certain function name is used (function calls, use function statements, maybe callbacks).
    • Detecting all places a certain constant name is used (constant use, use const statements).
    • Examining the parameters of function calls to a limited list of functions.

PHPCSUtils 1.3.0

  • Add utililty class to find the docblock for a construct, supporting all typical constructs which take docblocks (file, OO, function, constant, property, enum case, etc)
  • Add utililty class to work with docblock tags and their descriptions
  • Add utility class to work with inline comments

Future scope (version to be determined)

  • Improved version of the PHPCS native AbstractScopeSniff, i.e. more akin to AbstractDirectScope to allow for sniffs to run certain code for tokens in the global scope and other code for tokens in an OO/function scope.
  • Add abstract base test class for use by external standards:
    • Fully compatible with the functionality in the PHPCS native PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest.
    • Allow for running sniff class tests on PHPUnit 4.x - 9.x.
    • Allow for verifying that the correct error code(s) are being shown on each line expecting errors/warnings.
    • Allow for testing the error/warning messages.
    • Allow for testing the metrics.
    • Runs with a clean Config for each test class to prevent configuration directives set for one sniff influencing the tests for another.
  • NamingConventions: a set of methods to verify a "label name" (class, function etc) complies with certain naming conventions and methods to convert a label to a certain convention
  • Add abstract sniff class to examine callbacks
  • Add helper method to parse an enum declaration statement ?
  • Add TypeString::isValid(string $typeString): bool to verify that a type string is valid ?
    This could potentially check for things like:
    - Duplicate names/types in the type string
    - Nullability operator ? being used with complex types (should use |null)
    - Invalid types like resource being used ?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions