Skip to content

Instantly share code, notes, and snippets.

@guweigang
Last active June 27, 2019 05:27
Show Gist options
  • Save guweigang/02686f52d813fa53c40578861f39b2a1 to your computer and use it in GitHub Desktop.
Save guweigang/02686f52d813fa53c40578861f39b2a1 to your computer and use it in GitHub Desktop.
namespace PhalconPlus
class Test
{
protected objects;
public function __construct()
{
let this->objects = new \SplObjectStorage();
}
public function test()
{
var a, b, c;
let a = new \stdClass();
let b = new \stdClass();
let c = new \stdClass();
let a->hello = "world";
let b->foo = "bar";
let c->iam = "lucky";
var obj, info;
this->objects->detach(a);
this->objects->attach(a, [
"name" : "first object - a",
"method" : "a",
"initial_data": []
]);
this->objects->detach(b);
this->objects->attach(b, [
"name": "second object - b",
"method" : "b",
"initial_data": []
]);
this->objects->detach(c);
this->objects->attach(c, [
"name" : "third object - c",
"method" : "c",
"initial_data": []
]);
this->objects->rewind();
while this->objects->valid() {
let obj = this->objects->current();
let info = this->objects->getInfo();
echo "Key: " . this->objects->key() . " Name: " . info["name"] . " Obj: " . get_class(obj) . PHP_EOL;
this->objects->next();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment