-
Notifications
You must be signed in to change notification settings - Fork 24
Add initial PHPStan config #212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
daa94ee
7217c5f
47d1809
3a2737f
5bff4a9
37dffc6
4b447b4
256f890
1091bfb
2a4171a
cb662f8
a1ae9f0
885b4fd
ac7a004
25afd31
96ae27a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| parameters: | ||
| level: 6 | ||
| paths: | ||
| - src | ||
| - doctor-command.php | ||
| scanDirectories: | ||
| - vendor/wp-cli/wp-cli/php | ||
| scanFiles: | ||
| - vendor/php-stubs/wordpress-stubs/wordpress-stubs.php | ||
| - tests/phpstan/scan-files.php | ||
| treatPhpDocTypesAsCertain: false | ||
| ignoreErrors: | ||
| - '#Call to deprecated method setAccessible\(\) of class ReflectionProperty\.#' | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,9 +26,9 @@ class Constant_Definition extends Check { | |
| /** | ||
| * Whether or not the constant is expected to be a falsy value. | ||
| * | ||
| * @var bool | ||
| * @var bool|null | ||
| */ | ||
| protected $falsy; | ||
| protected $falsy = null; | ||
|
|
||
| /** | ||
| * Expected value of the constant. | ||
|
|
@@ -39,6 +39,8 @@ class Constant_Definition extends Check { | |
|
|
||
| /** | ||
| * Initialize the constant check | ||
| * | ||
| * @param array<string, mixed> $options | ||
| */ | ||
| public function __construct( $options = array() ) { | ||
| parent::__construct( $options ); | ||
|
|
@@ -47,6 +49,9 @@ public function __construct( $options = array() ) { | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * @return void | ||
| */ | ||
| public function run() { | ||
|
|
||
| if ( isset( $this->falsy ) ) { | ||
|
|
@@ -99,7 +104,7 @@ public function run() { | |
| return; | ||
| } | ||
|
|
||
| if ( $this->defined && ! isset( $this->value ) ) { | ||
| if ( ! isset( $this->value ) ) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removing if ( $this->defined && ! isset( $this->value ) ) { |
||
| $this->set_status( 'success' ); | ||
| $this->set_message( "Constant '{$this->constant}' is defined." ); | ||
| return; | ||
|
|
@@ -118,12 +123,18 @@ public function run() { | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * @param mixed $value | ||
| * @return string | ||
| */ | ||
| private static function human_value( $value ) { | ||
| if ( true === $value ) { | ||
| $value = 'true'; | ||
| return 'true'; | ||
| } elseif ( false === $value ) { | ||
| $value = 'false'; | ||
| return 'false'; | ||
| } elseif ( is_null( $value ) ) { | ||
| return 'null'; | ||
| } | ||
| return $value; | ||
| return (string) $value; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Casting return is_scalar( $value ) ? (string) $value : json_encode( $value ); |
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,7 @@ abstract class File extends Check { | |
| /** | ||
| * File checks are run as their own group. | ||
| */ | ||
| protected $_when = false; | ||
| protected $_when = 'manual'; // Run manually via group | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changing protected $_when = false; |
||
|
|
||
| /** | ||
| * File extension to check. | ||
|
|
@@ -42,14 +42,14 @@ abstract class File extends Check { | |
| /** | ||
| * Any files matching the check. | ||
| * | ||
| * @var array | ||
| * @var array<string|\SplFileInfo> | ||
| */ | ||
| protected $_matches = array(); | ||
|
|
||
| /** | ||
| * Get the options for this check | ||
| * | ||
| * @return string | ||
| * @return array<string, bool|string> | ||
| */ | ||
| public function get_options() { | ||
| return array( | ||
|
|
@@ -58,4 +58,12 @@ public function get_options() { | |
| 'path' => $this->path, | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Check a specific file. | ||
| * | ||
| * @param \SplFileInfo $file File to check. | ||
| * @return void | ||
| */ | ||
| abstract public function check_file( \SplFileInfo $file ); | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.