通过ZendVM调用函数或者方法的时候,如果开启了类型检查,需要检查参数类型 #43
Closed
NathanFreeman
wants to merge 1 commits from feat/type_check into master
4 changed files with 76 additions and 0 deletions
@ -0,0 +1,10 @@ |
|||||||
|
<?php |
||||||
|
declare(strict_types=1); |
||||||
|
|
||||||
|
class Test |
||||||
|
{ |
||||||
|
public function handle(string $value) |
||||||
|
{ |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,16 @@ |
|||||||
|
--TEST-- |
||||||
|
declare(strict_types=1): Type checking of function calls 1 |
||||||
|
--FILE-- |
||||||
|
<?php |
||||||
|
declare(strict_types=1); |
||||||
|
function main() { |
||||||
|
ini_set(1, 1); |
||||||
|
} |
||||||
|
?> |
||||||
|
--EXPECTF-- |
||||||
|
Fatal error: Uncaught TypeError: ini_set(): Argument #1 ($option) must be of type string, int given in %s:%d |
||||||
|
Stack trace: |
||||||
|
#0 %s |
||||||
|
#1 %s |
||||||
|
#2 {main} |
||||||
|
thrown in %s on line %d |
||||||
@ -0,0 +1,18 @@ |
|||||||
|
--TEST-- |
||||||
|
declare(strict_types=1): Type checking of function calls 2 |
||||||
|
--FILE-- |
||||||
|
<?php |
||||||
|
declare(strict_types=1); |
||||||
|
|
||||||
|
function main() { |
||||||
|
require __DIR__ . "/Test.php"; |
||||||
|
(new Test())->handle(true); |
||||||
|
} |
||||||
|
?> |
||||||
|
--EXPECTF-- |
||||||
|
Fatal error: Uncaught TypeError: Test::handle(): Argument #1 ($value) must be of type string, true given in %s:%d |
||||||
|
Stack trace: |
||||||
|
#0 %s |
||||||
|
#1 %s |
||||||
|
#2 {main} |
||||||
|
thrown in %s on line %d |
||||||
Loading…
Reference in new issue