|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-07-30 01:16 UTC] horny at mail dot az
[2002-09-11 14:05 UTC] iliaa@php.net
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 29 09:00:02 2025 UTC |
<?php assert_options(ASSERT_ACTIVE, '1'); assert_options(ASSERT_WARNING, '1'); assert_options(ASSERT_QUIET_EVAL, '0'); $AVAILABLE_LANGS = array('az' => 'az', 'ru' => 'ru', 'en' => 'en'); # as per RFC 1766 function func($predicate) { do { $freeflag = null; if (call_user_func($predicate, $freeflag) === FALSE) break; assert('!is_null($freeflag)'); } while (0); } class foo { function foo_method(&$freeflag) { $retval = (bool) rand() % 2; if ($retval) $freeflag = 1; return $retval; } } $foo_instance = new foo; func(array($foo_instance, 'foo_method')); ?> D:\>c:\php\php-cli haha.php Warning: Assertion "!is_null($freeflag)" failed in haha.php on line 14 It occurs *always* no matter what foo_method() returns, as if asserts() are happening asynchronously. If I instead change func() to function func($predicate) { $freeflag = null; if (call_user_func($predicate, $freeflag) === TRUE) assert('!is_null($freeflag)'); } The assertion doesn't fail. (because it's NOTREACHED?)