cakephp: __isset() Inconsistency
Description
According to the Entity Class documentation, __isset() “Returns whether this entity contains a field named $field regardless of if it is empty” (emphasis added). However, the actual implementation in EntityTrait calls $this->has() and the comment for __isset() says “Returns whether this entity contains a field named $field and is not set to null” (which is consistent for the behavior of has()).
Minimally, the documentation should be made consistent with the implementation, but better would be for __isset() to implement the functionality described in the API documentation. Otherwise, in order to tell if a null key is set it is necessary to jump through some hoops, such as first calling extract() or jsonSerialize().
CakePHP Version
4.2.9 and later
PHP Version
7.4.27
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15 (12 by maintainers)
You can also have a base entity and use a trait for what u need See e.g. https://github.com/dereuromark/cakephp-shim/blob/master/src/Model/Entity/ReadTrait.php If all entities extend that base class, a community plugin Version might suffice. Then core doesnt need to provide it