Bug #69909 [Opn]: Type hint of a function are not checked when it's a generator

From: Date: Tue, 23 Jun 2015 12:01:11 +0000
Subject: Bug #69909 [Opn]: Type hint of a function are not checked when it's a generator
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-193797@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69909&edit=1 ID: 69909 Updated by: jpauli@php.net Reported by: lyrixx at lyrixx dot info Summary: Type hint of a function are not checked when it's a generator Status: Open Type: Bug Package: *General Issues Operating System: linux PHP Version: 5.5.26 Block user comment: N Private report: N New Comment: This is because the call to the generator does not call the function actually, thus this latter can't check its arguments. However, triggering a method on the generator returns actually triggers the function call. I attached a patch that fixes the issue by checking args in case of generator creation, however, this will only work if you make use of the return value (which is not the case in your script) Patch is at https://github.com/jpauli/php-src/tree/fix-69909 Previous Comments: ------------------------------------------------------------------------ [2015-06-23 09:37:29] lyrixx at lyrixx dot info Description: ------------ If you don't "next" on the generator, the typehint of the function is not checked. Test script: --------------- <?php function hello(closure $closure) { $closure('hello'); yield 10; } hello(); Expected result: ---------------- Argument 1 passed to hello must be an instance of Closure, none given ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=69909&edit=1

« previous php.bugs (#193797) next »