Hey Stas,
On 1 May 2016 at 00:14, Stanislav Malyshev wrote:

$def instanceof MyAnnotation; //TRUE
That looks fine, however the problem is that if MyAnnotation is a class,
then PHP does not have multiple inheritance, so it's the only class it
can be. And given that your class has no methods, $def has no methods
either and can not have any semantics besides simple data object. Which
begs the questions:

Note that an annotation usage here is basically a constructor call for a
concrete instance.
Still, this doesn't deny implementing interfaces for annotations, then
implementing those on the concrete annotation class.
I don't see the need for multiple inheritance therefore.

a) why it needs to be a class/object at all

Usually as a replacement for what you'd have as a "struct" in C.
Having a class definition provides some basic security on what is going on
(type-hints, etc).
You probably wouldn't ever have behavior on an annotation though, since it
is just a data structure: in fact, most of the existing annotations in PHP
userland libs are currently just classes with constructor+public properties.


Marco Pivetta



Search Discussions

Discussion Posts


Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 9 of 26 | next ›
Discussion Overview
groupphp-internals @
postedApr 30, '16 at 9:12p
activeMay 8, '16 at 3:54p



site design / logo © 2019 Grokbase