-
Notifications
You must be signed in to change notification settings - Fork 242
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
[PHP] Fix some PHP 7.2 deprecations #1382
Conversation
@@ -1197,7 +1197,7 @@ static function processElementTransformationList( $tpl, &$node, $elements, &$pri | |||
static function processElementTransformationChild( $useComments, $php, $tpl, &$node, | |||
$elementTree, $elementList, &$resourceData ) | |||
{ | |||
$count = count( $elementList ); | |||
$count = $elementList instanceof Countable || is_array( $elementList ) ? count( $elementList ) : 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to doc count() returns 1 on non countable / arrays, but 0 on null. As variable is used as array beneath this is assuming 0 if not countable / array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use https://github.com/symfony/polyfill-php73 and its is_countable
method for this?
@@ -1197,7 +1197,7 @@ static function processElementTransformationList( $tpl, &$node, $elements, &$pri | |||
static function processElementTransformationChild( $useComments, $php, $tpl, &$node, | |||
$elementTree, $elementList, &$resourceData ) | |||
{ | |||
$count = count( $elementList ); | |||
$count = $elementList instanceof Countable || is_array( $elementList ) ? count( $elementList ) : 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use https://github.com/symfony/polyfill-php73 and its is_countable
method for this?
{ | ||
return -1; | ||
} | ||
else if ( $a == $b ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for else
lib/ezutils/classes/ezphpcreator.php
Outdated
@@ -565,7 +565,7 @@ function thisVariableText( $value, $column = 0, $iteration = 0, $maxIterations = | |||
$column += strlen( $text ); | |||
$valueKeys = array_keys( $value ); | |||
$isIndexed = true; | |||
for ( $i = 0; $i < count( $valueKeys ); ++$i ) | |||
for ($i = 0, $count = count($valueKeys); $i < $count; ++$i ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, unbalanced use of space-inside-parentheses.
lib/ezutils/classes/ezphpcreator.php
Outdated
@@ -676,7 +676,7 @@ static function variableText( $value, $column = 0, $iteration = 0, $maxIteration | |||
$column += strlen( $text ); | |||
$valueKeys = array_keys( $value ); | |||
$isIndexed = true; | |||
for ( $i = 0; $i < count( $valueKeys ); ++$i ) | |||
for ($i = 0, $count = count($valueKeys); $i < $count; ++$i ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unbalanced use of space-inside-parentheses.
0b94221
to
34bb333
Compare
Todo: