com php-src: Test strict code calling weak code and vice-versa: Zend/tests/typehints/strict_call_weak.phpt Zend/tests/t
ypehints/strict_call_weak_2.inc Zend/tests/typehint s/strict_call_weak_explicit.phpt Zend/tests/typehints /strict_call_weak_explicit_2.inc
Zend/tests/typeh ints/weak_call_strict.phpt Zend/tests/typehints/weak_ call_strict_2.inc Zend/tests/typehints/weak_explici t_call_strict.phpt

From: Date: Tue, 10 Feb 2015 15:48:07 +0000
Subject: com php-src: Test strict code calling weak code and vice-versa: Zend/tests/typehints/strict_call_weak.phpt Zend/tests/t
ypehints/strict_call_weak_2.inc Zend/tests/typehint s/strict_call_weak_explicit.phpt Zend/tests/typehints /strict_call_weak_explicit_2.inc
Zend/tests/typeh ints/weak_call_strict.phpt Zend/tests/typehints/weak_ call_strict_2.inc Zend/tests/typehints/weak_explici t_call_strict.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-85724@lists.php.net to get a copy of this message
Commit: b112c13a41674e9c307f42c6054e3036ca3e6960 Author: Andrea Faulds <ajf@ajf.me> Sun, 25 Jan 2015 02:18:58 +0000 Parents: e1a238670c940ea6c017de0cada52e76528db64b Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=b112c13a41674e9c307f42c6054e3036ca3e6960 Log: Test strict code calling weak code and vice-versa Changed paths: A Zend/tests/typehints/strict_call_weak.phpt A Zend/tests/typehints/strict_call_weak_2.inc A Zend/tests/typehints/strict_call_weak_explicit.phpt A Zend/tests/typehints/strict_call_weak_explicit_2.inc A Zend/tests/typehints/weak_call_strict.phpt A Zend/tests/typehints/weak_call_strict_2.inc A Zend/tests/typehints/weak_explicit_call_strict.phpt Diff: diff --git a/Zend/tests/typehints/strict_call_weak.phpt b/Zend/tests/typehints/strict_call_weak.phpt new file mode 100644 index 0000000..45b87b0 --- /dev/null +++ b/Zend/tests/typehints/strict_call_weak.phpt @@ -0,0 +1,17 @@ +--TEST-- +strict_types=1 code calling strict_types=0 code +--FILE-- +<?php + +declare(strict_types=1); + +// file that's implicitly weak +require 'strict_call_weak_2.inc'; + +// Will succeed: Function was declared in weak mode, but that does not matter +// This file uses strict mode, so the call is strict, and float denied for int +function_declared_in_weak_mode(1.0); +?> +--EXPECTF-- +Catchable fatal error: Argument 1 passed to function_declared_in_weak_mode() must be of the type integer, float given, called in %sstrict_call_weak.php on line 10 and defined in %sstrict_call_weak_2.inc on line 5 + diff --git a/Zend/tests/typehints/strict_call_weak_2.inc b/Zend/tests/typehints/strict_call_weak_2.inc new file mode 100644 index 0000000..cba5512 --- /dev/null +++ b/Zend/tests/typehints/strict_call_weak_2.inc @@ -0,0 +1,7 @@ +<?php + +// implicitly weak code + +function function_declared_in_weak_mode(int $x) { + echo "Success!"; +} diff --git a/Zend/tests/typehints/strict_call_weak_explicit.phpt b/Zend/tests/typehints/strict_call_weak_explicit.phpt new file mode 100644 index 0000000..07a311b --- /dev/null +++ b/Zend/tests/typehints/strict_call_weak_explicit.phpt @@ -0,0 +1,17 @@ +--TEST-- +strict_types=1 code calling explicitly strict_types=0 code +--FILE-- +<?php + +declare(strict_types=1); + +// file that's explicitly weak +require 'strict_call_weak_explicit_2.inc'; + +// Will succeed: Function was declared in weak mode, but that does not matter +// This file uses strict mode, so the call is strict, and float denied for int +function_declared_in_weak_mode(1.0); +?> +--EXPECTF-- +Catchable fatal error: Argument 1 passed to function_declared_in_weak_mode() must be of the type integer, float given, called in %sstrict_call_weak_explicit.php on line 10 and defined in %sstrict_call_weak_explicit_2.inc on line 5 + diff --git a/Zend/tests/typehints/strict_call_weak_explicit_2.inc b/Zend/tests/typehints/strict_call_weak_explicit_2.inc new file mode 100644 index 0000000..d26c847 --- /dev/null +++ b/Zend/tests/typehints/strict_call_weak_explicit_2.inc @@ -0,0 +1,7 @@ +<?php + +declare(strict_types=0); + +function function_declared_in_weak_mode(int $x) { + echo "Success!"; +} diff --git a/Zend/tests/typehints/weak_call_strict.phpt b/Zend/tests/typehints/weak_call_strict.phpt new file mode 100644 index 0000000..b0ea78c --- /dev/null +++ b/Zend/tests/typehints/weak_call_strict.phpt @@ -0,0 +1,16 @@ +--TEST-- +strict_types=0 code calling strict_types=1 code +--FILE-- +<?php + +// implicitly strict_types=0 + +// file with strict_types=1 +require 'weak_call_strict_2.inc'; + +// Will succeed: Function was declared in strict mode, but that does not matter +// This file uses weak mode, so the call is weak, and float accepted for int +function_declared_in_strict_mode(1.0); +?> +--EXPECT-- +Success! diff --git a/Zend/tests/typehints/weak_call_strict_2.inc b/Zend/tests/typehints/weak_call_strict_2.inc new file mode 100644 index 0000000..fe2a17f --- /dev/null +++ b/Zend/tests/typehints/weak_call_strict_2.inc @@ -0,0 +1,7 @@ +<?php + +declare(strict_types=1); + +function function_declared_in_strict_mode(int $x) { + echo "Success!"; +} diff --git a/Zend/tests/typehints/weak_explicit_call_strict..phpt b/Zend/tests/typehints/weak_explicit_call_strict.phpt new file mode 100644 index 0000000..b07cef5 --- /dev/null +++ b/Zend/tests/typehints/weak_explicit_call_strict.phpt @@ -0,0 +1,16 @@ +--TEST-- +Explicitly strict_types=0 code calling strict_types=1 code +--FILE-- +<?php + +declare(strict_types=0); + +// file with strict_types=1 +require 'weak_call_strict_2.inc'; + +// Will succeed: Function was declared in strict mode, but that does not matter +// This file uses weak mode, so the call is weak, and float accepted for int +function_declared_in_strict_mode(1.0); +?> +--EXPECT-- +Success!

« previous php.cvs (#85724) next »