-
Notifications
You must be signed in to change notification settings - Fork 61
Conversation
See #192 |
@webimpress sorry I miss this PR, BTW second commit still make sense ? |
no problem 👍
yeah, but... isset !== array_key_exists as you know, so in this case I can find failing test case, for example:
before we got Because of that, I think we need change the condition: if (is_array($this->variables)) {
if (array_key_exists($name, $this->variables)) {
return $this->variables[$name];
}
} elseif ($this->variables->offsetExists($this->variables)) {
return $this->variables[$name];
}
return $default; or something like that, haven't tested yet. Do you know what I mean? |
Yes, As I explain in initial description, there is some issue. In current code (so this trivial PR preserve current behavior, which is perhaps broken) |
@remicollet Ok, thanks, I'll have a look on it later on and will try to release bugfix version with PHP 7.4 compatibility later today. Thanks for your effort! |
fc0e69c
to
cd691f9
Compare
From PHP 7.4 docs: Calling get_object_vars() on an ArrayObject instance will now always return the properties of the ArrayObject itself (or a subclass). Previously it returned the values of the wrapped array/object unless the STD_PROP_LIST flag was specified. Other affected operations are: * ReflectionObject::getProperties() * reset(), current(), etc. Use Iterator methods instead. * Potentially others working on object properties as a list.
Added tests to verify the change.
@remicollet I've fixed other failing tests - see commit c711fbd. I've changed your fix to keep the previous behaviour and added tests to cover the fix. (BTW. yeah, I do not like it too much, but I don't want introduce BC break with the fix...) |
if (array_key_exists($name, $this->variables)) { | ||
return $this->variables[$name]; | ||
} | ||
} elseif ($this->variables->offsetExists($name)) { |
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.
Don't you want to check if this is an ArrayAccess
object first ?
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.
As I can see from the code (construct, setter...) it must be an array or Zend\View\Variables
(extends ArrayObject
), so I think no additional check is needed here.
|
||
if (empty($vars)) { | ||
echo "No object model passed"; | ||
} elseif (isset($vars['message'])) { | ||
echo $vars['message']; | ||
} else { | ||
$objKey = current($this->vars())->helper->getObjectKey(); | ||
$objKey = current($vars)->helper->getObjectKey(); |
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.
Nice,
This BC break on ArrayAccess object in 7.4 is terrible
Already bitten on another project, not easy to catch
FYI, according to Fedora CI, excepted zend-server, ZF seems in good shape for 7.4 |
Thanks, @remicollet! |
The second commit revels an issue with current code.
Zend\View\Variable
implementsArrayObject
butarray_key_exists
doesn't work in this case, as eplained in https://wiki.php.net/rfc/deprecations_php_7_4This PR is not complete, as with 7.4.0RC3 I still encounter an issue
There were 2 errors: