phramework / jsonapi

jsonapi implementation for phramework
https://phramework.github.io/jsonapi/
Apache License 2.0
4 stars 2 forks source link

empty() behaviour in Filter properties #33

Open nohponex opened 8 years ago

nohponex commented 8 years ago

empty($filter->primary) is not working as expected, same applies for classes with magic properties

Solution:

https://stackoverflow.com/questions/2045791/php-empty-on-get-accessor

Based on a reading of the empty's manual page and comments (Ctrl-F for isset and/or double underscores), it looks like this is known behavior, and if you want your set and get methods and empty to play nice together, there's an implicit assumption that you implement a __isset magic method as well.