Skip to content

PHPStan configuration #215

@swissspidy

Description

@swissspidy

Would be nice if we could use PHPStan here too.

We can start with level 1 and work our way up. Most basic phpstan.neon.dist file:

parameters:
  level: 1
  paths:
    - src
    - package-command.php
  scanDirectories:
    - vendor/wp-cli/wp-cli/php
  scanFiles:
    - vendor/php-stubs/wordpress-stubs/wordpress-stubs.php
  treatPhpDocTypesAsCertain: false

This yields:

------ ---------------------------------------------------------------------------------------------------
  Line   src/Package_Command.php
 ------ ---------------------------------------------------------------------------------------------------
  744    Class Composer\Repository\ComposerRepository constructor invoked with 3 parameters, 4-5 required.
  779    Variable $default_fields might not be defined.
  1002   Constant WP_CLI_VERSION not found.
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
  1077   Access to deprecated static property $stabilities of class Composer\Package\BasePackage.
 ------ ---------------------------------------------------------------------------------------------------

 ------ ------------------------------------------------------------------------------------------------------------
  Line   src/WP_CLI/JsonManipulator.php
 ------ ------------------------------------------------------------------------------------------------------------
  131    Fetching deprecated class constant PLATFORM_PACKAGE_REGEX of class Composer\Repository\PlatformRepository:
         use PlatformRepository::isPlatformPackage(string $name) instead
  251    Anonymous function has an unused use $name.
  387    Variable $childrenClean might not be defined.
  407    Variable $childrenClean might not be defined.
 ------ ------------------------------------------------------------------------------------------------------------

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions