forked from laminas/laminas-code
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Nullable flag on constructor property promotion, closes laminas#183
Signed-off-by: Grundik <[email protected]>
- Loading branch information
Showing
5 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace LaminasTest\Code\Generator; | ||
|
||
use Laminas\Code\Generator\PromotedParameterGenerator; | ||
use Laminas\Code\Reflection\ParameterReflection; | ||
use LaminasTest\Code\TestAsset\ClassWithPromotedProperties; | ||
use PHPUnit\Framework\Attributes\Group; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
#[Group('Laminas_Code_Generator')] | ||
#[Group('Laminas_Code_Generator_Php')] | ||
class PromotedParameterGeneratorTest extends TestCase | ||
{ | ||
public function testfromParameterGeneratorWithVisibility() | ||
{ | ||
$parameterReflection = new ParameterReflection([ClassWithPromotedProperties::class, '__construct'], 0); | ||
|
||
$generator = PromotedParameterGenerator::fromReflection($parameterReflection); | ||
|
||
$this->assertSame('protected ?int $nullable', $generator->generate()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace LaminasTest\Code\TestAsset; | ||
|
||
/** | ||
* Class with a promoted constructor properties | ||
* | ||
* @license MIT | ||
*/ | ||
class ClassWithPromotedProperties | ||
{ | ||
public function __construct( | ||
protected ?int $nullable | ||
) { | ||
} | ||
} |