コード例 #1
0
 /**
  * Add property to class.
  *
  * @param string|ClassMemberListNode $property
  * @return $this
  */
 public function appendProperty($property)
 {
     if (is_string($property)) {
         $property = ClassMemberListNode::create($property);
     }
     $properties = $this->statements->children(Filter::isInstanceOf('\\Pharborist\\ClassMemberListNode'));
     if ($properties->count() === 0) {
         $this->statements->firstChild()->after($property);
     } else {
         $properties->last()->after($property);
     }
     FormatterFactory::format($this);
     return $this;
 }
コード例 #2
0
 public function testClassProperty()
 {
     $property = ClassMemberListNode::create('someProperty');
     $this->assertEquals('private $someProperty;', $property->getText());
     $property->setVisibility(Token::_protected());
     $this->assertEquals('protected $someProperty;', $property->getText());
 }