Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93028 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 98265 invoked from network); 2 May 2016 06:12:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 May 2016 06:12:39 -0000 Authentication-Results: pb1.pair.com smtp.mail=ocramius@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ocramius@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.53 as permitted sender) X-PHP-List-Original-Sender: ocramius@gmail.com X-Host-Fingerprint: 209.85.215.53 mail-lf0-f53.google.com Received: from [209.85.215.53] ([209.85.215.53:34675] helo=mail-lf0-f53.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D1/E7-03860-6DFE6275 for ; Mon, 02 May 2016 02:12:38 -0400 Received: by mail-lf0-f53.google.com with SMTP id m64so23935841lfd.1 for ; Sun, 01 May 2016 23:12:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=04T9moWwKLgSRLpPDeJ6zR3vYctSBkEtAyQKGUB7/Uk=; b=xY/ZwfK5tGRyTx0pFXxi9mLQzYzO5ud7bnb2BnxsD6ONg6LAjoGyeu94W5Cl4RlFfi iJiMCoEkjusIe/hfntEbCal+EH3ArD42ES2EvwKJw7lee70+25xtX01G4mQ9vAW8SxY0 AeFDUPGQM2HnWSmF+dSE39ZHKNNMBZ0E8asnCMG2IvBBxUDn+GDFmi1nWaeDFZCmsh0y U1rtO7Kwirzr5sOide5cKWLGnygUN6tdqKcMTnpQ5Vb7NO/wCFgckPiZiY1DZPbSXD23 kx5vuSZAXEunbeixBdZoKJa84BlO9gDBoRPUk1fbYy9vM5M4uOVpmEfDLHHlhDb+nJBJ QEAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=04T9moWwKLgSRLpPDeJ6zR3vYctSBkEtAyQKGUB7/Uk=; b=MmwIbINfxxTBq5vmHoIvtaPXWmJ6aWQqloIF4piX3X9uRgCygIxH8Nvke30aYbC8Ya R65PvhD2Qwtuvd/BEj+A0w1RIR7+3MO6gU1KHRApS5utvdocHNQhBkgwYIf/vP9I/9gX KpNpOPI4oCq3omWjW0kAafuc1OG8zS3Lpf4xPCmA01zYf0W0ihweCVSQa+AYDsBe+/uO DNtZjMAdUcsC+mS8WsbocmkLLMa2ACJpo3EBr16vJEukHrHC50ypOSjI+DHiVPF4jC0E xQ2G/2ejmRNZ6FqoIvrXM56YKs8La1129BnGeDn/d3uZQh6w5bH10FXZlXUx//if1jY/ ozOw== X-Gm-Message-State: AOPr4FXDPjzKZ55OY1Sk6AT0OLkvKca1ux5n30QyQoy/nmV+LtFVkNY3GefRPIWEkZV7/cgIEFuNMCSu6N6f7Q== X-Received: by 10.25.24.35 with SMTP id o35mr14385192lfi.25.1462169555713; Sun, 01 May 2016 23:12:35 -0700 (PDT) MIME-Version: 1.0 Received: by 10.112.126.67 with HTTP; Sun, 1 May 2016 23:12:16 -0700 (PDT) In-Reply-To: <8e4ed849-f504-fe80-3c5f-e4ea114e99fa@gmail.com> References: <5723F2AE.2020806@garfieldtech.com> <572529F2.9070606@garfieldtech.com> <8e4ed849-f504-fe80-3c5f-e4ea114e99fa@gmail.com> Date: Mon, 2 May 2016 08:12:16 +0200 Message-ID: To: Stanislav Malyshev Cc: Larry Garfield , PHP Internals List Content-Type: multipart/alternative; boundary=001a11401642f8444f0531d5e010 Subject: Re: [PHP-DEV] Attributes/Annotations Case Study: Drupal From: ocramius@gmail.com (Marco Pivetta) --001a11401642f8444f0531d5e010 Content-Type: text/plain; charset=UTF-8 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. Cheers, Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ --001a11401642f8444f0531d5e010--