public function isPassthroughAttribute($attr) { $key = get_class($this); if (!array_key_exists($key, self::$ownAttributes)) { $ref = new \ReflectionClass($key); self::$ownAttributes[$key] = []; foreach ($ref->getProperties(\ReflectionProperty::IS_PUBLIC) as $prop) { if ($prop->isStatic()) { continue; } self::$ownAttributes[$key][$prop->name] = $prop; } } if (empty(self::$ownAttributes[$key][$attr])) { return true; } $ref = self::$ownAttributes[$key][$attr]; if ($ref->isPublic() && $ref->isDefault() && !$ref->isStatic()) { $comment = new DocComment($ref->getDocComment()); if ($comment->hasTag('passthrough')) { return true; } } return false; }
protected function populateField(\ReflectionProperty $prop, InputInterface $input) { $comment = new DocComment($prop->getDocComment()); $defaults = $prop->getDeclaringClass()->getDefaultProperties(); if ($comment->hasTag('argument')) { $arg = $input->getArgument((int) $comment->getTagValue('argument'), NULL); if ($arg === NULL) { $arg = $defaults[$prop->name]; } $this->{$prop->name} = $arg; } elseif ($comment->hasTag('option')) { $shorty = (string) $comment->getTagValue('option'); if ($shorty !== '' && $input->hasOption($shorty)) { $this->{$prop->name} = $input->getOption($shorty); return; } $this->{$prop->name} = $input->getOption($prop->name, $defaults[$prop->name]); } }
public function parseFile($file, $key = NULL) { $mtime = filemtime($file); $hash = md5($file) . dechex(strlen($file)); $sql = 'SELECT * FROM "meta_file" WHERE "hash" = :hash AND "mtime" >= :mtime LIMIT 1'; $stmt = $this->pdo->prepare($sql); $stmt->bindValue('hash', $hash); $stmt->bindValue('mtime', $mtime); $stmt->execute(); $row = $stmt->fetch(\PDO::FETCH_ASSOC); if ($row !== false) { return new MetaFile($row['hash'], $row['location'], $row['mtime'], unserialize(gzdecode($row['storage'])), unserialize(gzdecode($row['buffer']))); } $storage = new ArraySourceStorage(); $parser = new SourceParser(); $buffer = $parser->parse(SourceStream::fromUrl($file), $storage); $this->insertFileStmt->execute(['hash' => $hash, 'location' => $file, 'mtime' => $mtime, 'key' => $key, 'storage' => gzencode(serialize($storage), 1), 'buffer' => gzencode(serialize($buffer), 1)]); foreach ($storage->getTypes() as $type) { $typeInfo = new ParsedTypeInfo($type, [], []); $this->insertTypeStmt->execute(['name' => $typeInfo->getName(), 'file' => $hash, 'mod' => MetaInfo::getTypeModifiers($typeInfo), 'mtime' => $mtime, 'data' => gzencode(serialize($type), 1)]); foreach ($type->getSupertypes() as $supertype) { $this->insertSupertypeStmt->execute(['super' => $supertype, 'sub' => $typeInfo->getName()]); } foreach ($typeInfo->getAnnotationCandidates() as $anno) { $this->insertTypeAnnotationStmt->execute(['type' => $typeInfo->getName(), 'anno' => $anno]); } foreach ($storage->getFields($type) as $field) { $fieldInfo = new ParsedFieldInfo($typeInfo, $field); $this->insertFieldStmt->execute(['type' => $type->getName(), 'field' => $fieldInfo->getName(), 'mod' => MetaInfo::getFieldModifiers($fieldInfo)]); foreach ($fieldInfo->getAnnotationCandidates() as $anno) { $this->insertFieldAnnotationStmt->execute(['type' => $typeInfo->getName(), 'field' => $field->getName(), 'anno' => $anno]); } } foreach ($storage->getMethods($type) as $method) { $methodInfo = new ParsedMethodInfo($typeInfo, $method); $this->insertMethodStmt->execute(['type' => $type->getName(), 'method' => $methodInfo->getName(), 'mod' => MetaInfo::getMethodModifiers($methodInfo)]); foreach ($methodInfo->getAnnotationCandidates() as $anno) { $this->insertMethodAnnotationStmt->execute(['type' => $type->getName(), 'method' => $methodInfo->getName(), 'anno' => $anno]); } } $comment = new DocComment($type->getComment()); foreach ($comment->getTagValues('merge') as $group) { $this->insertMergeGroupStmt->execute(['type' => $typeInfo->getName(), 'group' => trim($group)]); } $this->typeCache[strtolower($type->getName())] = new ParsedTypeInfo($type, $storage->getFields($type), $storage->getMethods($type)); } return new MetaFile($hash, $file, $mtime, $storage, $buffer); }