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

[PHP] Fix some PHP 7.2 deprecations #1382

Merged
merged 6 commits into from
Aug 15, 2018
Merged

[PHP] Fix some PHP 7.2 deprecations #1382

merged 6 commits into from
Aug 15, 2018

Conversation

andrerom
Copy link
Contributor

@andrerom andrerom commented Aug 13, 2018

Todo:

  • Testing
  • Review

@@ -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;
Copy link
Contributor Author

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.

Copy link
Collaborator

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;
Copy link
Collaborator

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 )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for else

@@ -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 )
Copy link
Member

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.

@@ -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 )
Copy link
Member

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.

@andrerom andrerom changed the base branch from master to 2017.12 August 14, 2018 08:56
@andrerom andrerom merged commit 6321a92 into 2017.12 Aug 15, 2018
@andrerom andrerom deleted the php_deprecations branch August 15, 2018 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants