Completed
Push — branch-7.5 ( 0b488c...075cf7 )
by
unknown
131:54 queued 123:20
created

Declaration::get_params_as_string()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 1
nop 0
dl 0
loc 14
rs 9.7998
c 0
b 0
f 0
1
<?php
2
3
namespace Automattic\Jetpack\Analyzer\Declarations;
4
5
use Automattic\Jetpack\Analyzer\PersistentList\Item as PersistentListItem;
6
7
abstract class Declaration extends PersistentListItem {
8
	public $path;
9
	public $line;
10
11
	function __construct( $path, $line ) {
12
		$this->path = $path;
13
		$this->line = $line;
14
	}
15
16
	function match( $other ) {
17
		return get_class( $other ) === get_class( $this )
18
			&& $other->display_name() === $this->display_name(); // hack
19
	}
20
21
	function partial_match( $other ) {
22
		// TODO
23
		return false;
24
	}
25
26
	// a simple name, like 'method'
27
	abstract function type();
28
29
	// e.g. Jetpack::get_file_url_for_environment()
30
	abstract function display_name();
31
32
	// utility function
33
	protected function get_params_as_string() {
34
		return implode(
35
			',',
36
			array_map(
37
				function( $param ) {
38
					if ( ! empty( $param->default ) ) {
39
						  return '$' . $param->name . '=' . $param->default;
40
					}
41
					return '$' . $param->name;
42
				},
43
				$this->params
0 ignored issues
show
Bug introduced by
The property params does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
44
			)
45
		);
46
	}
47
}
48