-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Conflicts: # src/Compiler/Mapper/Object/DelegateMapperCompiler.php
- Loading branch information
Showing
31 changed files
with
1,255 additions
and
56 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace ShipMonk\InputMapper\Compiler\Mapper; | ||
|
||
interface GenericMapperCompiler extends MapperCompiler | ||
{ | ||
|
||
/** | ||
* @return list<GenericMapperParameter> | ||
*/ | ||
public function getGenericParameters(): array; | ||
|
||
} |
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,33 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace ShipMonk\InputMapper\Compiler\Mapper; | ||
|
||
use PHPStan\PhpDocParser\Ast\Type\TypeNode; | ||
use function trim; | ||
|
||
class GenericMapperParameter | ||
{ | ||
|
||
public function __construct( | ||
public readonly string $name, | ||
public readonly GenericTypeVariance $variance = GenericTypeVariance::Invariant, | ||
public readonly ?TypeNode $bound = null, | ||
public readonly ?TypeNode $default = null, | ||
) | ||
{ | ||
} | ||
|
||
public function toPhpDocLine(): string | ||
{ | ||
$tagName = match ($this->variance) { | ||
GenericTypeVariance::Invariant => 'template', | ||
GenericTypeVariance::Covariant => 'template-covariant', | ||
GenericTypeVariance::Contravariant => 'template-contravariant', | ||
}; | ||
|
||
$bound = $this->bound !== null ? " of {$this->bound}" : ''; | ||
$default = $this->default !== null ? " = {$this->default}" : ''; | ||
return trim("@{$tagName} {$this->name}{$bound}{$default}"); | ||
} | ||
|
||
} |
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,12 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace ShipMonk\InputMapper\Compiler\Mapper; | ||
|
||
enum GenericTypeVariance: string | ||
{ | ||
|
||
case Invariant = 'inout'; | ||
case Covariant = 'out'; | ||
case Contravariant = 'in'; | ||
|
||
} |
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
Oops, something went wrong.