public function visit($parent, &$tokens, $handle = [], $eldnah = null) { $visibilty = $handle; $value = $this->getUntilValue($tokens, ['{', ';']); $c = array_pop($value); $name = $this->getUntilValue($value, '('); $args = $this->getTokensBetweenValue($value, '(', ')'); array_pop($args); array_pop($args); array_unshift($value, array_pop($name)); array_unshift($tokens, $c); //$this->_parseArgs($args); $content = $this->getTokensBetweenValue($tokens, '{', '}'); $args = $this->extractArgs($args); foreach ($args as $key => $value) { $args[$key] = trim($value); } $visibilty = $this->concat($visibilty); $isStatic = false; if (preg_match('#static#', $visibilty)) { $isStatic = true; $visibilty = str_replace('static', '', $visibilty); $visibilty = trim($visibilty); } if ($visibilty === '') { $visibilty = 'public'; } \Sohapi\Parser\Model::getInstance()->setMethod($visibilty, $isStatic, $this->concat($name), count($args) === 0 ? ['void'] : $args); }
public function testClass() { $source = '<?php class Hello {}'; $object = new \Sohapi\Parser\Reader($source); $this->object($object)->isInstanceOf('Sohapi\\Parser\\Reader')->array($object->getTokens())->hasSize(7)->string[0][1]->isIdenticalTo('<?php ')->string[3][1]->isIdenticalTo('Hello'); $this->integer($object->build())->isIdenticalTo(0); $storage = \Sohapi\Parser\Model::getInstance(); $this->namespace->get()->contains(''); $this->class->get('')->contains('Hello'); }
public function __construct($arguments = []) { $ast = \Sohapi\Parser\Model::getInstance(); $this->_namespace = $ast->getNamespace(); $this->_classe = $ast->getClasse(); $this->_interface = $ast->getInterface(); $this->_abstract = $ast->getAbstract(); $this->_properties = $ast->getProperties(); $this->_methods = $ast->getMethods(); $this->_use = $ast->getUse(); $this->_alias = $ast->getAlias(); $this->_arguments = $arguments; }
public function visit($parent, &$tokens, $handle = [], $eldnah = null) { $deps = $this->getUntilValue($tokens, '{'); $separator = array_pop($deps); array_unshift($tokens, $separator); $name = $this->getUntilToken($deps, ['T_EXTENDS', 'T_IMPLEMENTS']); $a = array_pop($name); array_unshift($deps, $a); \Sohapi\Parser\Model::getInstance()->setInterface($this->concat($name), trim($this->concat($deps))); // TODO : Différencier le Extends et Implements $content = $this->getTokensBetweenValue($tokens, '{', '}'); array_shift($content); $this->dispatch($content); }
public function visit($parent, &$tokens, $handle = [], $eldnah = null) { $buffer = $this->getUntilValue($tokens, ['{', ';']); $separator = array_pop($buffer); $ns = trim($this->concat($buffer)); \Sohapi\Parser\Model::getInstance()->setNamespace($ns); if ($separator[1] === '{') { array_unshift($tokens, $separator); $content = $this->getTokensBetweenValue($tokens, '{', '}'); $parent->dispatch($content); } else { $parent->dispatch($tokens); } }
protected function parse($use) { $last = array_pop($use); $name = ''; $as = ''; if ($this->tokenExists($use, 'T_AS') === true) { $name = $this->getUntilToken($use, 'T_AS'); array_pop($name); $name = $this->concat($name); $as = $this->concat($use); } else { $name = $this->concat($use); } \Sohapi\Parser\Model::getInstance()->setUse($name, $as); }
public function visit($parent, &$tokens, $handle = [], $eldnah = null) { $a = $tokens; $aliased = []; while ($this->valueExists($a, 'class_alias')) { $this->getUntilValue($a, 'class_alias'); $b = $this->getUntilValue($a, ';'); $alias = $this->getTokensBetweenValue($b, '(', ')'); $class = $this->getUntilValue($alias, ','); $class = substr($this->getToken($class, 'T_CONSTANT_ENCAPSED_STRING'), 1, -1); $alias = substr($this->getToken($alias, 'T_CONSTANT_ENCAPSED_STRING'), 1, -1); \Sohapi\Parser\Model::getInstance()->setAlias($alias, $class); } unset($a, $b, $alias, $class); $this->dispatch($tokens, $handle, $eldnah); }
public function visit($parent, &$tokens, $handle = [], $eldnah = null) { $visibilty = $handle; $name = strval($eldnah[1]); $value = $this->getUntilValue($tokens, ';'); $visibilty = $this->concat($visibilty); $isStatic = false; if (preg_match('#static#', $visibilty)) { $isStatic = true; $visibilty = str_replace('static', '', $visibilty); $visibilty = trim($visibilty); } if ($visibilty === '') { $visibilty = 'public'; } \Sohapi\Parser\Model::getInstance()->setProperty($visibilty, $isStatic, $name, $this->concat($value)); $parent->dispatch($tokens); }
public function visit($parent, &$tokens, $handle = [], $eldnah = null) { $deps = $this->getUntilValue($tokens, '{'); $separator = array_pop($deps); array_unshift($tokens, $separator); $name = $this->getUntilToken($deps, ['T_EXTENDS', 'T_IMPLEMENTS']); $a = array_pop($name); if ($a[0] === 'T_STRING') { $name[] = $a; } $extends = []; $implements = []; //array_unshift($deps, $a); if ($a[0] === 'T_EXTENDS') { $extends = $this->getUntilToken($deps, 'T_IMPLEMENTS'); if ($this->tokenExists($extends, 'T_IMPLEMENTS') === true) { array_pop($extends); } $implements = $deps; } if ($a[0] === 'T_IMPLEMENTS') { $implements = $this->getUntilToken($deps, 'T_EXTENDS'); if ($this->tokenExists($implements, 'T_EXTENDS') === true) { array_pop($implements); } $extends = $deps; } if ($this->_abstract === false) { \Sohapi\Parser\Model::getInstance()->setClasse($this->concat($name), trim($this->concat($extends)), trim($this->concat($implements))); } else { \Sohapi\Parser\Model::getInstance()->setAbstract($this->concat($name), trim($this->concat($extends)), trim($this->concat($implements))); } $content = $this->getTokensBetweenValue($tokens, '{', '}'); array_shift($content); $this->dispatch($content); }
public function visit($parent, &$tokens, $handle = [], $eldnah = null) { \Sohapi\Parser\Model::getInstance()->setComment($eldnah[1]); $parent->dispatch($tokens); }
public function __construct(asserter\generator $generator = null, tools\variable\analyzer $analyzer = null, atoum\locale $locale = null) { parent::__construct($generator, $analyzer, $locale); $this->_data = \Sohapi\Parser\Model::getInstance()->getAll(); }