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

Indirect modification #84

Open
arokettu opened this issue Jul 9, 2018 · 2 comments
Open

Indirect modification #84

arokettu opened this issue Jul 9, 2018 · 2 comments

Comments

@arokettu
Copy link

arokettu commented Jul 9, 2018

Currently you cannot modify arrays that are set as view variables

$view->a = [];
$view->a[] = 1; // PHP Notice:  Indirect modification of overloaded property Aura/View/View::$a has no effect
var_dump($view->a); // empty array

is it a bug or expected behavior?

The fix is simple:
return field by reference

public function &__get($key)

I can make pr if you agree that it's a bug

@harikt
Copy link
Member

harikt commented Jul 18, 2018

@sandfoxme I believe if you keep an array to view you should not alter the data.

@arokettu
Copy link
Author

@harikt I don't claim that that code is good :) I encountered this bug when upgrading from legacy Zend1 code. Still, the behavior is very unexpected and non intuitive. Also, there is no problem with all other data types

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

No branches or pull requests

2 participants