Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100858 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 39416 invoked from network); 10 Oct 2017 16:53:52 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Oct 2017 16:53:52 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.52 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.214.52 mail-it0-f52.google.com Received: from [209.85.214.52] ([209.85.214.52:48603] helo=mail-it0-f52.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 08/8A-49033-F1BFCD95 for ; Tue, 10 Oct 2017 12:53:52 -0400 Received: by mail-it0-f52.google.com with SMTP id c3so3224983itc.3 for ; Tue, 10 Oct 2017 09:53:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=He8Q/Ovmt17EQafcVqGmEHB1egt5Q6b1W15lHo9YPWs=; b=DxlZ3Vi1Kpk90XDNkG2p0Sls75hYlhhjvQh481JuuHKxt2+a/TgsHFZv9KL5Gm1E5f YxV7rNsagZMdiifdPHpGoWYDvZLJ+CEEGt3XjPSq8DgsZ3qxf4JwNvfrqWXK3sO7RfGV Y9DaEjxNZWWmiefvC9GqNvtrYtKcNzIQuOfKeercnuCrlksdIQJrzXcCjaajVUFUWhE5 Hv88OW6OEHIt0qNzlEOlX3hK5zKrrEcyiC+DxsoyZEzuDwIbzXLnr19MdoaQa/xMJLTm CJhxPSzZH2n1zgICsjdN8+jHvY8o+sw3A1vYsQOjjamhISZnwCjZmqSdTrRcqvtmVDhZ wD9w== 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; bh=He8Q/Ovmt17EQafcVqGmEHB1egt5Q6b1W15lHo9YPWs=; b=ubBc0zD1IOXZFZpIn9396Tc6A0RoS9/XC1i9IRNMRpiXXBrKQtsVx5UlpQhaXl4jKq WsiIBYoKoqkd98lulbsEnv2lyYzKZ4gAqwprZRP0MTtI27EFSVkbh2ZgNgAqM/ZO0Bh5 n0LhsiTrL571xNNhsOtVmThcAqh6xQc9A2R4NtAhGoW3Cg2jHbWQ3BU4ke7WNrKAvzPD gR9lnEbaU5X3ndeNWY4G7zcHOOgEVFcdz4s0Mf4wdaX4OwE4W7PRgh2xi/oNyLr3wNYV seJSd6S21lJQVg4X/UvEa8s/YiyVpBRp7mF045dnFffGIiEZcU6bPhNjJFlejPxVsHFJ HUTg== X-Gm-Message-State: AMCzsaWBEFxr11YF4LzrK0nJnDzTBOnNgef+nNtBpqSMG9kzvgNo5/jj o6ZBQeIrgWZqnkTCjRtNnchMD35KsCfo4JumLsE= X-Google-Smtp-Source: AOwi7QCGxNL+8qnzNXyGcEexS0CP7AhBHl/ntcg1XG1A1SSU9CEDCbJJFOesjS/zrWQ1V9Oh+guZQqSTUUbaX57BzFk= X-Received: by 10.36.149.196 with SMTP id m187mr18150700itd.75.1507654428764; Tue, 10 Oct 2017 09:53:48 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.35.78 with HTTP; Tue, 10 Oct 2017 09:53:47 -0700 (PDT) In-Reply-To: <9a3f15dd-5dfc-144b-cc5f-66f689c33f53@php.net> References: <9a3f15dd-5dfc-144b-cc5f-66f689c33f53@php.net> Date: Tue, 10 Oct 2017 18:53:47 +0200 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary="94eb2c05e6e6abaeae055b3426bb" Subject: Re: [PHP-DEV] Strict type declarations not enforced for Reflection API invocation From: nikita.ppv@gmail.com (Nikita Popov) --94eb2c05e6e6abaeae055b3426bb Content-Type: text/plain; charset="UTF-8" On Tue, Oct 10, 2017 at 3:41 PM, Sebastian Bergmann wrote: > https://bugs.php.net/bug.php?id=75345 is about the fact that strict type > declarations are not enforced when a function or method is invoked via the > Reflection API. > > There is a pull request that addresses this (as well as > https://bugs.php.net/bug.php?id=74750) at > https://github.com/php/php-src/pull/2837. > > I consider this a serious bug that leads to unexpected, confusing problems > such as > https://github.com/sebastianbergmann/phpunit/issues/2796#issuecomment- > 335180273. > > I understand Nikita's point of view (see > https://github.com/php/php-src/pull/2837#issuecomment-335405067) that > changing this behavior (aka. fixing this bug) can be considered a > "non-trivial backwards compatibility break". Therefore I would like to > bring this issue to the attention of this list with this mail. > To repeat what I said in a comment on the pull request: I think this is fixing the wrong issue. The problem are not internal function calls, the problem are callbacks. In fact, the proposed fix does not actually fix the problem you encountered in PHPUnit, as it is going to use the strictness mode at the reflection call-site, not the strictness mode used by the file defining the data provider. The proposed patch is going to add a discrepancy between internal and userland code. It means that the internal array_map function will execute the callback using the strictness mode of the array_map caller, while a userland reimplementation of the same function will not be able to match that behavior and always either perform the call strictly or weakly, independent of the array_map caller. I believe that the proper way to fix this is to handle dynamic function invocations differently from direct invocations. Direct invocations should use the strictness level of the call-site, while dynamic invocations should use the strictness level of the declaration-site. This means that the internal array_map and a userland reimplementation will behave consistent. It also means that PHPUnit will be able to respect the strictness level of file defining the data provider, etc. I've seen a number of complaints about our handling of callbacks wrt strict_types, so I think it's worthwhile to at least consider making such a change. Regards, Nikita --94eb2c05e6e6abaeae055b3426bb--