PHPSA\Definition\ClassDefinition::addProperty PHP Method

addProperty() public method

public addProperty ( Property $property )
$property PhpParser\Node\Stmt\Property
    public function addProperty(Node\Stmt\Property $property)
    {
        foreach ($property->props as $propertyDefinition) {
            $this->properties[$propertyDefinition->name] = $propertyDefinition;
        }
        $this->propertyStatements[$propertyDefinition->name] = $property;
    }

Usage Example

Example #1
0
 protected function parseTopDefinitions($topStatement, $aliasManager, $filepath, $namespace)
 {
     foreach ($topStatement as $statement) {
         if ($statement instanceof Node\Stmt\Use_) {
             if (!empty($statement->uses)) {
                 foreach ($statement->uses as $use) {
                     $aliasManager->add($use->name->parts);
                 }
             }
         } elseif ($statement instanceof Node\Stmt\Class_) {
             $definition = new ClassDefinition($statement->name, $statement->type);
             $definition->setFilepath($filepath);
             $definition->setNamespace($namespace);
             foreach ($statement->stmts as $stmt) {
                 if ($stmt instanceof Node\Stmt\ClassMethod) {
                     $method = new ClassMethod($stmt->name, $stmt, $stmt->type);
                     $definition->addMethod($method);
                 } elseif ($stmt instanceof Node\Stmt\Property) {
                     $definition->addProperty($stmt);
                 } elseif ($stmt instanceof Node\Stmt\ClassConst) {
                     $definition->addConst($stmt);
                 }
             }
             $this->getCompiler()->addClass($definition);
         } elseif ($statement instanceof Node\Stmt\Function_) {
             $definition = new FunctionDefinition($statement->name, $statement);
             $definition->setFilepath($filepath);
             $definition->setNamespace($namespace);
             $this->getCompiler()->addFunction($definition);
         }
     }
 }
All Usage Examples Of PHPSA\Definition\ClassDefinition::addProperty