private function start_new_test($name) { $this->current_test = $this->getNewTestObject(); $this->current_test->setName($name); $this->tests[] = $this->current_test; return $this->current_test; }
{ $this->name = $name; $this->test = $name; return $this; } public function getName() { return $this->name; } public function getTest() { return $this->test; } } $test = new Test(['a' => 'a', 'b' => 'b']); $test->setName('ok'); $ser = serialize($test); $unSer = unserialize($ser); var_dump($unSer->getName()); // null var_dump($unSer->getTest()); // ok var_dump($unSer); // php 7.0.3 /** * D:\htdocs\array_object.php:36:null * * D:\htdocs\array_object.php:37: * object(Test)[2] * private 'name' => string 'ok' (length=2) * private 'storage' (ArrayObject) =>
<?php include './GettersAndSetters.php'; class Test extends GettersAndSetters { /** * @method String getName() return the value of attribute name * @method $this setName($value) set the value in attribute name */ protected $name; /** * @method String getNameWithUnderscore() return the value of attribute name * @method $this setNameWithUnderscore($value) set the value in attribute name */ protected $_nameWithUnderscore; } $test = new Test(); $test->setName("Name"); $test->setNameWithUnderscore("Name"); echo $test->getName(); echo "<br>"; echo $test->getNameWithUnderscore();
function test($name, callable $testCode) { $this->tests[] = $test = new Test(); $test->setName($name); $test->setCode($testCode); }