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

Array declaration sniff should account for places where WP expects mixed key/no-key arrays #146

Closed
JDGrimes opened this issue Dec 27, 2013 · 2 comments

Comments

@JDGrimes
Copy link
Contributor

The array syntax sniff will report when an array has some values assigned specific keys and others not.

314 | WARNING | No key specified for array entry; first entry specifies key
| | (WordPress.Arrays.ArrayDeclaration)

This causes a problem where WordPress requires mixed arrays, as in the 'meta_query' argument for WP_Query:

$args = array(
    'post_type' => 'product',
    'meta_query' => array(
        'relation' => 'OR', // 'relation' key used to specify AND/OR, the rest are numeric
        array(
            'key' => 'color',
            'value' => 'blue',
            'compare' => 'NOT LIKE'
        ),
        array(
            'key' => 'price',
            'value' => array( 20, 100 ),
            'type' => 'numeric',
            'compare' => 'BETWEEN'
        )
    )
);
$query = new WP_Query( $args );

The sniff should probably ignore any key if its text is 'related'.

@westonruter
Copy link
Member

It seems we should eliminate this warning from the sniff. There is actually no reference to a forbidden mixing of explicit keys and implied numerical keys in the WordPress Coding Standards: http://make.wordpress.org/core/handbook/coding-standards/php/

@shadyvb
Copy link
Contributor

shadyvb commented Jul 11, 2014

@westonruter Just commented that problematic warning in #204

jrfnl added a commit to jrfnl/WordPress-Coding-Standards that referenced this issue Apr 22, 2022
Using the `dealerdirect/phpcodesniffer-composer-installer` Composer plugin is recommended to register external PHPCS standards with PHPCS.

As of Composer 2.2.0, Composer plugins need to be explicitly allowed to run.

This commit:
* Adds the necessary configuration for that to the `composer.json` for this project.
* Adds the CLI command to set those permissions to the installation instructions for consumer projects.

