Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:84678 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 4853 invoked from network); 13 Mar 2015 12:08:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Mar 2015 12:08:49 -0000 Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.177 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.212.177 mail-wi0-f177.google.com Received: from [209.85.212.177] ([209.85.212.177:46081] helo=mail-wi0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7B/11-32208-F43D2055 for ; Fri, 13 Mar 2015 07:08:48 -0500 Received: by wiwh11 with SMTP id h11so5371657wiw.5 for ; Fri, 13 Mar 2015 05:08:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=zI8e4CiuWiYlvS196YR7K2HIv0fnjkVh7RKNJ9Yt0h8=; b=nnTh6RiLMkoBSXwfYH/ErtPD7q90K3ZPHuSfdgkyorDRJureBnKdXfN2Hc1f00LwuA maEb9xU/QSHRO1LaNF1VzMPtAcgicRedSQkqORFfBAAaX28O4R9iGTLj4jnVgeq2iVaY rnbjNcRKsaujEKItTatSbi6YbFKE90IgOLIXly7p1j0wcSEEJ4cNCmIPRiv+CAlL7xzs Km6NBi1b/Kj8MKlK/ycG0nB8rw2Ow1G0qycJalAwW6epRfl3YjyYDKY7FHR8fdmurCPd JdqnYS/sO2u0HaiuJmdtDSZkyWrju/e/VDHGcvD2r3KIzCaSP+QyoCoAR2l0Zqp7ehR4 kVHA== MIME-Version: 1.0 X-Received: by 10.180.97.106 with SMTP id dz10mr95286492wib.33.1426248525004; Fri, 13 Mar 2015 05:08:45 -0700 (PDT) Received: by 10.27.10.193 with HTTP; Fri, 13 Mar 2015 05:08:44 -0700 (PDT) In-Reply-To: References: Date: Fri, 13 Mar 2015 13:08:44 +0100 Message-ID: To: =?UTF-8?B?0JDQvdC00YDQtdC5INCa0LvRjtC10LI=?= Cc: PHP internals Content-Type: multipart/alternative; boundary=f46d0442712eb1c69005112a5c38 Subject: Re: [PHP-DEV] Behavior of classes type hinting together with the error handler From: nikita.ppv@gmail.com (Nikita Popov) --f46d0442712eb1c69005112a5c38 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Fri, Mar 13, 2015 at 12:48 PM, =D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9 =D0= =9A=D0=BB=D1=8E=D0=B5=D0=B2 wrote: > Hello internals! My name is Andrew and I write php literally since > childhood (something around 10 years), > now PHP - is my profession. > And today once again debugging foreign code, I was ready to go to the > hospital to see a psychiatrist. > First, some of the code: > Do you think that can output this feature? > > function test(A $a) > { > var_dump(get_class($a)); > } > > I always thought that only 'string (1) "A"', I have never been so wrong > (c). > > The code below will display 'string (1) "B"' > > class A { > } > > class B { > public $id =3D 1; > } > > set_error_handler(function () { > return true; > }); > > function test(A $a) > { > var_dump(get_class($a)); > } > > test(new B()); > > I think this is very unexpected behavior, and suggest you to consider the > possibility of removing this behavior in PHP7. > It has already been dropped by https://wiki.php.net/rfc/engine_exceptions_for_php7 :) As a side node, an "A $a" typehint does not make sure that get_class($a) =3D=3D=3D 'A', only that $a instanceof A. Nikita --f46d0442712eb1c69005112a5c38--