| Total Complexity | 8 |
| Total Lines | 67 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | abstract class Parameter { |
||
| 8 | |||
| 9 | protected static $name; |
||
| 10 | /** |
||
| 11 | * 索引名 |
||
| 12 | * |
||
| 13 | * @var string |
||
| 14 | */ |
||
| 15 | protected $indexName; |
||
| 16 | /** |
||
| 17 | * 默认值 |
||
| 18 | * |
||
| 19 | * @var mixed |
||
| 20 | */ |
||
| 21 | protected $default; |
||
| 22 | |||
| 23 | public static function name():string { |
||
| 24 | return static::$name; |
||
| 25 | } |
||
| 26 | |||
| 27 | public static function build(string $indexName, string $extra):Parameter { |
||
| 28 | $parameter = new static($extra); |
||
|
|
|||
| 29 | $parameter->setIndexName($indexName); |
||
| 30 | return $parameter; |
||
| 31 | } |
||
| 32 | |||
| 33 | public function getValue(string $matched) { |
||
| 34 | return $matched; |
||
| 35 | } |
||
| 36 | |||
| 37 | public function getDefaultValue() { |
||
| 38 | return isset($this->default) ? $this->default : null; |
||
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * 获取匹配字符串 |
||
| 43 | * |
||
| 44 | * @return string |
||
| 45 | */ |
||
| 46 | abstract function getMatch():string; |
||
| 47 | |||
| 48 | public function getCommonDefault(string $extra):string { |
||
| 49 | return $extra; |
||
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Get 索引名 |
||
| 54 | * |
||
| 55 | * @return string |
||
| 56 | */ |
||
| 57 | public function getIndexName() |
||
| 58 | { |
||
| 59 | return $this->indexName; |
||
| 60 | } |
||
| 61 | |||
| 62 | /** |
||
| 63 | * Set 索引名 |
||
| 64 | * |
||
| 65 | * @param string $indexName 索引名 |
||
| 66 | * |
||
| 67 | * @return self |
||
| 68 | */ |
||
| 69 | public function setIndexName(string $indexName) |
||
| 74 | } |
||
| 75 | } |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.