Fix unit tests failing on PHP nightly for the `WordPress.WP.I18n` sniff. #771

Merged
merged 1 commit into from Jan 5, 2017

Projects

None yet

2 participants

@jrfnl
Contributor
jrfnl commented Jan 5, 2017

This solves the following error:
An error occurred during processing; checking has been aborted. The error message was: "count(): Parameter must be an array or an object that implements Countable" at /home/travis/build/WordPress-Coding-Standards/WordPress-Coding-Standards/WordPress/Sniffs/WP/I18nSniff.php:233

array_shift() returns null if the array is empty or not an array which may have happened when less arguments where passed to the i18n function than expected.
In that case $tokens will be null and start throwing the countable error for PHP nightly.

@jrfnl jrfnl Fix unit tests failing on PHP nightly for the `WordPress.WP.I18n` sniff.
This solves the following error:
`An error occurred during processing; checking has been aborted. The error message was: "count(): Parameter must be an array or an object that implements Countable" at /home/travis/build/WordPress-Coding-Standards/WordPress-Coding-Standards/WordPress/Sniffs/WP/I18nSniff.php:233`

`array_shift()` returns null if the array is empty or not an array which may have happened when less arguments where passed to the i18n function then expected.
In that case `$tokens` will be null and start throwing the `countable` error for PHP nightly.
312e6bf
@JDGrimes JDGrimes merged commit 5f042dd into develop Jan 5, 2017

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
@JDGrimes JDGrimes deleted the feature/fix-i18n-vs-php-master branch Jan 5, 2017
@jrfnl jrfnl modified the milestone: 0.11.0 Jan 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment