-
-
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.
MetaResolver: Check that Callback returns correct Args class type
- Loading branch information
Showing
10 changed files
with
148 additions
and
31 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
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,44 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Tests\Orisai\ObjectMapper\Doubles\Callbacks; | ||
|
||
use Orisai\Exceptions\Logic\NotImplemented; | ||
use Orisai\ObjectMapper\Args\Args; | ||
use Orisai\ObjectMapper\Args\EmptyArgs; | ||
use Orisai\ObjectMapper\Callbacks\Callback; | ||
use Orisai\ObjectMapper\Context\ArgsContext; | ||
use Orisai\ObjectMapper\Context\BaseFieldContext; | ||
use Orisai\ObjectMapper\Processing\ObjectHolder; | ||
use Orisai\ObjectMapper\Rules\NullArgs; | ||
use ReflectionClass; | ||
use Reflector; | ||
|
||
/** | ||
* @implements Callback<NullArgs> | ||
*/ | ||
final class WrongArgsTypeCallback implements Callback | ||
{ | ||
|
||
public static function resolveArgs(array $args, ArgsContext $context, Reflector $reflector): Args | ||
{ | ||
return new NullArgs(false); | ||
} | ||
|
||
public static function getArgsType(): string | ||
{ | ||
/** @phpstan-ignore-next-line */ | ||
return EmptyArgs::class; | ||
} | ||
|
||
public static function invoke( | ||
$data, | ||
Args $args, | ||
ObjectHolder $holder, | ||
BaseFieldContext $context, | ||
ReflectionClass $declaringClass | ||
): void | ||
{ | ||
throw NotImplemented::create(); | ||
} | ||
|
||
} |
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,28 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Tests\Orisai\ObjectMapper\Doubles\Callbacks; | ||
|
||
use Attribute; | ||
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor; | ||
use Orisai\ObjectMapper\Callbacks\CallbackDefinition; | ||
|
||
/** | ||
* @Annotation | ||
* @NamedArgumentConstructor() | ||
* @Target({"PROPERTY"}) | ||
*/ | ||
#[Attribute(Attribute::TARGET_PROPERTY)] | ||
final class WrongArgsTypeCallbackValue implements CallbackDefinition | ||
{ | ||
|
||
public function getType(): string | ||
{ | ||
return WrongArgsTypeCallback::class; | ||
} | ||
|
||
public function getArgs(): array | ||
{ | ||
return []; | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
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 Tests\Orisai\ObjectMapper\Doubles\Invalid; | ||
|
||
use Orisai\ObjectMapper\MappedObject; | ||
use Orisai\ObjectMapper\Rules\StringValue; | ||
use Tests\Orisai\ObjectMapper\Doubles\Callbacks\WrongArgsTypeCallbackValue; | ||
|
||
final class WrongCallbackArgsTypeVO implements MappedObject | ||
{ | ||
|
||
/** | ||
* @WrongArgsTypeCallbackValue() | ||
* @StringValue() | ||
*/ | ||
public string $field; | ||
|
||
} |
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,14 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Tests\Orisai\ObjectMapper\Doubles\Invalid; | ||
|
||
use Orisai\ObjectMapper\MappedObject; | ||
use Tests\Orisai\ObjectMapper\Doubles\Rules\WrongArgsTypeRuleValue; | ||
|
||
final class WrongRuleArgsTypeVO implements MappedObject | ||
{ | ||
|
||
/** @WrongArgsTypeRuleValue() */ | ||
public string $field; | ||
|
||
} |
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