Hi Michael,
On 4 September 2020 18:03:29 BST, "Michael Voříšek - ČVUT FEL"
<[email protected]> wrote:
>Ideally, we should introduce __exist() which should return true even if
>value is null
Magic methods in PHP allow the user to overload some built-in operator or
behaviour, so it doesn't make sense to talk about a new magic method in terms
of how users are expected to implement it without first describing what
built-in functionality it overloads.
Is the idea that $foo->__exists($bar) would be called when running
property_exists($foo, $bar)?
If so I suspect most cases would be clearer if they used some context-specific
interface with a well-named method. For instance:
interface SomeORM\DynamicDBModel {
public function hasColumn($columnName): bool;
}
A notable difference from __isset is that you can write isset($foo->bar)
without having 'bar' as a string value, which AFAIK is not possible with
"exists".
Regards,
--
Rowan Tommins
[IMSoP]