Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101315 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 35485 invoked from network); 11 Dec 2017 08:28:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Dec 2017 08:28:32 -0000 Authentication-Results: pb1.pair.com smtp.mail=andreas@dqxtech.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=andreas@dqxtech.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain dqxtech.net from 209.85.215.51 cause and error) X-PHP-List-Original-Sender: andreas@dqxtech.net X-Host-Fingerprint: 209.85.215.51 mail-lf0-f51.google.com Received: from [209.85.215.51] ([209.85.215.51:33590] helo=mail-lf0-f51.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DD/0A-53433-FA14E2A5 for ; Mon, 11 Dec 2017 03:28:31 -0500 Received: by mail-lf0-f51.google.com with SMTP id 74so18204948lfs.0 for ; Mon, 11 Dec 2017 00:28:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dqxtech-net.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=275/+0Bi51QpzfBjYkrFg9D6MxXcLZG9nm9gUmfhYdY=; b=hWNNEj6AViop6DFPhSq37ypq/DXV03NA3rAPxoeOWrmKSGL6WQs/UfB+nPKhqXj9pD YN3LhcjzcqkCFfo2i8ERSvKUFAwjmlPKLdj5DyZkAVVRb9dm7Lgxi3ZWSaTpwR3ys/+X yqtXjTheeXxFuDx1vXBJ94/ZNsZdWoJiIjC36ERn/MpIXqw26Kiq1mvNtfuaoHuvs3Rw eikRUUgfvjCual2eYn7C3LPcWc7ULol6VH0sdHGhMVFwK0dnG6A3/0MR2SxiZc+w/BGB YwW0F3gCKGZge2Q/kIB1krfJMJkfKLNtslJ/kIQxQwJ1SCpBIODHZpPX34w8BDH+mCpP X2OA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=275/+0Bi51QpzfBjYkrFg9D6MxXcLZG9nm9gUmfhYdY=; b=hkFH+0K5fIrVOUIuG1nv37uMmRdKc84iB2nyLl2WoLeCJCE6mu+Q5dbVAzz25s6tmg SXBEgxEgwjvJ/7ylLXXGqfCSW5C06TbU6sdln0SyvdRqndHfCo6bw7KUY+EKoTH4p9Cn NTwLEzUF7YPOHZp4NvS5wdluIVPP0C1qCdwS5uJ+XJ/n3xe4oAQXxgUIC1eENk8Shkqb 2l3haaKLIW5kzaRsxlLaJ6iHUK7BZcYWUtrVlRONZOHRvBu7w6puPkdHd5kdnCEBzWlC Ku3BeAA+DSzm2RoNjkn+kvjU5j+FVm3C6uMfYuRj5XXiHyw5zmTJ8oRuPSp62OEaL8m3 Yt5g== X-Gm-Message-State: AJaThX6rWB079i2zmp/rCxf/UvgxSz0l9Wej3ygv69efOl2LDOBNUXvh uSmUiFCsV24dIwr2gpGN12YVPIN3 X-Google-Smtp-Source: AGs4zMYu2xMtU46YdKfo2JiBcf1raJwTic15z0BIgR4cNmwvfiZOxOIMxO2mb039bHZ60Hc1vMqS/A== X-Received: by 10.25.59.28 with SMTP id i28mr16836178lfa.189.1512980908168; Mon, 11 Dec 2017 00:28:28 -0800 (PST) Received: from mail-lf0-f45.google.com (mail-lf0-f45.google.com. [209.85.215.45]) by smtp.googlemail.com with ESMTPSA id f67sm2645718lfb.20.2017.12.11.00.28.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Dec 2017 00:28:27 -0800 (PST) Received: by mail-lf0-f45.google.com with SMTP id e137so18174340lfg.5 for ; Mon, 11 Dec 2017 00:28:27 -0800 (PST) X-Received: by 10.25.157.143 with SMTP id g137mr15063633lfe.6.1512980907004; Mon, 11 Dec 2017 00:28:27 -0800 (PST) MIME-Version: 1.0 Received: by 10.25.170.16 with HTTP; Mon, 11 Dec 2017 00:28:06 -0800 (PST) In-Reply-To: References: Date: Mon, 11 Dec 2017 09:28:06 +0100 X-Gmail-Original-Message-ID: Message-ID: To: Marco Pivetta Cc: Niklas Keller , PHP Internals List Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] ReflectionContext for imports and namespace From: andreas@dqxtech.net (Andreas Hennings) On 11 December 2017 at 09:23, Andreas Hennings wrote: >>> These side effects would be that the class loader loads files which can >>> break things? >> >> >> Yes. Reflecting over a codebase which contains even just polyfills >> (duplicate classes) can already lead to unexpected crashes. Reflecting over >> non-PSR-2 code can even lead to worse things such as starting a DB >> connection and performing unwanted operations. >> > > My own use case avoids this problem. > Instead of randomly scanning anything, you need to tell the annotation > parser explicitly which namespace directory you want to scan. > It is the caller's responsibility that all class files in this > directory are nicely shaped, and can be safely autoloaded. > > In fact I did use a userland parser in the past, but then decided that > native reflection is safe with the above assumption. Maybe one fragile edge case would be if one of the files causes the autoloader to include a different file, outside of the library, due to ambiguous namespace mapping. But this problem would also occur during everyday use of the library, if this class is used. So the condition is: Only scan namespace directories where you know that every class can be safely autoloaded. In fact I do not explicitly include the class file, but let the class loader do this, to be sure that the same version of the class is used that would be used in a regular request / process.