From 9c518265decd411d5cdd22e00403f46cf06b171f Mon Sep 17 00:00:00 2001 From: "Ralph J. Smit" <59207045+ralphjsmit@users.noreply.github.com> Date: Wed, 22 Jan 2025 20:21:40 +0100 Subject: [PATCH 1/3] WIP --- .idea/.gitignore | 8 ++++++++ tests/ReflectionClosure6Test.php | 15 +++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 tests/ReflectionClosure6Test.php diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000..13566b81 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/tests/ReflectionClosure6Test.php b/tests/ReflectionClosure6Test.php new file mode 100644 index 00000000..8d010ffc --- /dev/null +++ b/tests/ReflectionClosure6Test.php @@ -0,0 +1,15 @@ + $this instanceof (class_exists(Foo::class) ? Foo::class : Forest::class); + $e1 = 'fn (\Foo\Bar $a) => $this instanceof (class_exists(\Foo:class) ? \Foo::class : \Foo\Baz\Qux\Forest::class)'; + + expect($f1)->toBeCode($e1); +}); \ No newline at end of file From b9082aa0341edffb16e2eea8ef3e4fbf1c903287 Mon Sep 17 00:00:00 2001 From: "Ralph J. Smit" <59207045+ralphjsmit@users.noreply.github.com> Date: Wed, 22 Jan 2025 20:23:59 +0100 Subject: [PATCH 2/3] WIP --- .idea/.gitignore | 8 -------- tests/ReflectionClosure6Test.php | 8 ++++++-- 2 files changed, 6 insertions(+), 10 deletions(-) delete mode 100644 .idea/.gitignore diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 13566b81..00000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/tests/ReflectionClosure6Test.php b/tests/ReflectionClosure6Test.php index 8d010ffc..712851ce 100644 --- a/tests/ReflectionClosure6Test.php +++ b/tests/ReflectionClosure6Test.php @@ -8,8 +8,12 @@ use Tests\Fixtures\RegularClass; test('resolve instanceof with class_exists()', function () { - $f1 = fn (Baz $a) => $this instanceof (class_exists(Foo::class) ? Foo::class : Forest::class); - $e1 = 'fn (\Foo\Bar $a) => $this instanceof (class_exists(\Foo:class) ? \Foo::class : \Foo\Baz\Qux\Forest::class)'; + $f1 = fn (Baz $a) => $this instanceof (Forest::class); // Turning `instanceof` into an expression results into this incorrect compilation + $e1 = 'fn (\Foo\Bar $a) => $this instanceof (\Foo\Baz\Qux\Forest::class)'; + + $f2 = fn (Baz $a) => $this instanceof (class_exists(Foo::class) ? Foo::class : Forest::class); + $e2 = 'fn (\Foo\Bar $a) => $this instanceof (class_exists(\Foo:class) ? \Foo::class : \Foo\Baz\Qux\Forest::class)'; expect($f1)->toBeCode($e1); + expect($f2)->toBeCode($e2); }); \ No newline at end of file From fb330119e45d4e0b759ef6569aa185c4e8a95c9e Mon Sep 17 00:00:00 2001 From: "Ralph J. Smit" <59207045+ralphjsmit@users.noreply.github.com> Date: Wed, 22 Jan 2025 20:41:16 +0100 Subject: [PATCH 3/3] Update ReflectionClosure6Test.php --- tests/ReflectionClosure6Test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ReflectionClosure6Test.php b/tests/ReflectionClosure6Test.php index 712851ce..d13a5e6f 100644 --- a/tests/ReflectionClosure6Test.php +++ b/tests/ReflectionClosure6Test.php @@ -7,7 +7,7 @@ use Tests\Fixtures\Model; use Tests\Fixtures\RegularClass; -test('resolve instanceof with class_exists()', function () { +test('resolve instanceof with expression', function () { $f1 = fn (Baz $a) => $this instanceof (Forest::class); // Turning `instanceof` into an expression results into this incorrect compilation $e1 = 'fn (\Foo\Bar $a) => $this instanceof (\Foo\Baz\Qux\Forest::class)';