Code Duplication    Length = 21-23 lines in 2 locations

packages/analyzer/src/Analyzer.php 2 locations

@@ 154-176 (lines=23) @@
151
		$ast = $traverser->traverse( $ast );
152
	}
153
154
	public function enterNode( Node $node ) {
155
		if ( $node instanceof Node\Stmt\Class_ ) {
156
			// $this->current_class = $node->name->name;
157
			$this->current_class = implode( '\\', $node->namespacedName->parts );
158
159
			$this->add_declaration( new Class_Declaration( $this->current_relative_path, $node->getLine(), $node->name->name ) );
160
		}
161
		if ( $node instanceof Node\Stmt\Property && $node->isPublic() ) {
162
			$this->add_declaration( new Class_Property_Declaration( $this->current_relative_path, $node->getLine(), $this->current_class, $node->props[0]->name->name, $node->isStatic() ) );
163
		}
164
		if ( $node instanceof Node\Stmt\ClassMethod && $node->isPublic() ) {
165
			// ClassMethods are also listed inside interfaces, which means current_class is null
166
			// so we ignore these
167
			if ( ! $this->current_class ) {
168
				return;
169
			}
170
			$method = new Class_Method_Declaration( $this->current_relative_path, $node->getLine(), $this->current_class, $node->name->name, $node->isStatic() );
171
			foreach ( $node->getParams() as $param ) {
172
				$method->add_param( $param->var->name, $param->default, $param->type, $param->byRef, $param->variadic );
173
			}
174
			$this->add_declaration( $method );
175
		}
176
	}
177
178
	public function leaveNode( Node $node ) {
179
		if ( $node instanceof Node\Stmt\Class_ ) {
@@ 246-266 (lines=21) @@
243
		$this->analyzer = $analyzer;
244
	}
245
246
	public function enterNode( Node $node ) {
247
		if ( $node instanceof Node\Stmt\Class_ ) {
248
			$this->current_class = $node->name->name;
249
			$this->add_declaration( new Class_Declaration( $this->current_relative_path, $node->getLine(), $node->name->name ) );
250
		}
251
		if ( $node instanceof Node\Stmt\Property && $node->isPublic() ) {
252
			$this->add_declaration( new Class_Property_Declaration( $this->current_relative_path, $node->getLine(), $this->current_class, $node->props[0]->name->name, $node->isStatic() ) );
253
		}
254
		if ( $node instanceof Node\Stmt\ClassMethod && $node->isPublic() ) {
255
			// ClassMethods are also listed inside interfaces, which means current_class is null
256
			// so we ignore these
257
			if ( ! $this->current_class ) {
258
				return;
259
			}
260
			$method = new Class_Method_Declaration( $this->current_relative_path, $node->getLine(), $this->current_class, $node->name->name, $node->isStatic() );
261
			foreach ( $node->getParams() as $param ) {
262
				$method->add_param( $param->var->name, $param->default, $param->type, $param->byRef, $param->variadic );
263
			}
264
			$this->add_declaration( $method );
265
		}
266
	}
267
268
	public function leaveNode( Node $node ) {
269
		if ( $node instanceof Node\Stmt\Class_ ) {