Skip to content

Commit 3123c3d

Browse files
committed
#2 - Add PHPCA version constraint + PHPCA options
1 parent 169f680 commit 3123c3d

File tree

6 files changed

+54
-5
lines changed

6 files changed

+54
-5
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ With:
6767
| phpmnd.ignore-funcs | _null_ | PHP Magic Number Detector | List (comma separate) of function to ignore |
6868
| phpmnd.ignore-strings | _null_ | PHP Magic Number Detector | List (comma separate) of strings value to ignore |
6969
| phpmnd.strings | `false` | PHP Magic Number Detector | Activate the strings literal analysis |
70+
| phpca.since | _null_ | PhpCodeAnalyzer | Only include extensions not included since version |
71+
| phpca.extension | _null_ | PhpCodeAnalyzer | Look for usage of a specific extension |
7072

7173
## How to contribute
7274

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"require-dev": {
2626
"povils/phpmnd": "^2.0",
2727
"rskuipers/php-assumptions": "^0.7.0",
28-
"wapmorgan/php-code-analyzer": "dev-master"
28+
"wapmorgan/php-code-analyzer": "^1.0.5"
2929
},
3030
"suggest": {
3131
"povils/phpmnd": "PHP Magic Number Detector",

src/ToolDefinition.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,10 @@ public static function getCliName();
3939
* @return string
4040
*/
4141
public static function getInternalClass();
42+
43+
/**
44+
* Return the global tool settings.
45+
* @return array
46+
*/
47+
public static function getToolSettings();
4248
}

src/Tools/Analyzer/PhpAssumptions.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function __invoke()
4646
*/
4747
public static function getComposer()
4848
{
49-
return static::$SETTINGS['composer'];
49+
return static::getToolSettings()['composer'];
5050
}
5151

5252
/**
@@ -87,6 +87,16 @@ public static function getCliName()
8787
*/
8888
public static function getInternalClass()
8989
{
90-
return static::$SETTINGS['internalClass'];
90+
return static::getToolSettings()['internalClass'];
91+
}
92+
93+
/**
94+
* Return the global tool settings.
95+
*
96+
* @return array
97+
*/
98+
public static function getToolSettings()
99+
{
100+
return self::$SETTINGS;
91101
}
92102
}

src/Tools/Analyzer/PhpCodeAnalyzer.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@ public function __invoke()
2828
$args['output'] = $this->options->rawFile('php-code-analyzer.xml');
2929
}
3030

31+
$sinceVersion = $this->config->value('phpca.since');
32+
$extension = $this->config->value('phpca.extension');
33+
34+
if ($sinceVersion !== null) {
35+
$args['since-version'] = $sinceVersion;
36+
}
37+
38+
if ($extension !== null) {
39+
$args['extension'] = $extension;
40+
}
41+
3142
return $args;
3243
}
3344

@@ -81,4 +92,14 @@ public static function getInternalClass()
8192
{
8293
return 'wapmorgan\PhpCodeAnalyzer\PhpCodeAnalyzer';
8394
}
95+
96+
/**
97+
* Return the global tool settings.
98+
*
99+
* @return array
100+
*/
101+
public static function getToolSettings()
102+
{
103+
return self::$SETTINGS;
104+
}
84105
}

src/Tools/Analyzer/PhpMagicNumber.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function __invoke()
7272
*/
7373
public static function getComposer()
7474
{
75-
return static::$SETTINGS['composer'];
75+
return static::getToolSettings()['composer'];
7676
}
7777

7878
/**
@@ -113,6 +113,16 @@ public static function getCliName()
113113
*/
114114
public static function getInternalClass()
115115
{
116-
return static::$SETTINGS['internalClass'];
116+
return static::getToolSettings()['internalClass'];
117+
}
118+
119+
/**
120+
* Return the global tool settings.
121+
*
122+
* @return array
123+
*/
124+
public static function getToolSettings()
125+
{
126+
return self::$SETTINGS;
117127
}
118128
}

0 commit comments

Comments
 (0)