Skip to content

Commit

Permalink
Merge pull request #829 from PHPCompatibility/feature/newtypedpropert…
Browse files Browse the repository at this point in the history
…ies-tweak-unittests

NewTypedProperties: add some additional unit tests
  • Loading branch information
wimg committed Jun 27, 2019
2 parents 74e3262 + 745b598 commit fd781d5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class PHP73Example {
// Intentional parse error.
$invalidProperty;

public function method($param) {
// Typed function parameter, not property.
public function method(?int $param) {
$localVar = 'abc';
}
}
Expand Down Expand Up @@ -52,6 +53,9 @@ class PHP74Example {
// Note: The RFC does not explicitely mention this syntax.
// @tod This needs verification once the alpha is out.
static bool $bool = true;

// Test reversed keyword order.
static public int $int = 0;
}

// Invalid property types.
Expand Down
33 changes: 17 additions & 16 deletions PHPCompatibility/Tests/Classes/NewTypedPropertiesUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,22 @@ public function testNewTypedProperties($line)
public function dataNewTypedProperties()
{
return array(
array(22),
array(23),
array(24),
array(27),
array(30),
array(33),
array(25),
array(28),
array(31),
array(34),
array(37),
array(40),
array(48),
array(50),
array(54),
array(59),
array(60),
array(61),
array(35),
array(38),
array(41),
array(49),
array(51),
array(55),
array(58),
array(63),
array(64),
array(65),
);
}

Expand All @@ -78,7 +79,7 @@ public function testNoFalsePositivesNewTypedProperties()
{
$file = $this->sniffFile(__FILE__, '7.3');

for ($line = 1; $line < 18; $line++) {
for ($line = 1; $line < 19; $line++) {
$this->assertNoViolation($file, $line);
}
}
Expand Down Expand Up @@ -110,9 +111,9 @@ public function testInvalidPropertyType($line, $type)
public function dataInvalidPropertyType()
{
return array(
array(59, 'void'),
array(60, 'callable'),
array(61, 'callable'),
array(63, 'void'),
array(64, 'callable'),
array(65, 'callable'),
);
}

Expand Down

0 comments on commit fd781d5

Please sign in to comment.