Skip to content
This repository has been archived by the owner on Dec 16, 2019. It is now read-only.

Worker::collect() should accept any callable, but only accepts \Closure objects #836

Closed
dktapps opened this issue Feb 19, 2018 · 0 comments · Fixed by #841
Closed

Worker::collect() should accept any callable, but only accepts \Closure objects #836

dktapps opened this issue Feb 19, 2018 · 0 comments · Fixed by #841

Comments

@dktapps
Copy link
Contributor

dktapps commented Feb 19, 2018

Environment

  • PHP: 7.2.2
  • pthreads: 2bc4406
  • OS: windows x64

Reproducing Code

function collector(Collectable $collectable) : bool{
	return $collectable->isGarbage();
}

class Work extends \Threaded{
	public function run(){
		sleep(1);
	}
}
$worker = new \Worker();
$worker->start();
$worker->stack(new Work());
while($worker->collect('collector'));
$worker->shutdown();

Expected Output

nothing

Actual Output

Fatal error: Uncaught TypeError: Argument 1 passed to Worker::collect() must be an instance of Closure, string given in pthreads-test.php:38
Stack trace:
#0 pthreads-test.php(38): Worker->collect('collector')
#1 {main}
  thrown in pthreads-test.php on line 38
dktapps referenced this issue in pmmp/ext-pmmpthread Feb 21, 2018
This updates the stub to match pthreads v3 properly, as per the arginfo of the extension. Some issues were discovered in the process (see #835 and #836), so method signatures have been adjusted to match the documentation where there are mismatches.

The formatting in this file is very inconsistent, I went to great pains to avoid reformatting it to avoid polluting the diff.
dktapps referenced this issue in pmmp/ext-pmmpthread Feb 22, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants