Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83679 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 18312 invoked from network); 24 Feb 2015 17:21:47 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Feb 2015 17:21:47 -0000 Authentication-Results: pb1.pair.com header.from=pencap@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=pencap@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.180 as permitted sender) X-PHP-List-Original-Sender: pencap@gmail.com X-Host-Fingerprint: 209.85.223.180 mail-ie0-f180.google.com Received: from [209.85.223.180] ([209.85.223.180:33780] helo=mail-ie0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B5/00-17473-923BCE45 for ; Tue, 24 Feb 2015 12:21:46 -0500 Received: by iecar1 with SMTP id ar1so33967759iec.0 for ; Tue, 24 Feb 2015 09:21:43 -0800 (PST) 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=GIRQazxLFqPmihJBDKqWUahfHOSN2PgVog6RXagsuDo=; b=nRIokTXqtGWwtwlrYQrTE1Z56EPl2BbzfkGCVRegeNxJsuPnBd69s+HMi+yBf3ca9h 73wzK161QjbhfCXsa7SlkrAOgSRwpFGmIcn5zAHSb2T1i0jHeEh5VEIc7v7GbBHk22vm WvRT0UfiWfEQEO8/TIoymaPwyMAKHpzsnQ4aw2r8rNndENw+GCWlvFG7ewi2CKkZ512Z P53IS9U+wzerv/JWcRp4RdXpKyFxpSK0h+UH8WKrjK5EAOC4DQ+hklyhyuMZwnStlXDU toZ4nlBNbFBJBOmlemmWiOaHaINDL/pAFdE9zcpNLqA+Ss0XiykuwneCj5SqTgc8SCBf SdVQ== MIME-Version: 1.0 X-Received: by 10.107.135.27 with SMTP id j27mr22323055iod.55.1424798503099; Tue, 24 Feb 2015 09:21:43 -0800 (PST) Received: by 10.64.125.33 with HTTP; Tue, 24 Feb 2015 09:21:42 -0800 (PST) In-Reply-To: References: Date: Tue, 24 Feb 2015 11:21:42 -0600 Message-ID: To: Philip Sturgeon Cc: PHP Internals Content-Type: multipart/alternative; boundary=001a113f90fca7651f050fd8c0e8 Subject: Re: [PHP-DEV] [RFC] Anonymous Classes From: pencap@gmail.com (Mike Willbanks) --001a113f90fca7651f050fd8c0e8 Content-Type: text/plain; charset=UTF-8 On Tue, Feb 24, 2015 at 7:52 AM, Philip Sturgeon wrote: > Good day! > > https://wiki.php.net/rfc/anonymous_classes > > There's a little RFC + patch that Joe Watkins put together, and as > before with the ArrayOf RFC, I'll be helping out. > > So, lets get this discussion rolling. > > It was declined for PHP 5 some time ago, and has returned now to try for > PHP 7. > > The usage of anonymous classes to some will be instantly offensive, > but really it comes down to the use case. The usage of anonymous > functions compared to declared functions is pretty much the exact same > thing as anonymous classes. > > Other than examples on the RFC, Fractal would certainly be happy to > have them: http://fractal.thephpleague.com/transformers/ I would also find myself to be a very happy consumer of this. It can provide the opportunity of getting rid of a large amount of boilerplate. In addition, there has been several times when implementing single use extensions for say view libraries (Plates extensions comes to mind) or Plugin handling for things like Zend Framework 2 and there has been several times I utilize a closure with an array to get around having an object simply due to you want to have a callback but with some form of definition. I think there is a very large use case here and something that would be a great addition to the language. Sure, I could make a class and extend it just like this would do but for the convenience of the implementation it is sometimes better to do a simple closure. Defining a class properly is certainly still going to be the majority > of uses of classes in PHP. That helps with the Optimizer, and helps > code reuse. > > Sadly due to the way in which people have had ONE CLASS ONE FILE > drilled into their head since PEAR and continuing through Zend and > PSR-0, it can become a PITA to add some simple functionality if a > small class is needed for one tiny thing. > I see the point here, but the argument to me seems void. Nothing wrong with a simple class one file for a small class. > > Anonymous functions alleviate that annoyance with a simple and > consistent feature that just give people a nice simple option to get > their jobs done, without hitting autoloaders and file systems to do > it. --001a113f90fca7651f050fd8c0e8--