| @@ 32-40 (lines=9) @@ | ||
| 29 | * |
|
| 30 | * @return void |
|
| 31 | */ |
|
| 32 | public function testFunctionsThatShouldntBeFlagged() |
|
| 33 | { |
|
| 34 | $file = $this->sniffFile(self::TEST_FILE, '5.3'); |
|
| 35 | ||
| 36 | $this->assertNoViolation($file, 4); |
|
| 37 | $this->assertNoViolation($file, 5); |
|
| 38 | $this->assertNoViolation($file, 6); |
|
| 39 | $this->assertNoViolation($file, 7); |
|
| 40 | } |
|
| 41 | ||
| 42 | ||
| 43 | /** |
|
| @@ 40-47 (lines=8) @@ | ||
| 37 | * |
|
| 38 | * @return void |
|
| 39 | */ |
|
| 40 | public function testGroupUseDeclaration($line) |
|
| 41 | { |
|
| 42 | $file = $this->sniffFile(self::TEST_FILE, '5.6'); |
|
| 43 | $this->assertError($file, $line, 'Group use declarations are not allowed in PHP 5.6 or earlier'); |
|
| 44 | ||
| 45 | $file = $this->sniffFile(self::TEST_FILE, '7.0'); |
|
| 46 | $this->assertNoViolation($file, $line); |
|
| 47 | } |
|
| 48 | ||
| 49 | /** |
|
| 50 | * Data provider. |
|
| @@ 26-33 (lines=8) @@ | ||
| 23 | * |
|
| 24 | * @return void |
|
| 25 | */ |
|
| 26 | public function testFunctionThatShouldntBeFlagged() |
|
| 27 | { |
|
| 28 | $file = $this->sniffFile(self::TEST_FILE, '5.1'); |
|
| 29 | ||
| 30 | $this->assertNoViolation($file, 3); |
|
| 31 | $this->assertNoViolation($file, 4); |
|
| 32 | $this->assertNoViolation($file, 5); |
|
| 33 | } |
|
| 34 | ||
| 35 | ||
| 36 | /** |
|
| @@ 27-34 (lines=8) @@ | ||
| 24 | * |
|
| 25 | * @return void |
|
| 26 | */ |
|
| 27 | public function testNamespaceSeparator() |
|
| 28 | { |
|
| 29 | $file = $this->sniffFile(self::TEST_FILE, '5.2'); |
|
| 30 | $this->assertError($file, 3, 'the \ operator (for namespaces) is not present in PHP version 5.2 or earlier'); |
|
| 31 | ||
| 32 | $file = $this->sniffFile(self::TEST_FILE, '5.3'); |
|
| 33 | $this->assertNoViolation($file, 3); |
|
| 34 | } |
|
| 35 | ||
| 36 | /** |
|
| 37 | * testPow |
|
| @@ 43-50 (lines=8) @@ | ||
| 40 | * |
|
| 41 | * @return void |
|
| 42 | */ |
|
| 43 | public function testPow() |
|
| 44 | { |
|
| 45 | $file = $this->sniffFile(self::TEST_FILE, '5.5'); |
|
| 46 | $this->assertError($file, 5, "power operator (**) is not present in PHP version 5.5 or earlier"); |
|
| 47 | ||
| 48 | $file = $this->sniffFile(self::TEST_FILE, '5.6'); |
|
| 49 | $this->assertNoViolation($file, 5); |
|
| 50 | } |
|
| 51 | ||
| 52 | /** |
|
| 53 | * testPowEquals |
|
| @@ 59-66 (lines=8) @@ | ||
| 56 | * |
|
| 57 | * @return void |
|
| 58 | */ |
|
| 59 | public function testPowEquals() |
|
| 60 | { |
|
| 61 | $file = $this->sniffFile(self::TEST_FILE, '5.5'); |
|
| 62 | $this->assertError($file, 6, "power assignment operator (**=) is not present in PHP version 5.5 or earlier"); |
|
| 63 | ||
| 64 | $file = $this->sniffFile(self::TEST_FILE, '5.6'); |
|
| 65 | $this->assertNoViolation($file, 6); |
|
| 66 | } |
|
| 67 | ||
| 68 | /** |
|
| 69 | * testSpaceship |
|
| @@ 75-82 (lines=8) @@ | ||
| 72 | * |
|
| 73 | * @return void |
|
| 74 | */ |
|
| 75 | public function testSpaceship() |
|
| 76 | { |
|
| 77 | $file = $this->sniffFile(self::TEST_FILE, '5.6'); |
|
| 78 | $this->assertError($file, 12, "spaceship operator (<=>) is not present in PHP version 5.6 or earlier"); |
|
| 79 | ||
| 80 | $file = $this->sniffFile(self::TEST_FILE, '7.0'); |
|
| 81 | $this->assertNoViolation($file, 12); |
|
| 82 | } |
|
| 83 | ||
| 84 | /** |
|
| 85 | * Coalescing operator |
|
| @@ 109-116 (lines=8) @@ | ||
| 106 | * |
|
| 107 | * @return void |
|
| 108 | */ |
|
| 109 | public function testEllipsis() |
|
| 110 | { |
|
| 111 | $file = $this->sniffFile(self::TEST_FILE, '5.5'); |
|
| 112 | $this->assertError($file, 14, "variadic functions using ... is not present in PHP version 5.5 or earlier"); |
|
| 113 | ||
| 114 | $file = $this->sniffFile(self::TEST_FILE, '5.6'); |
|
| 115 | $this->assertNoViolation($file, 14); |
|
| 116 | } |
|
| 117 | } |
|
| 118 | ||
| @@ 31-38 (lines=8) @@ | ||
| 28 | * |
|
| 29 | * @return void |
|
| 30 | */ |
|
| 31 | public function testForbiddenSwitchWithMultipleDefaultBlocks($line) |
|
| 32 | { |
|
| 33 | $file = $this->sniffFile(self::TEST_FILE, '5.6'); |
|
| 34 | $this->assertNoViolation($file, $line); |
|
| 35 | ||
| 36 | $file = $this->sniffFile(self::TEST_FILE, '7.0'); |
|
| 37 | $this->assertError($file, $line, 'Switch statements can not have multiple default blocks since PHP 7.0'); |
|
| 38 | } |
|
| 39 | ||
| 40 | /** |
|
| 41 | * Data provider. |
|
| @@ 31-38 (lines=8) @@ | ||
| 28 | * |
|
| 29 | * @return void |
|
| 30 | */ |
|
| 31 | public function testLateStaticBinding($line) |
|
| 32 | { |
|
| 33 | $file = $this->sniffFile(self::TEST_FILE, '5.2'); |
|
| 34 | $this->assertError($file, $line, 'Late static binding is not supported in PHP 5.2 or earlier.'); |
|
| 35 | ||
| 36 | $file = $this->sniffFile(self::TEST_FILE, '5.3'); |
|
| 37 | $this->assertNoViolation($file, $line); |
|
| 38 | } |
|
| 39 | ||
| 40 | /** |
|
| 41 | * Data provider. |
|
| @@ 36-45 (lines=10) @@ | ||
| 33 | * |
|
| 34 | * @return void |
|
| 35 | */ |
|
| 36 | public function testParameterShadowSuperGlobal($superglobal, $line) |
|
| 37 | { |
|
| 38 | ||
| 39 | $file = $this->sniffFile(self::TEST_FILE, '5.3'); |
|
| 40 | $this->assertNoViolation($file, $line); |
|
| 41 | ||
| 42 | ||
| 43 | $file = $this->sniffFile(self::TEST_FILE, '5.4'); |
|
| 44 | $this->assertError($file, $line, "Parameter shadowing super global ({$superglobal}) causes fatal error since PHP 5.4"); |
|
| 45 | } |
|
| 46 | ||
| 47 | /** |
|
| 48 | * dataParameterShadowSuperGlobals |
|
| @@ 31-38 (lines=8) @@ | ||
| 28 | * |
|
| 29 | * @return void |
|
| 30 | */ |
|
| 31 | public function testEmptyNonVariable($line) |
|
| 32 | { |
|
| 33 | $file = $this->sniffFile(self::TEST_FILE, '5.4'); |
|
| 34 | $this->assertError($file, $line, 'Only variables can be passed to empty() prior to PHP 5.5.'); |
|
| 35 | ||
| 36 | $file = $this->sniffFile(self::TEST_FILE, '5.5'); |
|
| 37 | $this->assertNoViolation($file, $line); |
|
| 38 | } |
|
| 39 | ||
| 40 | /** |
|
| 41 | * Data provider. |
|