| @@ 16-33 (lines=18) @@ | ||
| 13 | * @package PHPCompatibility |
|
| 14 | * @author Wim Godden <[email protected]> |
|
| 15 | */ |
|
| 16 | class ForbiddenEmptyListAssignmentSniffTest extends BaseSniffTest |
|
| 17 | { |
|
| 18 | /** |
|
| 19 | * Verify that checking for a specific version works |
|
| 20 | * |
|
| 21 | * @return void |
|
| 22 | */ |
|
| 23 | public function testEmptyListAssignment() |
|
| 24 | { |
|
| 25 | $file = $this->sniffFile('sniff-examples/forbidden_empty_list_assignment.php', '5.6'); |
|
| 26 | $this->assertNoViolation($file, 3); |
|
| 27 | $this->assertNoViolation($file, 5); |
|
| 28 | ||
| 29 | $file = $this->sniffFile('sniff-examples/forbidden_empty_list_assignment.php', '7.0'); |
|
| 30 | $this->assertError($file, 3, "Empty list() assignments are not allowed since PHP 7.0"); |
|
| 31 | $this->assertError($file, 5, "Empty list() assignments are not allowed since PHP 7.0"); |
|
| 32 | } |
|
| 33 | } |
|
| 34 | ||
| @@ 16-33 (lines=18) @@ | ||
| 13 | * @package PHPCompatibility |
|
| 14 | * @author Wim Godden <[email protected]> |
|
| 15 | */ |
|
| 16 | class ForbiddenNegativeBitshiftSniffTest extends BaseSniffTest |
|
| 17 | { |
|
| 18 | /** |
|
| 19 | * testSettingTestVersion |
|
| 20 | * |
|
| 21 | * @return void |
|
| 22 | */ |
|
| 23 | public function testSettingTestVersion() |
|
| 24 | { |
|
| 25 | $file = $this->sniffFile('sniff-examples/forbidden_negative_bitshift.php', '5.6'); |
|
| 26 | $this->assertNoViolation($file, 3); |
|
| 27 | $this->assertNoViolation($file, 5); |
|
| 28 | ||
| 29 | $file = $this->sniffFile('sniff-examples/forbidden_negative_bitshift.php', '7.0'); |
|
| 30 | $this->assertError($file, 3, 'Bitwise shifts by negative number will throw an ArithmeticError in PHP 7.0'); |
|
| 31 | $this->assertNoViolation($file, 5); |
|
| 32 | } |
|
| 33 | } |
|
| 34 | ||
| 35 | ||
| @@ 16-34 (lines=19) @@ | ||
| 13 | * @package PHPCompatibility |
|
| 14 | * @author Wim Godden <[email protected]> |
|
| 15 | */ |
|
| 16 | class RemovedGlobalVariablesSniffTest extends BaseSniffTest |
|
| 17 | { |
|
| 18 | /** |
|
| 19 | * HTTP_RAW_POST_DATA |
|
| 20 | * |
|
| 21 | * @return void |
|
| 22 | */ |
|
| 23 | public function testHttpRawPostData() |
|
| 24 | { |
|
| 25 | $file = $this->sniffFile('sniff-examples/removed_global_variables.php', '5.5'); |
|
| 26 | $this->assertNoViolation($file); |
|
| 27 | ||
| 28 | $file = $this->sniffFile('sniff-examples/removed_global_variables.php', '5.6'); |
|
| 29 | $this->assertWarning($file, 3, "Global variable 'HTTP_RAW_POST_DATA' is deprecated since PHP 5.6 - use php://input instead"); |
|
| 30 | ||
| 31 | $file = $this->sniffFile('sniff-examples/removed_global_variables.php', '7.0'); |
|
| 32 | $this->assertError($file, 3, "Global variable 'HTTP_RAW_POST_DATA' is deprecated since PHP 5.6 and removed since PHP 7.0 - use php://input instead"); |
|
| 33 | } |
|
| 34 | } |
|
| 35 | ||
| @@ 15-46 (lines=32) @@ | ||
| 12 | * @package PHPCompatibility |
|
| 13 | * @author Koen Eelen <[email protected]> |
|
| 14 | */ |
|
| 15 | class DeprecatedPHP4StyleConstructorsSniffTest extends BaseSniffTest |
|
| 16 | { |
|
| 17 | /** |
|
| 18 | * Test PHP4 style constructors. |
|
| 19 | * |
|
| 20 | * @group deprecatedPHP4Constructors |
|
| 21 | * |
|
| 22 | * @return void |
|
| 23 | */ |
|
| 24 | public function testIsDeprecated() |
|
| 25 | { |
|
| 26 | $file = $this->sniffFile('sniff-examples/deprecated_php4style_constructors.php', '5.6'); |
|
| 27 | $this->assertNoViolation($file, 3); |
|
| 28 | ||
| 29 | $file = $this->sniffFile('sniff-examples/deprecated_php4style_constructors.php', '7.0'); |
|
| 30 | $this->assertError($file, 3, 'Deprecated PHP4 style constructor are not supported since PHP7'); |
|
| 31 | } |
|
| 32 | ||
| 33 | /** |
|
| 34 | * Test valid methods with the same name as the class. |
|
| 35 | * |
|
| 36 | * @group deprecatedPHP4Constructors |
|
| 37 | * |
|
| 38 | * @return void |
|
| 39 | */ |
|
| 40 | public function testValidMethods() |
|
| 41 | { |
|
| 42 | $file = $this->sniffFile('sniff-examples/deprecated_php4style_constructors.php', '7.0'); |
|
| 43 | $this->assertNoViolation($file, 9); |
|
| 44 | $this->assertNoViolation($file, 20); |
|
| 45 | } |
|
| 46 | } |
|
| 47 | ||