Skip to content
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

Change logic for finding plugin slug in CLI #367

Merged
merged 2 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions includes/Checker/CLI_Runner.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,19 @@ public static function is_plugin_check() {
* @throws Exception Thrown if the plugin parameter is empty.
*/
protected function get_plugin_param() {
// Get the plugin parameter from the command line arguments.
$plugin = isset( $_SERVER['argv'][3] ) ? $_SERVER['argv'][3] : '';
// Exclude first three reserved elements.
$params = array_slice( $_SERVER['argv'], 3 );

// Remove associative arguments.
$params = array_filter(
$params,
static function ( $val ) {
return ! str_starts_with( $val, '--' );
}
);

// Use only first element. We dont support checking multiple plugins at once yet!
$plugin = count( $params ) > 0 ? reset( $params ) : '';

if ( empty( $plugin ) ) {
throw new Exception(
Expand Down
3 changes: 3 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ parameters:
- includes/Checker/Checks/Plugin_Readme_Check.php
- includes/Traits/Find_Readme.php
- includes/Traits/File_Editor_URL.php
-
message: '/^Function str_starts_with not found.$/'
path: includes/Checker/CLI_Runner.php
Loading