Skip to content

Commit

Permalink
Merge pull request #360 from jrfnl/feature/execution-directive-effici…
Browse files Browse the repository at this point in the history
…ency-tweak

NewExecutionDirectives sniff: minor efficiency tweak.
  • Loading branch information
wimg committed Feb 28, 2017
2 parents c9568ea + 80ac8aa commit 824b81c
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions Sniffs/PHP/NewExecutionDirectivesSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ protected function isNumeric($value)


/**
* Check whether a value is valid encoding.
* Check whether a value is a valid encoding.
*
* Callback function to test whether the value for an execution directive is valid.
*
Expand All @@ -316,22 +316,17 @@ protected function isNumeric($value)
*/
protected function validEncoding($value)
{
$encodings = array();
if (function_exists('mb_list_encodings')) {
static $encodings;
if (isset($encodings) === false && function_exists('mb_list_encodings')) {
$encodings = mb_list_encodings();
}

if (empty($encodings)) {
if (empty($encodings) || is_array($encodings) === false) {
// If we can't test the encoding, let it pass through.
return true;
}

if (in_array($value, $encodings, true)) {
return true;
}
else {
return false;
}
return in_array($value, $encodings, true);
}


Expand Down

0 comments on commit 824b81c

Please sign in to comment.