Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:95674 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 54193 invoked from network); 5 Sep 2016 20:30:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Sep 2016 20:30:12 -0000 Authentication-Results: pb1.pair.com header.from=me@daveyshafik.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=me@daveyshafik.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain daveyshafik.com from 209.85.220.175 cause and error) X-PHP-List-Original-Sender: me@daveyshafik.com X-Host-Fingerprint: 209.85.220.175 mail-qk0-f175.google.com Received: from [209.85.220.175] ([209.85.220.175:33335] helo=mail-qk0-f175.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AA/D9-45301-EC5DDC75 for ; Mon, 05 Sep 2016 16:30:07 -0400 Received: by mail-qk0-f175.google.com with SMTP id z190so199468589qkc.0 for ; Mon, 05 Sep 2016 13:30:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daveyshafik-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=cOkBrUcpI2jORWxZjqDP+dwEUP8wFAbvr6g0mCC8VDY=; b=tA5Nr8LSFxoLnMM/S5IsmwPRSuz2uTM2hmUj3smSO+URLL5k1+R05EJy52fiA/E0aH OHBuOw8JODqlcOm9V2yDDVzSC0Mqrjqo1hFUsj9zHWgXquA21kHlgpuFkswJSMF9Vu5Q J4NRjWO2FTAexNEGrMpvPiur7Ttur49RkA34XHnu1BHw7eQoneFGnH6FxASZSLdypTza HY3Se/Jysu2+dcQ05pgM4x6pIEbMV/cQtjP3uKLXVO0jlB1b/rXyHW3Bgjov/ZGjwGjp PZz0KsN+BTzoz11AtcbvaHkAJPSBH39LmXNf2lL4aEheFZS93g5WXxOPkHOJEevdVtnz bnkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=cOkBrUcpI2jORWxZjqDP+dwEUP8wFAbvr6g0mCC8VDY=; b=kwSfYF+QLQtCUnWZt/l3Ru8owEFDMLW+ZJDzJxCmvc/DwDjsWSsa8976bsz09zceCc RnKAvktST74KvBfk3Z+oqsnZ6dLREHiOjdJ19rJHwJvVc5b02YGeTIZ387/nM/5Lgp14 1+PyqmMHU8pqeI2Zs9sYrIk3UU27bgoGTjwRu1G3ROQezAbilpVuLzMEVWd49u3FzbwD 4Ly2aIPlUoOTVwKwcIdalcLQOKY8J7Pofj9j0VhvcpIx4oOaJYULmTTTg3Qx3+yz+reR ml9ySISATI8ZVbH4KgzRBiufImo0yZBWuRcdcLsWLmMkzzbukyDGNqijIpoqdEXBnI73 xXyQ== X-Gm-Message-State: AE9vXwMjcCxPKchheUOmbGcotVRKGJpJbth+gZaJruRf48vS7eBNRIsaarQO66Ol7nFYrPUCqpUESvlA6FKaLW4H X-Received: by 10.55.214.68 with SMTP id t65mr19535544qki.216.1473107402838; Mon, 05 Sep 2016 13:30:02 -0700 (PDT) MIME-Version: 1.0 Sender: me@daveyshafik.com Received: by 10.237.50.161 with HTTP; Mon, 5 Sep 2016 13:30:02 -0700 (PDT) In-Reply-To: References: Date: Mon, 5 Sep 2016 13:30:02 -0700 X-Google-Sender-Auth: 37rVk9veJZeankWUGrpffKy9cGU Message-ID: To: Nicolas Grekas Cc: Niklas Keller , Pierre Joye , PHP internals Content-Type: multipart/alternative; boundary=001a1149a728767a7f053bc88bc0 Subject: Re: [PHP-DEV] Missing reflection info about strict types? From: davey@php.net (Davey Shafik) --001a1149a728767a7f053bc88bc0 Content-Type: text/plain; charset=UTF-8 On Mon, Sep 5, 2016 at 1:13 PM, Nicolas Grekas wrote: > > Why do you concatenate these files in the first place? > > > > > > It's not specifically me but Symfony's ClassCollectionLoader::load() > method, which generates a single file with common classes inlined for > faster bootstrapping (the perf gain is objectively measurable). > > You give this method a list of classes that are always required, and it > computes all the required parents/interfaces/traits they use, by using > reflection of course. It turns namespace to the bracketed syntax, orderd > things as required (parents first), and dumps everything in one php file. > > The issue came to our tracker that this process was broken once one wanted > to inline a strict class there, either directly or indirectly through the > parent chain. > Again, there is not such thing as a strict class. You should be stripping ALL declare(strict_types=0/1) from the class files, and even if enabled it at the top of final generated file it wouldn't make any difference _unless_ you're calling the classes IN the generated file. Anything you include it into will decide for itself whether it is strict or not. > I worked on the issue and fixed it by replacing the inlining by a "require" > for now. > > Here is the pointer for the fix (then the class & the issue): > https://github.com/symfony/symfony/pull/19859/files?w=1 I would highly recommend using sprintf() instead of str_replace() to inject your regex. And again, strip the declare lines completely. Then you can concat. https://github.com/symfony/symfony/pull/19859/files?w=1#diff-e37b3a45b919f2dd526570353388e4a5R1 This isn't a class with strict types, it's a file that will enforce strict types on code that _it_ calls, not code that calls the class defined inside it. - Davey --001a1149a728767a7f053bc88bc0--