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

Use array_key_first() when judicious #2029

Open
wants to merge 1 commit into
base: 8.x
Choose a base branch
from

Conversation

deguif
Copy link
Collaborator

@deguif deguif commented Dec 1, 2021

No description provided.

@deguif deguif self-assigned this Dec 1, 2021
// add last action if available
if (isset($action)) {
$this->addAction($action);
if (Action::isValidOpType($opType)) {
Copy link
Owner

Choose a reason for hiding this comment

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

Nice rewrite. This old code was way too complicated!

$this->_data = \reset($data['nodes']);
$this->_id = \key($data['nodes']);
$this->getNode()->setId($this->getId());
if (null !== $nodeId = \array_key_first($data['nodes'])) {
Copy link
Owner

Choose a reason for hiding this comment

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

Trying to get my head around on what happened before when we didn't check furl null.

If there are no nodes, it is expected that we keep the old values or should these be overwritten with empty values?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You're right, I didn't think this case, when nodes can be empty

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.

2 participants