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

Fix regression with self-referencing arrays handling #2638

Conversation

julienfalque
Copy link
Contributor

Fixes a regression introduced with #2620: when arrays mix objects with scalars, it produces errors such as:

Object of class Foo could not be converted to int

@keradus
Copy link
Contributor

keradus commented Apr 2, 2017

new tests are always nice, not sure about replacing existing test, especially when you drop some of assertions

@@ -2441,7 +2441,7 @@ private function registerMockObjectsFromTestArguments(array $testArguments, arra
}

$this->registerMockObject($testArgument);
} elseif (is_array($testArgument) && !in_array($testArgument, $visited)) {
} elseif (is_array($testArgument) && !in_array($testArgument, $visited, true)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nice fix

@sebastianbergmann , would you consider applying strictness for is_array globally ?

@julienfalque julienfalque force-pushed the self-referencing-array-regression branch from 8e682c9 to 79beff6 Compare April 2, 2017 22:25
@codecov-io
Copy link

codecov-io commented Apr 2, 2017

Codecov Report

Merging #2638 into 5.7 will increase coverage by 0.11%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##                5.7    #2638      +/-   ##
============================================
+ Coverage     52.01%   52.13%   +0.11%     
  Complexity     2907     2907              
============================================
  Files           110      110              
  Lines          7761     7761              
============================================
+ Hits           4037     4046       +9     
+ Misses         3724     3715       -9
Impacted Files Coverage Δ Complexity Δ
src/Framework/TestCase.php 54.88% <100%> (+1.06%) 315 <0> (ø) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c6884c0...d91324b. Read the comment docs.

@julienfalque
Copy link
Contributor Author

Reverted original test and added mine as a new one.

@@ -671,4 +671,20 @@ private function getAutoreferencedArray()
]
];
}

public function testProvidingOfSelfReferencingArray()
Copy link
Contributor

@keradus keradus Apr 2, 2017

Choose a reason for hiding this comment

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

what's the difference between autoreferenced array and selfreferencing one?
no need for testing $arr[] = &$arr here as well, as it's tested in previous test

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed the new test and removed self-reference from the array.

@julienfalque julienfalque force-pushed the self-referencing-array-regression branch from 79beff6 to d91324b Compare April 2, 2017 22:36
@sebastianbergmann sebastianbergmann merged commit ff57ea9 into sebastianbergmann:5.7 Apr 3, 2017
@sebastianbergmann
Copy link
Owner

Thanks!

@julienfalque julienfalque deleted the self-referencing-array-regression branch April 3, 2017 06:04
@SpacePossum
Copy link
Contributor

thanks @julienfalque , nice fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants