Skip to content

Commit

Permalink
PHP 8.0 | PEAR/ValidDefaultValue: add tests with constructor property…
Browse files Browse the repository at this point in the history
… promotion

The sniff already handles this correctly. This just adds some tests to confirm it and safeguard it for the future.
  • Loading branch information
jrfnl committed Mar 16, 2021
1 parent 6e0df17 commit 43feac1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Standards/PEAR/Tests/Functions/ValidDefaultValueUnitTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,20 @@ $closure = function(array $arg2=array(), array $arg1) {}

$fn = fn($a = [], $b) => $a[] = $b;

class OnlyConstructorPropertyPromotion {
public function __construct(
public string $name = '',
protected $bar
) {}
}

class ConstructorPropertyPromotionMixedWithNormalParams {
public function __construct(
public string $name = '',
?int $optionalParam = 0,
mixed $requiredParam,
) {}
}

// Intentional syntax error. Must be last thing in the file.
function
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public function getErrorList()
91 => 1,
99 => 1,
101 => 1,
106 => 1,
114 => 1,
];

}//end getErrorList()
Expand Down

0 comments on commit 43feac1

Please sign in to comment.