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

Modifying existing array record does nothing. #71

Open
ursulnegrul opened this issue Nov 22, 2018 · 2 comments
Open

Modifying existing array record does nothing. #71

ursulnegrul opened this issue Nov 22, 2018 · 2 comments

Comments

@ursulnegrul
Copy link

ursulnegrul commented Nov 22, 2018

Steps to reproduce:
$db = new \DB\Cortex( new \DB\Jig( __DIR__ ), 'db.json' );

$db->myArray = array( 'a' => 1, 'b' => 2 );

$db->myArray['a'] = 3;

#Result:
$db->myArray['a'] === 1;

#Expected:
$db->myArray['a'] === 3;

#Ugly patch
$db->myArray = array_merge( $db->myArray, array( 'a' => 3 ) );

@ikkez
Copy link
Owner

ikkez commented Nov 28, 2018

I could probably fix that, but it would conflict with the feature of custom getter / setter functions and events. If i pass it by reference (and that's the point here in your example), every access to the variable would change the raw data at its origin, and as a result of this skip silently those events, making that feature inconsistent 🤔
So I'm not exactly sure how to deal with it right now.

@ursulnegrul
Copy link
Author

Take your time 👍 It was hard to spot the issue when I refactored from Jig to Cortex as most of my code was using arrays and since it was working before, seemed logical to work with Cortex too, until tested..

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

No branches or pull requests

2 participants