bcosca / fatfree

A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast!
2.66k stars 446 forks source link

Inconsistent Base::get and Base::set with __get and __set methods #1218

Closed gronostajo closed 3 years ago

gronostajo commented 3 years ago

I'm using F3 3.7.3. I have a class Config with __get and __set methods implemented. I'm assigning it to 'config' var and reading values from it successfully:

$f3->set('config', new Config());
echo $f3->get('config->foo');

This code ↑ will call magic __get correctly. Setting values through magic __set doesn't work though:

$f3->set('config->foo', 'bar');  // does nothing

Base::ref tries to grab and return a reference to non-existent property. It's later assigned in Base::set but __set is never called.

I can use $f3->get('config')->foo = 'bar' as a workaround, but it's inconsistent.

gronostajo commented 3 years ago

Correction: __get is working only in templates because they're complied into PHP. So it was my fault from the very beginning. Sorry for the confusion!