Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:76433 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 42421 invoked from network); 11 Aug 2014 16:43:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Aug 2014 16:43:36 -0000 Authentication-Results: pb1.pair.com smtp.mail=are.you.winning@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=are.you.winning@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.192.42 as permitted sender) X-PHP-List-Original-Sender: are.you.winning@gmail.com X-Host-Fingerprint: 209.85.192.42 mail-qg0-f42.google.com Received: from [209.85.192.42] ([209.85.192.42:44502] helo=mail-qg0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7F/03-22956-7B2F8E35 for ; Mon, 11 Aug 2014 12:43:35 -0400 Received: by mail-qg0-f42.google.com with SMTP id j5so8590416qga.15 for ; Mon, 11 Aug 2014 09:44:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=b354OOoK10UnOS+OJC1uKKWlRB2Aja69KYe31VyX3Ww=; b=fZyaV+L+h/WiGXSOhnlvMSAlS0mR3yzuaGOsCpByu24qPYo1xANGKLsebWauA1XSh9 tEyqg/rNuLvCIb2XCF+cP0EeveAibWuWkw3/7jqLrYV92boUtA1dWfh5yMy911mUdGC8 Y6efYI8lQUVYBr0h4v4gltvrqkgUYmGoFv4/OBuPE03P3ZiQ/0rnAIf3jb/KmSPRhdNh XewC4mKupn181iD6/LOXOfUSQM79661UfDxoUt4phIkvdnALWYwCcA8btr1MhW1aWGIj 8/3u9hmSOlWOvgj9qaIU5ZAn4mTfizhF3CexQqYmfRVsRs5tekSSgg0rWGAxJChSgHPp y/GQ== MIME-Version: 1.0 X-Received: by 10.140.30.73 with SMTP id c67mr49772037qgc.16.1407775454107; Mon, 11 Aug 2014 09:44:14 -0700 (PDT) Sender: are.you.winning@gmail.com Received: by 10.229.64.196 with HTTP; Mon, 11 Aug 2014 09:44:14 -0700 (PDT) In-Reply-To: References: Date: Mon, 11 Aug 2014 17:44:14 +0100 X-Google-Sender-Auth: p4Gs98s4usnBhQSsExyV8xTz58A Message-ID: To: Julien Pauli Cc: Ferenc Kovacs , Tom Oram , PHP Internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Reflection to remove final From: cw@daverandom.com (Chris Wright) On 11 August 2014 17:09, Julien Pauli wrote: > On Mon, Aug 11, 2014 at 12:59 PM, Ferenc Kovacs wrote: >> On Sat, Aug 9, 2014 at 12:35 PM, Tom Oram wrote: >> >>> I've just been looking back at the history of this previous conversation... >>> >>> http://marc.info/?l=php-internals&m=132673741606531&w=2 >>> >>> as a mockist tester I'd really REALLY like to see this be possible but I >>> can see the problem with the original patch modifying the actual existing >>> class. >>> >>> One solution I propose is rather than modify it would it be possible for >>> the reflection class to be able to duplicate the class with the finals >>> removed so something like this could be possible: >>> >>> final class A >>> { >>> } >>> >>> $r = new ReflectionClass('A'); >>> >>> $r->defineExtendableClass('ExtendableA'); >>> >>> class MockA extends ExtendabledA >>> { >>> } >>> >>> I'm unfamiliar with the PHP codebase so I thought I'd just ask here to find >>> out if it sounds possible before diving into the code >>> >>> Thoughts? >>> >>> Regards, >>> Tom > > > Supporting this at an engine level would be harder than you think. > > We already had lots of difficulties patching > newInstanceWithoutConstructor() to support internal classes (5.6) > because they've never been designed to support creation without the > call to their constructor. > > Removing (or giving a way to remove) FINAL should be OK for userland > classes, but that will be hard to support for internal classes and > would require lots of work. Some of them could even never support it. I don't think that it even makes sense to have this as a possibility for internal classes. tbh I doubt it makes sense to do it in userland either (class shouldn't have been declared final in the first place) but there may some testing applications that are not immediately apparent to me, as implied by the code sample in the original mail. If such a feature were to be implemented as part of reflection as suggested (I'm not a fan), not supporting internal classes would be totally acceptable IMO.