This repository has been archived by the owner on Dec 16, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 501
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from bwoebi/master
Implemented what I wanted in #36
- Loading branch information
Showing
4 changed files
with
120 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
--TEST-- | ||
Test NULLing ressources in arrays | ||
--FILE-- | ||
<?php | ||
class file { | ||
public static $fps; | ||
|
||
public static function __callstatic($method, $args) { | ||
$tid = Thread::getThreadId(); | ||
if (isset(self::$fps[$tid])) { | ||
return call_user_func_array(array("file", "_{$method}"), array_merge($args, array($tid))); | ||
} else { | ||
self::$fps[$tid] = fopen(__FILE__, "r+"); | ||
if (isset(self::$fps[$tid])) | ||
return call_user_func_array(array("file", "_{$method}"), array_merge($args, array($tid))); | ||
} | ||
} | ||
|
||
public static function _get ($arg, $tid) { | ||
printf("%s: %s\n", __METHOD__, $arg); | ||
var_dump(self::$fps); | ||
} | ||
} | ||
|
||
class UserThread extends Thread { | ||
public function run () { | ||
/* execute calls */ | ||
$i = 2; | ||
file::get("something".(++$i)); | ||
file::get("something".(++$i)); | ||
|
||
} | ||
} | ||
|
||
$i = 0; | ||
|
||
file::get("something".(++$i)); | ||
file::get("something".(++$i)); | ||
|
||
$thread = new UserThread(); | ||
$thread->start(); | ||
?> | ||
--EXPECTF-- | ||
file::_get: something1 | ||
array(1) { | ||
[%i]=> | ||
resource(5) of type (stream) | ||
} | ||
file::_get: something2 | ||
array(1) { | ||
[%i]=> | ||
resource(5) of type (stream) | ||
} | ||
file::_get: something3 | ||
array(2) { | ||
[%i]=> | ||
NULL | ||
[%i]=> | ||
resource(2) of type (stream) | ||
} | ||
file::_get: something4 | ||
array(2) { | ||
[%i]=> | ||
NULL | ||
[%i]=> | ||
resource(2) of type (stream) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters