From 3bb67b2749b6a5ce1965fe5d597330532b9def72 Mon Sep 17 00:00:00 2001 From: Anton Vasiliev Date: Thu, 8 Apr 2021 09:25:07 +0100 Subject: [PATCH 1/3] #1136 - Add test case --- stub/mcall.zep | 11 +++++++++++ tests/Extension/MCallTest.php | 10 ++++++++++ 2 files changed, 21 insertions(+) diff --git a/stub/mcall.zep b/stub/mcall.zep index 30491e46ff..0918c27133 100644 --- a/stub/mcall.zep +++ b/stub/mcall.zep @@ -262,4 +262,15 @@ class Mcall let a = new self; return a->bb(); } + + /** + * @issue https://github.com/zephir-lang/zephir/issues/1136 + */ + public function issue1136() + { + var _finfo; + let _finfo = new \finfo(); + + return _finfo; + } } diff --git a/tests/Extension/MCallTest.php b/tests/Extension/MCallTest.php index cd4256d306..c927cc50ac 100644 --- a/tests/Extension/MCallTest.php +++ b/tests/Extension/MCallTest.php @@ -191,4 +191,14 @@ public function testShouldThrowTypeErrorForOptionalBoolean2(): void $test->optionalParameterBoolean([]); } + + /** + * @issue https://github.com/zephir-lang/zephir/issues/1136 + */ + public function testIssue1136(): void + { + $test = new Mcall(); + + $this->assertInstanceOf(\finfo::class, $test->issue1136()); + } } From 26c76e46f3e26861c150a27bd02bd69cd73c5579 Mon Sep 17 00:00:00 2001 From: Anton Vasiliev Date: Thu, 8 Apr 2021 09:27:39 +0100 Subject: [PATCH 2/3] #1136 - Fix code style --- stub/mcall.zep | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stub/mcall.zep b/stub/mcall.zep index 0918c27133..8e41d64691 100644 --- a/stub/mcall.zep +++ b/stub/mcall.zep @@ -266,7 +266,7 @@ class Mcall /** * @issue https://github.com/zephir-lang/zephir/issues/1136 */ - public function issue1136() + public function issue1136() { var _finfo; let _finfo = new \finfo(); From fafd17b17d35290ff1e40b61e8abb6a83a239c1f Mon Sep 17 00:00:00 2001 From: Anton Vasiliev Date: Thu, 8 Apr 2021 12:12:32 +0100 Subject: [PATCH 3/3] #1136 - Add version check --- stub/mcall.zep | 7 ++++++- tests/Extension/MCallTest.php | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/stub/mcall.zep b/stub/mcall.zep index 8e41d64691..e808f5a382 100644 --- a/stub/mcall.zep +++ b/stub/mcall.zep @@ -269,7 +269,12 @@ class Mcall public function issue1136() { var _finfo; - let _finfo = new \finfo(); + + if version_compare(PHP_VERSION, "8.0.0", ">=") { + let _finfo = new \finfo(); + } else { + let _finfo = finfo_open(); + } return _finfo; } diff --git a/tests/Extension/MCallTest.php b/tests/Extension/MCallTest.php index c927cc50ac..42a7b7728d 100644 --- a/tests/Extension/MCallTest.php +++ b/tests/Extension/MCallTest.php @@ -199,6 +199,10 @@ public function testIssue1136(): void { $test = new Mcall(); - $this->assertInstanceOf(\finfo::class, $test->issue1136()); + if (version_compare(PHP_VERSION, "8.0.0", ">=")) { + $this->assertInstanceOf(\finfo::class, $test->issue1136()); + } else { + $this->assertIsResource($test->issue1136()); + } } }