/** * Parses comment. * * @param string $comment * * @return void */ private function parseComment($comment) { $lines = explode(PHP_EOL, $comment); foreach ($lines as $line) { $pos = stripos($line, '@property-read'); if ($pos !== false) { $isReadonly = true; } else { $pos = stripos($line, '@property'); $isReadonly = false; } if (false !== $pos) { $property = explode(' ', preg_replace('/[ ]+/', ' ', substr($line, $pos))); $name = $property[1]; if (3 == count($property)) { $name = $property[2]; $type = $property[1]; } if ('$' == $name[0]) { $name = substr($name, 1); } $this->properties->init($name, null, $isReadonly); if (isset($type)) { $this->properties->getValidator()->append($name, $type); } } } }
protected function setUp() { $this->subject = new Data(); $lazyload = function () { $data = new Data(); $data->init('offset1')->init('offset2')->init('offset3'); return $data; }; $this->subject->init('offset1', null, true)->init('offset2', null, false)->init('offset3', $lazyload, true)->init('offset4', $lazyload, false); $this->subject->getFilter()->append('offset1', function ($value) { $value .= 'filtrated'; return $value; }); $this->subject->getValidator()->append('offset1', 'string')->append('offset3', 'Neat\\Data\\Data'); }