Skip to content

Commit 64c1fc7

Browse files
PHP7 support (#2)
* Add test for php7 support * Bump sonar-php-plugin: not latest version, but the most recent with a compatible API and php7 support
1 parent f1963d3 commit 64c1fc7

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ dependencies {
3636
compile("com.github.codeclimate:sonar-wrapper:master-SNAPSHOT")
3737

3838
// Plugins
39-
compile("org.sonarsource.php:sonar-php-plugin:2.10.0.2087")
39+
compile("org.sonarsource.php:sonar-php-plugin:2.11.0.2485")
4040

4141
testCompile("org.assertj:assertj-core:2.8.0")
4242
testCompile("org.skyscreamer:jsonassert:1.5.0")

fixtures/app/config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"enabled": true,
33
"include_paths": [
4-
"main.php"
4+
"main.php",
5+
"php7_constants.php"
56
]
67
}

fixtures/app/php7_constants.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
class ConstDemo
3+
{
4+
const PUBLIC_CONST_A = 1;
5+
public const PUBLIC_CONST_B = 2;
6+
protected const PROTECTED_CONST = 3;
7+
private const PRIVATE_CONST = 4;
8+
}

src/test/resources/sanity_check_expected_issues.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,24 @@
3636
"categories": [
3737
"Bug Risk"
3838
]
39+
},
40+
{
41+
"type": "issue",
42+
"check_name": "php:S1068",
43+
"severity": "major",
44+
"description": "Remove this unused \"PRIVATE_CONST\" private field.",
45+
"content": {
46+
"body": "<p>If a <code>private</code> field is declared but not used in the program, it can be considered dead code and should therefore be removed. This will\nimprove maintainability because developers will not wonder what the variable is used for.</p>\n<h2>Noncompliant Code Example</h2>\n<pre>\nclass MyClass {\n private $foo = 4; //foo is unused\n\n public function compute($a) {\n return $a * 4;\n }\n}\n</pre>\n<h2>Compliant Solution</h2>\n<pre>\nclass MyClass {\n\n public function compute($a) {\n return $a * 4;\n }\n}\n</pre>\n<h2>See</h2>\n<ul>\n <li> <a href=\"https://www.securecoding.cert.org/confluence/x/SIIyAQ\">CERT, MSC12-CPP.</a> - Detect and remove code that has no effect </li>\n</ul>"
47+
},
48+
"location": {
49+
"path": "php7_constants.php",
50+
"lines": {
51+
"begin": 7,
52+
"end": 7
53+
}
54+
},
55+
"categories": [
56+
"Clarity"
57+
]
3958
}
4059
]

0 commit comments

Comments
 (0)