Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:91419 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 6587 invoked from network); 25 Feb 2016 18:33:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Feb 2016 18:33:00 -0000 Authentication-Results: pb1.pair.com header.from=derokorian@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=derokorian@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.53 as permitted sender) X-PHP-List-Original-Sender: derokorian@gmail.com X-Host-Fingerprint: 74.125.82.53 mail-wm0-f53.google.com Received: from [74.125.82.53] ([74.125.82.53:34957] helo=mail-wm0-f53.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C2/25-11730-BD84FC65 for ; Thu, 25 Feb 2016 13:32:59 -0500 Received: by mail-wm0-f53.google.com with SMTP id c200so41683561wme.0 for ; Thu, 25 Feb 2016 10:32:59 -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; bh=rJm3pDBrt5k9Ag86U32z43MG90B9ZFi19JnHRczjAL4=; b=YCiysy1Arp8j0O4xW5at/vYwniquCUwUj2Rcwa7FNNTom3czF3BrUBRgWhe6lRHcRx mGOfZWhUzm6sRTwLkcc0e6PLARMe+lqOA6BPK3eKmx6IKG1Qrsce4nGrzeJUtTQAS6DR cX6IZUXJEx1fEBPIrIa9eTtAFiF9F0lPZ4IGUa+pZANfwl+cXQGXF6BYKSxKETqzmOai DdoEfZB8aeCpf1NF2q3qDsVCEcXczi/xu2z27nPvYx9Fnb2UZRnGdNAHjCifS3jcmheu glAMgnPUhHU/7Sf2AMshbE632PPhkKoaawR64pGykg0Qf55JCxJ0wMShLI3RSLIWKXgb oCbA== 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:date :message-id:subject:from:to:cc; bh=rJm3pDBrt5k9Ag86U32z43MG90B9ZFi19JnHRczjAL4=; b=iKtIzAfWELT5kextFhuPV5lQKOnE047zDpRbFnDbnun/pw01ZZimWjH8u0Nfls42Ox uGX3gvP1jieJ0XFBHBpgBmm6calV+TzoRN1jFbQqV+lYhqx8kISbCr6yXOX7n36cY9go VQc+hFfBcunU3OokQuUMYYYRJhFVPOLNTzzUsqAE1D7EuXbzE5/1Lt7nJSZPH25mUXoU 3Pl291fDkSr9HRtKdNqqMPQ/LGSgfljyW4NOHPmc2VlCBouKB+W9VB1VzRzPqL1v3rti nUm2ULZ/GWSDnDHi/3KBLJ0Q4f/wJTYaNu6FpRqDOmVryUbEHhYB2wUmSZf9pP2cDW4X gkZg== X-Gm-Message-State: AG10YORMdGWua+vh6sCaHWQxSy6RC/rJR2pDuCG2I5E3sRDErgMsus2M1TBzc/EVIiPtvs+sj9FmUvhszyXNUw== MIME-Version: 1.0 X-Received: by 10.28.188.195 with SMTP id m186mr120021wmf.64.1456425176599; Thu, 25 Feb 2016 10:32:56 -0800 (PST) Received: by 10.28.68.215 with HTTP; Thu, 25 Feb 2016 10:32:56 -0800 (PST) In-Reply-To: References: Date: Thu, 25 Feb 2016 11:32:56 -0700 Message-ID: To: Marco Pivetta Cc: Dan Ackroyd , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a114b0bec4b1400052c9c6976 Subject: Re: [PHP-DEV] [RFC] Callable constructors From: derokorian@gmail.com (Ryan Pallas) --001a114b0bec4b1400052c9c6976 Content-Type: text/plain; charset=UTF-8 On Thu, Feb 25, 2016 at 11:31 AM, Ryan Pallas wrote: > > > On Thu, Feb 25, 2016 at 11:20 AM, Marco Pivetta > wrote: > >> Just adding to the use-cases: I really could've needed this the other day: >> >> >> $records = array_map([MyRecord::class, '__construct'], >> $db->someQuery()->fetchAll()); >> >> I used a named constructor instead, but this results with more internal >> method calls: >> >> $records = array_map([MyRecord::class, 'fromResultSetRow'], >> $db->someQuery()->fetchAll()); >> > > If fetchAll is coming from PDO. then you could have simply done this: > > $records = $db->someQuery()->fetchAll(MyRecord::class); > Sorry, that should have been $records = $db->someQuery()->fetchAll(PDO::FETCH_CLASS, $MyRecord::class); --001a114b0bec4b1400052c9c6976--