Includes updating the URL references to the plugin to point to the new home of the plugin. (see [upstream issue WordPress#146](PHPCSStandards/composer-installer#146))

Refs:
* https://blog.packagist.com/composer-2-2/#more-secure-plugin-execution
jrfnl added a commit to jrfnl/WordPress-Coding-Standards that referenced this issue Apr 22, 2022
Using the `dealerdirect/phpcodesniffer-composer-installer` Composer plugin is recommended to register external PHPCS standards with PHPCS.

As of Composer 2.2.0, Composer plugins need to be explicitly allowed to run.

This commit:
* Adds the necessary configuration for that to the `composer.json` for this project.
* Adds the CLI command to set those permissions to the installation instructions for consumer projects.

Includes updating the URL references to the plugin to point to the new home of the plugin. (see [upstream issue WordPress#146](PHPCSStandards/composer-installer#146))

Refs:
* https://blog.packagist.com/composer-2-2/#more-secure-plugin-execution
jrfnl added a commit to jrfnl/WordPress-Coding-Standards that referenced this issue Apr 26, 2022
Using the `dealerdirect/phpcodesniffer-composer-installer` Composer plugin is recommended to register external PHPCS standards with PHPCS.

As of Composer 2.2.0, Composer plugins need to be explicitly allowed to run.

This commit:
* Adds the necessary configuration for that to the `composer.json` for this project.
* Adds the CLI command to set those permissions to the installation instructions for consumer projects.

Includes updating the URL references to the plugin to point to the new home of the plugin. (see [upstream issue WordPress#146](PHPCSStandards/composer-installer#146))

Refs:
* https://blog.packagist.com/composer-2-2/#more-secure-plugin-execution
jrfnl added a commit to jrfnl/WordPress-Coding-Standards that referenced this issue May 15, 2022
Using the `dealerdirect/phpcodesniffer-composer-installer` Composer plugin is recommended to register external PHPCS standards with PHPCS.

As of Composer 2.2.0, Composer plugins need to be explicitly allowed to run.

This commit:
* Adds the necessary configuration for that to the `composer.json` for this project.
* Adds the CLI command to set those permissions to the installation instructions for consumer projects.

Includes updating the URL references to the plugin to point to the new home of the plugin. (see [upstream issue WordPress#146](PHPCSStandards/composer-installer#146))

Refs:
* https://blog.packagist.com/composer-2-2/#more-secure-plugin-execution
jrfnl added a commit to jrfnl/WordPress-Coding-Standards that referenced this issue Jun 17, 2022
Using the `dealerdirect/phpcodesniffer-composer-installer` Composer plugin is recommended to register external PHPCS standards with PHPCS.

As of Composer 2.2.0, Composer plugins need to be explicitly allowed to run.

This commit:
* Adds the necessary configuration for that to the `composer.json` for this project.
* Adds the CLI command to set those permissions to the installation instructions for consumer projects.

Includes updating the URL references to the plugin to point to the new home of the plugin. (see [upstream issue WordPress#146](PHPCSStandards/composer-installer#146))

Refs:
* https://blog.packagist.com/composer-2-2/#more-secure-plugin-execution
jrfnl added a commit to jrfnl/WordPress-Coding-Standards that referenced this issue Jun 17, 2022
Using the `dealerdirect/phpcodesniffer-composer-installer` Composer plugin is recommended to register external PHPCS standards with PHPCS.

As of Composer 2.2.0, Composer plugins need to be explicitly allowed to run.

This commit:
* Adds the necessary configuration for that to the `composer.json` for this project.
* Adds the CLI command to set those permissions to the installation instructions for consumer projects.

Includes updating the URL references to the plugin to point to the new home of the plugin. (see [upstream issue WordPress#146](PHPCSStandards/composer-installer#146))

Refs:
* https://blog.packagist.com/composer-2-2/#more-secure-plugin-execution
jrfnl added a commit to jrfnl/WordPress-Coding-Standards that referenced this issue Jun 25, 2022
Using the `dealerdirect/phpcodesniffer-composer-installer` Composer plugin is recommended to register external PHPCS standards with PHPCS.

As of Composer 2.2.0, Composer plugins need to be explicitly allowed to run.

This commit:
* Adds the necessary configuration for that to the `composer.json` for this project.
* Adds the CLI command to set those permissions to the installation instructions for consumer projects.

Includes updating the URL references to the plugin to point to the new home of the plugin. (see [upstream issue WordPress#146](PHPCSStandards/composer-installer#146))

Refs:
* https://blog.packagist.com/composer-2-2/#more-secure-plugin-execution
jrfnl added a commit to jrfnl/WordPress-Coding-Standards that referenced this issue Jul 22, 2022
Using the `dealerdirect/phpcodesniffer-composer-installer` Composer plugin is recommended to register external PHPCS standards with PHPCS.

As of Composer 2.2.0, Composer plugins need to be explicitly allowed to run.

This commit:
* Adds the necessary configuration for that to the `composer.json` for this project.
* Adds the CLI command to set those permissions to the installation instructions for consumer projects.

Includes updating the URL references to the plugin to point to the new home of the plugin. (see [upstream issue WordPress#146](PHPCSStandards/composer-installer#146))

Refs:
* https://blog.packagist.com/composer-2-2/#more-secure-plugin-execution
jrfnl added a commit to jrfnl/WordPress-Coding-Standards that referenced this issue Aug 7, 2022
Using the `dealerdirect/phpcodesniffer-composer-installer` Composer plugin is recommended to register external PHPCS standards with PHPCS.

As of Composer 2.2.0, Composer plugins need to be explicitly allowed to run.

This commit:
* Adds the necessary configuration for that to the `composer.json` for this project.
* Adds the CLI command to set those permissions to the installation instructions for consumer projects.

Includes updating the URL references to the plugin to point to the new home of the plugin. (see [upstream issue WordPress#146](PHPCSStandards/composer-installer#146))

Refs:
* https://blog.packagist.com/composer-2-2/#more-secure-plugin-execution
jrfnl added a commit to jrfnl/WordPress-Coding-Standards that referenced this issue Aug 10, 2022
Using the `dealerdirect/phpcodesniffer-composer-installer` Composer plugin is recommended to register external PHPCS standards with PHPCS.

As of Composer 2.2.0, Composer plugins need to be explicitly allowed to run.

This commit:
* Adds the necessary configuration for that to the `composer.json` for this project.
* Adds the CLI command to set those permissions to the installation instructions for consumer projects.

Includes updating the URL references to the plugin to point to the new home of the plugin. (see [upstream issue WordPress#146](PHPCSStandards/composer-installer#146))

Refs:
* https://blog.packagist.com/composer-2-2/#more-secure-plugin-execution
jrfnl added a commit to jrfnl/WordPress-Coding-Standards that referenced this issue Aug 12, 2022
Using the `dealerdirect/phpcodesniffer-composer-installer` Composer plugin is recommended to register external PHPCS standards with PHPCS.

As of Composer 2.2.0, Composer plugins need to be explicitly allowed to run.

This commit:
* Adds the necessary configuration for that to the `composer.json` for this project.
* Adds the CLI command to set those permissions to the installation instructions for consumer projects.

Includes updating the URL references to the plugin to point to the new home of the plugin. (see [upstream issue WordPress#146](PHPCSStandards/composer-installer#146))

Refs:
* https://blog.packagist.com/composer-2-2/#more-secure-plugin-execution
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants