Bug #79976 [Opn->Ver]: anonymous class instanceof error in cli
Edit report at https://bugs.php.net/bug.php?id=79976&edit=1
ID: 79976
Updated by: cmb@php.net
Reported by: consatan at gmail dot com
Summary: anonymous class instanceof error in cli
-Status: Open
+Status: Verified
Type: Bug
Package: *General Issues
Operating System: Linux
PHP Version: 7.3.21
Block user comment: N
Private report: N
New Comment:
Interestingly,
php > var_dump((new class() extends B {}) instanceof A);
bool(true)
Previous Comments:
------------------------------------------------------------------------
[2020-08-14 15:35:47] consatan at gmail dot com
Description:
------------
test on docker php:(7.3.0~7.4.1)-cli-alpine
```
$ docker run --rm -ti php:7.3.21-cli-alpine sh
/ # php -a
Interactive shell
php > class A {}
php > class B {}
php > var_dump((new class() extends A {}) instanceof A);
bool(true)
php > var_dump((new class() extends B {}) instanceof B);
bool(false)
```
if running with a php file, it's work.
```
$ docker run --rm -ti php:7.3.21-cli-alpine sh
/ # cat <<EOF>>/tmp/test.php
> <?php
> class A {}
> class B {}
> var_dump((new class() extends A {}) instanceof A);
> var_dump((new class() extends B {}) instanceof B);
> EOF
/ # php -f /tmp/test.php
bool(true)
bool(true)
```
Test script:
---------------
class A {}
class B {}
var_dump((new class() extends A {}) instanceof A);
var_dump((new class() extends B {}) instanceof B);
Expected result:
----------------
bool(true)
bool(true)
Actual result:
--------------
bool(true)
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79976&edit=1
Thread (6 messages)