swoole / docs

13 stars 44 forks source link

请问,我测试线程的map报错 #40

Closed 2723659854 closed 4 months ago

2723659854 commented 4 months ago
<?php
use Swoole\Thread;
/** 使用map传递数据 */
use Swoole\Thread\Map;

$args = Thread::getArguments();
if (empty($args)) {
    $map = new Map;
    $thread = new Thread(__FILE__, 2, $map);
    sleep(1);
    $class = new stdClass();
    $class->name = "张三556565";
    $map['test'] = $class;
    $map->add('demo','lucy');
    $thread->join();
} else {
    $map = $args[1];
    sleep(2);
    var_dump($map['test']);
    var_dump($map['demo']);
    var_dump($map->keys());
    var_dump($map->count());
    var_dump($map->values());
    var_dump($map->toArray());
}

报错:Fatal error: Uncaught Error: Call to undefined method Swoole\Thread\Map::values() in /var/www/swoole/map.php:23 Stack trace:

0 {main}

thrown in /var/www/swoole/map.php on line 23

2723659854 commented 4 months ago

是我的用法错了吗