com php-src: Test to verify that closures can't be instantiated: Zend/tests/closures/closure_instantiate.phpt

From: Date: Sat, 09 Feb 2019 01:46:09 +0000
Subject: com php-src: Test to verify that closures can't be instantiated: Zend/tests/closures/closure_instantiate.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-104493@lists.php.net to get a copy of this message
Commit: c5f9855283733131b9900818e7bc6e997668ffdc Author: MarkBaker <mark@lange.demon.co.uk> Fri, 6 Oct 2017 00:52:45 +0100 Committer: Peter Kokot <peterkokot@gmail.com> Sat, 9 Feb 2019 02:46:09 +0100 Parents: d22dd5f93a687ed208ca39e451ae5ab7d7dc6be3 Branches: PHP-7.4 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=c5f9855283733131b9900818e7bc6e997668ffdc Log: Test to verify that closures can't be instantiated Changed paths: A Zend/tests/closures/closure_instantiate.phpt Diff: diff --git a/Zend/tests/closures/closure_instantiate.phpt b/Zend/tests/closures/closure_instantiate.phpt new file mode 100644 index 0000000..fa936a2 --- /dev/null +++ b/Zend/tests/closures/closure_instantiate.phpt @@ -0,0 +1,21 @@ +--TEST-- +Closures cannot be instantiated directly +--CREDITS-- +Mark Baker mark@lange.demon.co.uk at the PHPNW2017 Conference for PHP Testfest 2017 +--FILE-- +<?php + +try { + // Closures should be instantiatable using new + $x = new Closure(); +} catch (Exception $e) { + // Instantiating a closure is an error, not an exception, so we shouldn't see this + echo 'EXCEPTION: ', $e->getMessage(); +} catch (Throwable $e) { + // This is the mesage that we should see for a caught error + echo 'ERROR: ', $e->getMessage(); +} + +?> +--EXPECT-- +ERROR: Instantiation of 'Closure' is not allowed

« previous php.cvs (#104493) next »