diff --git a/.gitignore b/.gitignore index a67d42b..cb291a4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ -composer.phar +# Composer /vendor/ -# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control -# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file -# composer.lock +# PHP Coding Standards Fixer +/.php-cs-fixer.cache diff --git a/CHANGELOG.md b/CHANGELOG.md index b53d6df..1adb86d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.2.0] - 2022-04-12 +### Changed +- We deviate from the WordPress Coding Standards and switch to the short array syntax. + ## [1.1.0] - 2022-02-17 ### Changed - Updated minimum WordPress version to `5.7`: https://codex.wordpress.org/Supported_Versions. @@ -27,6 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added relative exclude pattern `^wordpress/*` for the `wordpress` folder. - Added relative exclude pattern `^wp-content/*` for the `wp-content` folder. -[Unreleased]: https://github.com/pronamic/wp-coding-standards/compare/1.1.0...HEAD +[Unreleased]: https://github.com/pronamic/wp-coding-standards/compare/1.2.0...HEAD +[1.2.0]: https://github.com/pronamic/wp-coding-standards/compare/1.1.0...1.2.0 [1.1.0]: https://github.com/pronamic/wp-coding-standards/compare/1.0.0...1.1.0 [1.0.0]: https://github.com/pronamic/wp-coding-standards/releases/tag/1.0.0 diff --git a/PronamicWP/ruleset.xml b/PronamicWP/ruleset.xml index 3794a18..c5197c6 100644 --- a/PronamicWP/ruleset.xml +++ b/PronamicWP/ruleset.xml @@ -72,4 +72,9 @@ + + + + + diff --git a/README.md b/README.md index 8d25766..1e6984b 100644 --- a/README.md +++ b/README.md @@ -127,4 +127,20 @@ Filenames should be all lowercase with hyphens as word separators. Expected test We often use the [PSR-4](https://www.php-fig.org/psr/psr-4/) autoloading mechanism and therefore deviate from it. +### `Generic.Arrays.DisallowShortArraySyntax` + +According to the WordPress PHP Coding Standards: + +> Using long array syntax ( `array( 1, 2, 3 )` ) for declaring arrays is generally more readable than short array syntax ( `[ 1, 2, 3 ]` ), particularly for those with vision difficulties. Additionally, it’s much more descriptive for beginners. +> +> Arrays must be declared using long array syntax. + +_Source:_ https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/#declaring-arrays + +This change can be done using [PHP Coding Standards Fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer): + +``` +php-cs-fixer fix --rules @PHP54Migration ./src/ +``` + [![Pronamic - Work with us](https://github.com/pronamic/brand-resources/blob/main/banners/pronamic-work-with-us-leaderboard-728x90%404x.png)](https://www.pronamic.eu/contact/) diff --git a/composer.json b/composer.json index 27dfd31..f681ad7 100644 --- a/composer.json +++ b/composer.json @@ -43,5 +43,10 @@ "squizlabs/php_codesniffer": "^3.6", "wp-coding-standards/wpcs": "^2.3" }, - "prefer-stable": true + "prefer-stable": true, + "scripts": { + "test": [ + "vendor/bin/phpcs --standard=PronamicWP tests/test.php" + ] + } } diff --git a/tests/test.php b/tests/test.php new file mode 100644 index 0000000..575d654 --- /dev/null +++ b/tests/test.php @@ -0,0 +1,12 @@ +