mirror of
https://github.com/php/php-src.git
synced 2025-08-20 01:14:28 +02:00
Test strict code calling weak code and vice-versa
This commit is contained in:
parent
e1a238670c
commit
b112c13a41
7 changed files with 87 additions and 0 deletions
17
Zend/tests/typehints/strict_call_weak.phpt
Normal file
17
Zend/tests/typehints/strict_call_weak.phpt
Normal file
|
@ -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
|
||||||
|
|
7
Zend/tests/typehints/strict_call_weak_2.inc
Normal file
7
Zend/tests/typehints/strict_call_weak_2.inc
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// implicitly weak code
|
||||||
|
|
||||||
|
function function_declared_in_weak_mode(int $x) {
|
||||||
|
echo "Success!";
|
||||||
|
}
|
17
Zend/tests/typehints/strict_call_weak_explicit.phpt
Normal file
17
Zend/tests/typehints/strict_call_weak_explicit.phpt
Normal file
|
@ -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
|
||||||
|
|
7
Zend/tests/typehints/strict_call_weak_explicit_2.inc
Normal file
7
Zend/tests/typehints/strict_call_weak_explicit_2.inc
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=0);
|
||||||
|
|
||||||
|
function function_declared_in_weak_mode(int $x) {
|
||||||
|
echo "Success!";
|
||||||
|
}
|
16
Zend/tests/typehints/weak_call_strict.phpt
Normal file
16
Zend/tests/typehints/weak_call_strict.phpt
Normal file
|
@ -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!
|
7
Zend/tests/typehints/weak_call_strict_2.inc
Normal file
7
Zend/tests/typehints/weak_call_strict_2.inc
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
function function_declared_in_strict_mode(int $x) {
|
||||||
|
echo "Success!";
|
||||||
|
}
|
16
Zend/tests/typehints/weak_explicit_call_strict.phpt
Normal file
16
Zend/tests/typehints/weak_explicit_call_strict.phpt
Normal file
|
@ -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!
|
Loading…
Add table
Add a link
Reference in a new issue