Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109411 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 92585 invoked from network); 29 Mar 2020 12:19:31 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 29 Mar 2020 12:19:31 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 6E739180088 for ; Sun, 29 Mar 2020 03:45:09 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS8560 212.227.0.0/16 X-Spam-Virus: No X-Envelope-From: Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 29 Mar 2020 03:45:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1585478707; bh=lqhwZpqbiXzw4n+uRLXYzMohkiVaUMkMQQ6JFny7uy8=; h=X-UI-Sender-Class:Subject:To:References:From:Date:In-Reply-To; b=JYOWCRpNe+PXnOMrqAnCUdemejTJ+zokViXjFLaI03m4ftQjbbuiQK1w8aCI0sg0b KqA8INrwLAzRI11cg6wPUJEf1qsoS51k0Ndzmw8vSS1tFp7hs2gKllk/1RZqkIC8H4 F1ULw7zn63lggjxAbLwTNG8bRfQaPhNB9bHyXBOA= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.2.130] ([84.179.237.201]) by mail.gmx.com (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MgNh1-1irwaL3QQ3-00hskj for ; Sun, 29 Mar 2020 12:45:06 +0200 To: internals@lists.php.net References: Message-ID: Date: Sun, 29 Mar 2020 12:45:07 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: de-DE Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:n8O5uf0GfghVh8Dh2o05SVyvuCZNsqoEvEafdjBMNtObK/7tGhu N9RtJ7J9tXbax3GdTPj6p7fobTsKu8AQvrL+xtzDRc9v4ZrDK8EoThR2LahnUL96We/wAdo XUVj+5C6wQXrxgAKL4dphQzWQAIMGcB+ZKKfZFkQO458Zwdws0rySUrBR8YuegwvgMNpjYs VuxK8TlOScEpLDWNa3iQQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:Jp3EtDv9sd0=:tTY6FU6x/sO981w0rLW0w/ URGajuW/ti9uvL+W2JVLTSmvJl8WJyDYwm/f/OCCxkZgFAy8kwnoUxguD0KjFDtMlNKe1wfeI Q0WaF1WqLYaZs9oA5fX3NRjbfUOHx9BF0dF9G0k9Eo4UTr8mFIP1x0kz9af6cXSEOQ4fl/1wS c1DGigCSuP/ph5wh6xfqc73sbzE6un4tjLS0BB24qlwOydhxelz3Pb566N6mSOuZRM6GQ+j3R St9Ik+GNhTJVDnp3ouVBf+5UAx6Lq7qQRq+poOPbABXwJ8ODEfUvcwlN3zNq8+mEvMlgCAJ7d qVf1f+D5w7uWsJ5ThiQDcRA8OcFdw7oyNEr7+hkL27KhdRhipOHXTPEkPgJtyq15a/2+rP1vd p5MBTsU0894g48I7JIXZ+8Ygm0asxMFzRl3CXeyyDPkc7ymoH52KiDB9j5S6G+Rz7ix3lz/Iy FmGXkT7B4S5BFLFd3/uMLLcch2Cesnf8oilm9/C5rBOFkpFIb+cUm96+WuglGLsDyj2o2xZEI sXM42Hp8gd6Pax3yZNh4GMNMCubx0D12zJijOudUFKLB5rB0Tbf5M9FKnBKGTN9ZxDqyYH5tG tondJr7ZRnrBXgYPP5v8Racl/zQsgVNz8fIWqDLKYciCJgV0xBwDHWIa/gx1mYfPPuXks8/G8 +bIgNXLZ6uCi/Gsx4a8d1LcOahQ43nbpaygSi327DZvXSxwfAGgcupN8PRaS1+Dup8shTFJl2 ottmmYnPBQ3qwdf/OHY4IENLcLNmMwofpfffgQJvt1DmKJYDXwp20mLZPabTEROcXnPeG/8fo kpc8BIkv0rHgjStxJ2/Luvs4beNNEo94TT4tuiLz0FBeuqq9f6OUk+DmBtb7+5TkWqXa2sWli uNX0qo5+thcQ+XMiFIj1wQYXf4twZ76WayJwsYkWs/SpAVnSSQYcL+xgMpKkYQxID+iyfyVek ii84sMZh9MXF4R0C+GR8bIWNISZy+KSreLZfmTeJwNf9Yv8u88YzUR8229urSRI4AXVZbyyNO rd7Ui5lg29WKCB4Ph3n/ZPVH37/I/OMVd6cxcDm0NyYFKkqTjMyWOYXjnXkZn62A6zIDY7GMa OLzc1P3ebszbfsJwFk8E74eoZVEzUSLtcaPpE8rOmqEoAVZ+19LmOEyP+LOeoUEe6FesMc0fA 4owaVGFXe5qwi/Q9roUbzD2oRrwPMmHDAxUdwgtpTIifTxm1lFPPxUbejUStFEKm5c9VI6UK3 wi3vAu6+n6FUrBeUZ Subject: Re: Interfaces and ReflectionMethod::isConstructor() From: cmbecker69@gmx.de ("Christoph M. Becker") On 28.03.2020 at 08:44, Sebastian Bergmann wrote: > I recently received a bug report for PHPUnit [1] that with PHP 8 test > doubles (test stubs or mock objects) can no longer be created for > interfaces that declare a constructor. > > I was able to reproduce this [2] and learned that PHPUnit's > canMockMethod() [3] returns a different result on PHP 8 compared to PHP > 7. This is due to the return value of ReflectionMethod::isConstructor() > when the ReflectionMethod object was created for an interface. > > Here is a minimal, self-contained, reproducing test case: > > interface I > { > public function __construct(); > } > > var_dump((new ReflectionMethod(I::class, '__construct'))->isConstructor(= )); > > The code shown above yields the following result: > > * bool(true) for PHP 5.0.0 and PHP 5.0.1 > * bool(false) for PHP 5.0.2 through PHP 7.4.4 > * bool(true) for PHP 8.0-dev > > I think that the behaviour in PHP 8 (and PHP 5.0.0 and PHP 5.0.1) is > correct. But I also think that constructor declarations have no place in > interfaces ... so I am confused. Which is why I did not open a ticket on > bugs.php.net and bring this topic to this list instead. > > To the best of my knowledge, this change in behaviour of isConstructor() > between PHP 7 and PHP 8 is not yet documented. If it is intentional and > here to stay then it should be documented. > > I can deal with this in PHPUnit's code either way, but need to know what > the plan here is. The relevant change[1] is that now the class entry members serialize_func, unserialize_func, constructor, destructor and clone are set, if the respective methods are declared on an interface. [1] =2D- Christoph M. Becker