*/
protected $keys = array();
+ /**
+ * @var mixed $value Need to keep it here because it became private for PHPUnit 7.x and up
+ */
+ protected $capturedvalue;
+
+ /**
+ * Override constructor to capture value
+ */
+ public function __construct($value, float $delta = 0.0, int $maxDepth = 10, bool $canonicalize = false, bool $ignoreCase = false) {
+ parent::__construct($value, $delta, $maxDepth, $canonicalize, $ignoreCase);
+ $this->capturedvalue = $value;
+ }
+
/**
* Add an exception for the named key to use a different comparison
* method. Any assertion provided by PHPUnit\Framework\Assert is
*/
public function evaluate($other, $description = '', $shouldreturnesult = false) {
foreach ($this->keys as $key => $comparison) {
- if (isset($other->$key) || isset($this->value->$key)) {
+ if (isset($other->$key) || isset($this->capturedvalue->$key)) {
// One of the keys is present, therefore run the comparison.
- PHPUnit\Framework\Assert::$comparison($this->value->$key, $other->$key);
+ PHPUnit\Framework\Assert::$comparison($this->capturedvalue->$key, $other->$key);
// Unset the keys, otherwise the standard evaluation will take place.
unset($other->$key);
- unset($this->value->$key);
+ unset($this->capturedvalue->$key);
}
}