History
Version 1013
at Saturday 26 December 2009 09:42:50 UTC - Implemented #104: Method isStatic() implemented on member primary prefix ast node.Diff
| 1011 | 1013 | /tests/PHP/Depend/_code/code/ASTMemberPrimaryPrefix/testClassPropertyMemberPrimaryPrefixIsStaticReturnsTrue.php |
|---|---|---|
| 2 | +<?php | |
| 3 | +function testClassPropertyMemberPrimaryPrefixIsStaticReturnsTrue() | |
| 4 | +{ | |
| 5 | + return stdClass::$foo; | |
| 6 | +} | |
| 1011 | 1013 | /tests/PHP/Depend/_code/code/ASTMemberPrimaryPrefix/testObjectMethodMemberPrimaryPrefixIsStaticReturnsFalse.php |
| 2 | +<?php | |
| 3 | +function testObjectMethodMemberPrimaryPrefixIsStaticReturnsFalse($object) | |
| 4 | +{ | |
| 5 | + return $object->bar(); | |
| 6 | +} | |
| 1011 | 1013 | /tests/PHP/Depend/_code/code/ASTMemberPrimaryPrefix/testClassMethodMemberPrimaryPrefixIsStaticReturnsTrue.php |
| 2 | +<?php | |
| 3 | +function testClassMethodMemberPrimaryPrefixIsStaticReturnsTrue() | |
| 4 | +{ | |
| 5 | + return stdClass::get(); | |
| 6 | +} | |
| 1011 | 1013 | /tests/PHP/Depend/_code/code/ASTMemberPrimaryPrefix/testObjectPropertyMemberPrimaryPrefixIsStaticReturnsFalse.php |
| 2 | +<?php | |
| 3 | +function testObjectPropertyMemberPrimaryPrefixIsStaticReturnsFalse($object) | |
| 4 | +{ | |
| 5 | + $object->foo = 42; | |
| 6 | +} | |
| 1011 | 1013 | /tests/PHP/Depend/Code/ASTMemberPrimaryPrefixTest.php |
| 69 | 69 | * Tests the start line of a member primary prefix. |
| 70 | 70 | * |
| 71 | 71 | * @return void |
| 72 | + * @covers PHP_Depend_Code_ASTNode::getStartLine | |
| 72 | 73 | * @group ast |
| 73 | 74 | */ |
| 74 | 75 | public function testObjectMemberPrimaryPrefixHasExpectedStartLine() |
| 81 | 82 | * Tests the start column of a member primary prefix. |
| 82 | 83 | * |
| 83 | 84 | * @return void |
| 85 | + * @covers PHP_Depend_Code_ASTNode::getStartColumn | |
| 84 | 86 | * @group ast |
| 85 | 87 | */ |
| 86 | 88 | public function testObjectMemberPrimaryPrefixHasExpectedStartColumn() |
| 88 | 90 | $prefix = $this->_getFirstMemberPrimaryPrefixInFunction(__METHOD__); |
| 89 | 91 | $this->assertSame(5, $prefix->getStartColumn()); |
| 90 | 92 | } |
| 93 | + | |
| 91 | 94 | /** |
| 92 | 95 | * Tests the end line of a member primary prefix. |
| 93 | 96 | * |
| 94 | 97 | * @return void |
| 98 | + * @covers PHP_Depend_Code_ASTNode::getEndLine | |
| 95 | 99 | * @group ast |
| 96 | 100 | */ |
| 97 | 101 | public function testObjectMemberPrimaryPrefixHasExpectedEndLine() |
| 104 | 108 | * Tests the end column of a member primary prefix. |
| 105 | 109 | * |
| 106 | 110 | * @return void |
| 111 | + * @covers PHP_Depend_Code_ASTNode::getEndColumn | |
| 107 | 112 | * @group ast |
| 108 | 113 | */ |
| 109 | 114 | public function testObjectMemberPrimaryPrefixHasExpectedEndColumn() |
| 113 | 118 | } |
| 114 | 119 | |
| 115 | 120 | /** |
| 121 | + * testObjectPropertyMemberPrimaryPrefixIsStaticReturnsFalse | |
| 122 | + * | |
| 123 | + * @return void | |
| 124 | + * @covers PHP_Depend_Code_ASTMemberPrimaryPrefix::isStatic | |
| 125 | + * @group ast | |
| 126 | + */ | |
| 127 | + public function testObjectPropertyMemberPrimaryPrefixIsStaticReturnsFalse() | |
| 128 | + { | |
| 129 | + $prefix = $this->_getFirstMemberPrimaryPrefixInFunction(__METHOD__); | |
| 130 | + $this->assertFalse($prefix->isStatic()); | |
| 131 | + } | |
| 132 | + | |
| 133 | + /** | |
| 134 | + * testObjectMethodMemberPrimaryPrefixIsStaticReturnsFalse | |
| 135 | + * | |
| 136 | + * @return void | |
| 137 | + * @covers PHP_Depend_Code_ASTMemberPrimaryPrefix::isStatic | |
| 138 | + * @group ast | |
| 139 | + */ | |
| 140 | + public function testObjectMethodMemberPrimaryPrefixIsStaticReturnsFalse() | |
| 141 | + { | |
| 142 | + $prefix = $this->_getFirstMemberPrimaryPrefixInFunction(__METHOD__); | |
| 143 | + $this->assertFalse($prefix->isStatic()); | |
| 144 | + } | |
| 145 | + | |
| 146 | + /** | |
| 147 | + * testClassPropertyMemberPrimaryPrefixIsStaticReturnsTrue | |
| 148 | + * | |
| 149 | + * @return void | |
| 150 | + * @covers PHP_Depend_Code_ASTMemberPrimaryPrefix::isStatic | |
| 151 | + * @group ast | |
| 152 | + */ | |
| 153 | + public function testClassPropertyMemberPrimaryPrefixIsStaticReturnsTrue() | |
| 154 | + { | |
| 155 | + $prefix = $this->_getFirstMemberPrimaryPrefixInFunction(__METHOD__); | |
| 156 | + $this->assertTrue($prefix->isStatic()); | |
| 157 | + } | |
| 158 | + | |
| 159 | + /** | |
| 160 | + * testClassMethodMemberPrimaryPrefixIsStaticReturnsTrue | |
| 161 | + * | |
| 162 | + * @return void | |
| 163 | + * @covers PHP_Depend_Code_ASTMemberPrimaryPrefix::isStatic | |
| 164 | + * @group ast | |
| 165 | + */ | |
| 166 | + public function testClassMethodMemberPrimaryPrefixIsStaticReturnsTrue() | |
| 167 | + { | |
| 168 | + $prefix = $this->_getFirstMemberPrimaryPrefixInFunction(__METHOD__); | |
| 169 | + $this->assertTrue($prefix->isStatic()); | |
| 170 | + } | |
| 171 | + | |
| 172 | + /** | |
| 116 | 173 | * Returns a test member primary prefix. |
| 117 | 174 | * |
| 118 | 175 | * @param string $testCase The calling test case. |
| 1011 | 1013 | /PHP/Depend/Code/ASTMemberPrimaryPrefix.php |
| 88 | 88 | * Type of this node class. |
| 89 | 89 | */ |
| 90 | 90 | const CLAZZ = __CLASS__; |
| 91 | + | |
| 92 | + /** | |
| 93 | + * Returns <b>true</b> when this member primary prefix represents a static | |
| 94 | + * property or method access. | |
| 95 | + * | |
| 96 | + * @return boolean | |
| 97 | + */ | |
| 98 | + public function isStatic() | |
| 99 | + { | |
| 100 | + return ($this->getImage() === '::'); | |
| 101 | + } | |
| 91 | 102 | } |