From b1b453efb30e391c84b10fd46128df8c11737184 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Barto=C5=A1?= Date: Sun, 1 Jan 2023 00:50:27 +0100 Subject: [PATCH] MappedObject is an interface instead of abstract class --- README.md | 4 +- docs/README.md | 82 ++++++++-------- src/MappedObject.php | 93 +------------------ src/Processing/DefaultProcessor.php | 64 ++++++++++++- ...rClassCallbackCurrentTypeInvalidDataVO.php | 2 +- ...AfterClassCallbackNewTypeInvalidDataVO.php | 2 +- .../AfterClassCallbackValueDoesNotMatchVO.php | 2 +- tests/Doubles/ArrayOfIntVO.php | 2 +- tests/Doubles/ArrayOfStringVO.php | 2 +- tests/Doubles/AttributesVO.php | 2 +- .../BeforeClassCallbackMixedValueVO.php | 2 +- ...BeforeClassCallbackValueDoesNotMatchVO.php | 2 +- tests/Doubles/CallbacksVO.php | 2 +- tests/Doubles/CallbacksVisibilityVO.php | 2 +- tests/Doubles/CircularAVO.php | 2 +- tests/Doubles/CircularBVO.php | 2 +- tests/Doubles/CircularCVO.php | 2 +- tests/Doubles/ConstructorUsingVO.php | 2 +- tests/Doubles/DefaultsVO.php | 2 +- tests/Doubles/DependentVO.php | 2 +- tests/Doubles/EmptyVO.php | 2 +- ...NameIdenticalWithAnotherPropertyNameVO.php | 2 +- tests/Doubles/FieldNamesVO.php | 2 +- tests/Doubles/InitializingVO.php | 2 +- .../Doubles/MultipleIdenticalFieldNamesVO.php | 2 +- tests/Doubles/NoDefaultsVO.php | 2 +- tests/Doubles/PropertiesInitVO.php | 2 +- tests/Doubles/PropertiesVisibilityVO.php | 2 +- tests/Doubles/PropertyCallbacksFailureVO.php | 2 +- tests/Doubles/SelfReferenceVO.php | 2 +- tests/Doubles/SkippedPropertiesVO.php | 2 +- tests/Doubles/StructuresVO.php | 2 +- tests/Doubles/TransformingVO.php | 2 +- tools/phpstan.src.neon | 3 - 34 files changed, 135 insertions(+), 169 deletions(-) diff --git a/README.md b/README.md index a6d517f6..73a33027 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ use Orisai\ObjectMapper\MappedObject; use Orisai\ObjectMapper\Attributes\Expect\MappedObjectValue; use Orisai\ObjectMapper\Attributes\Expect\StringValue; -final class UserInput extends MappedObject +final class UserInput implements MappedObject { /** @StringValue(notEmpty=true) */ @@ -64,7 +64,7 @@ final class UserInput extends MappedObject ```php use Orisai\ObjectMapper\MappedObject; -final class UserAddressInput extends MappedObject +final class UserAddressInput implements MappedObject { // ... } diff --git a/docs/README.md b/docs/README.md index d2d4ae95..eefc676a 100644 --- a/docs/README.md +++ b/docs/README.md @@ -104,7 +104,7 @@ After you have finished [setup](#setup), define a mapped object: use Orisai\ObjectMapper\MappedObject; use Orisai\ObjectMapper\Attributes\Expect\StringValue; -final class UserInput extends MappedObject +final class UserInput implements MappedObject { /** @StringValue(notEmpty=true) */ @@ -171,7 +171,7 @@ Expects bool use Orisai\ObjectMapper\Attributes\Expect\BoolValue; use Orisai\ObjectMapper\MappedObject; -final class BoolInput extends MappedObject +final class BoolInput implements MappedObject { /** @BoolValue() */ @@ -209,7 +209,7 @@ Expects any of cases from given list use Orisai\ObjectMapper\Attributes\Expect\ArrayEnumValue; use Orisai\ObjectMapper\MappedObject; -final class ArrayEnumInput extends MappedObject +final class ArrayEnumInput implements MappedObject { public const Cases = [ @@ -256,7 +256,7 @@ Expects float or int use Orisai\ObjectMapper\Attributes\Expect\FloatValue; use Orisai\ObjectMapper\MappedObject; -final class FloatInput extends MappedObject +final class FloatInput implements MappedObject { /** @FloatValue() */ @@ -310,7 +310,7 @@ use Orisai\ObjectMapper\Attributes\Expect\InstanceOfValue; use Orisai\ObjectMapper\MappedObject; use stdClass; -final class InstanceofInput extends MappedObject +final class InstanceofInput implements MappedObject { /** @InstanceOfValue(stdClass::class) */ @@ -342,7 +342,7 @@ Expects int use Orisai\ObjectMapper\Attributes\Expect\IntValue; use Orisai\ObjectMapper\MappedObject; -final class IntInput extends MappedObject +final class IntInput implements MappedObject { /** @IntValue() */ @@ -393,7 +393,7 @@ Expects any value use Orisai\ObjectMapper\Attributes\Expect\MixedValue; use Orisai\ObjectMapper\MappedObject; -final class MixedInput extends MappedObject +final class MixedInput implements MappedObject { /** @@ -425,7 +425,7 @@ Expects null use Orisai\ObjectMapper\Attributes\Expect\NullValue; use Orisai\ObjectMapper\MappedObject; -final class NullInput extends MappedObject +final class NullInput implements MappedObject { /** @@ -468,7 +468,7 @@ use Orisai\ObjectMapper\Attributes\Expect\NullValue; use Orisai\ObjectMapper\Attributes\Expect\StringValue; use Orisai\ObjectMapper\MappedObject; -final class NullInput extends MappedObject +final class NullInput implements MappedObject { /** @@ -500,7 +500,7 @@ Expects any object use Orisai\ObjectMapper\Attributes\Expect\ObjectValue; use Orisai\ObjectMapper\MappedObject; -final class ObjectInput extends MappedObject +final class ObjectInput implements MappedObject { /** @ObjectValue() */ @@ -529,7 +529,7 @@ Expects any scalar value - int|float|string|bool use Orisai\ObjectMapper\Attributes\Expect\ScalarValue; use Orisai\ObjectMapper\MappedObject; -final class ScalarInput extends MappedObject +final class ScalarInput implements MappedObject { /** @@ -561,7 +561,7 @@ Expects string use Orisai\ObjectMapper\Attributes\Expect\StringValue; use Orisai\ObjectMapper\MappedObject; -final class StringInput extends MappedObject +final class StringInput implements MappedObject { /** @StringValue() */ @@ -621,7 +621,7 @@ use Orisai\ObjectMapper\Attributes\Expect\StringValue; use Orisai\ObjectMapper\Attributes\Expect\Url; use Orisai\ObjectMapper\MappedObject; -final class AllOfInput extends MappedObject +final class AllOfInput implements MappedObject { /** @@ -661,7 +661,7 @@ use Orisai\ObjectMapper\Attributes\Expect\NullValue; use Orisai\ObjectMapper\Attributes\Expect\StringValue; use Orisai\ObjectMapper\MappedObject; -final class AnyOfInput extends MappedObject +final class AnyOfInput implements MappedObject { /** @@ -703,7 +703,7 @@ use Orisai\ObjectMapper\Attributes\Expect\MixedValue; use Orisai\ObjectMapper\Attributes\Expect\StringValue; use Orisai\ObjectMapper\MappedObject; -final class ArrayOfInput extends MappedObject +final class ArrayOfInput implements MappedObject { /** @@ -772,7 +772,7 @@ use Orisai\ObjectMapper\Attributes\Expect\StringValue; use Orisai\ObjectMapper\Attributes\Expect\MixedValue; use Orisai\ObjectMapper\MappedObject; -final class ListOfInput extends MappedObject +final class ListOfInput implements MappedObject { /** @@ -837,7 +837,7 @@ Expects value of a `BackedEnum` case use Orisai\ObjectMapper\Attributes\Expect\BackedEnumValue; use Orisai\ObjectMapper\MappedObject; -final class BackedEnumInput extends MappedObject +final class BackedEnumInput implements MappedObject { #[BackedEnumValue(ExampleEnum::class)] @@ -882,7 +882,7 @@ use Orisai\ObjectMapper\Attributes\Expect\BackedEnumValue; use Orisai\ObjectMapper\Attributes\Expect\StringValue; use Orisai\ObjectMapper\MappedObject; -final class BackedEnumInput extends MappedObject +final class BackedEnumInput implements MappedObject { #[AnyOf([ @@ -914,7 +914,7 @@ use DateTimeImmutable; use Orisai\ObjectMapper\Attributes\Expect\DateTimeValue; use Orisai\ObjectMapper\MappedObject; -final class DateTimeInput extends MappedObject +final class DateTimeInput implements MappedObject { /** @DateTimeValue() */ @@ -967,7 +967,7 @@ use Orisai\ObjectMapper\Attributes\Expect\MappedObjectValue; use Orisai\ObjectMapper\Attributes\Expect\StringValue; use Orisai\ObjectMapper\MappedObject; -final class MappedObjectInput extends MappedObject +final class MappedObjectInput implements MappedObject { /** @MappedObjectValue(InnerInput::class) */ @@ -975,7 +975,7 @@ final class MappedObjectInput extends MappedObject } -class InnerInput extends MappedObject +class InnerInput implements MappedObject { /** @@ -1010,7 +1010,7 @@ Expects valid url address use Orisai\ObjectMapper\Attributes\Expect\Url; use Orisai\ObjectMapper\MappedObject; -final class UrlInput extends MappedObject +final class UrlInput implements MappedObject { /** @Url() */ @@ -1039,7 +1039,7 @@ Each field can be made optional by assigning default value to property: use Orisai\ObjectMapper\Attributes\Expect\StringValue; use Orisai\ObjectMapper\MappedObject; -final class OptionalInput extends MappedObject +final class OptionalInput implements MappedObject { /** @StringValue() */ @@ -1055,7 +1055,7 @@ which are impossible to send: use Orisai\ObjectMapper\Attributes\Expect\StringValue; use Orisai\ObjectMapper\MappedObject; -final class AnotherOptionalInput extends MappedObject +final class AnotherOptionalInput implements MappedObject { /** @StringValue() */ @@ -1076,7 +1076,7 @@ use Orisai\ObjectMapper\Attributes\Expect\NullValue; use Orisai\ObjectMapper\Attributes\Expect\StringValue; use Orisai\ObjectMapper\MappedObject; -final class NullableVariantsInput extends MappedObject +final class NullableVariantsInput implements MappedObject { /** @@ -1148,7 +1148,7 @@ Unknown fields are removed from data and are not available in mapped object. ```php use Orisai\ObjectMapper\MappedObject; -final class WithUnknownValuesInput extends MappedObject +final class WithUnknownValuesInput implements MappedObject { } @@ -1183,7 +1183,7 @@ use Orisai\ObjectMapper\Attributes\Expect\MappedObjectValue; use Orisai\ObjectMapper\Attributes\Expect\StringValue; use Orisai\ObjectMapper\MappedObject; -final class MainInput extends MappedObject +final class MainInput implements MappedObject { /** @@ -1197,7 +1197,7 @@ final class MainInput extends MappedObject } -final class FullInput extends MappedObject +final class FullInput implements MappedObject { /** @IntValue(min=0) */ @@ -1211,7 +1211,7 @@ final class FullInput extends MappedObject } -final class IdOnlyInput extends MappedObject +final class IdOnlyInput implements MappedObject { /** @IntValue(min=0) */ @@ -1237,7 +1237,7 @@ Keys from input data (fields) are mapped to object properties of the same name, use Orisai\ObjectMapper\Attributes\Expect\MixedValue; use Orisai\ObjectMapper\MappedObject; -final class DefaultMappingInput extends MappedObject +final class DefaultMappingInput implements MappedObject { /** @@ -1264,7 +1264,7 @@ use Orisai\ObjectMapper\Attributes\Expect\MixedValue; use Orisai\ObjectMapper\Attributes\Modifiers\FieldName; use Orisai\ObjectMapper\MappedObject; -final class CustomMappingInput extends MappedObject +final class CustomMappingInput implements MappedObject { /** @@ -1299,7 +1299,7 @@ see [default values](#optional-fields-and-default-values)). By default, you have use Orisai\ObjectMapper\Attributes\Expect\BoolValue; use Orisai\ObjectMapper\MappedObject; -final class ModesExampleInput extends MappedObject +final class ModesExampleInput implements MappedObject { /** @BoolValue() */ @@ -1383,7 +1383,7 @@ use Orisai\ObjectMapper\Attributes\Callbacks\After; use Orisai\ObjectMapper\Attributes\Expect\StringValue; use Orisai\ObjectMapper\Context\FieldContext; -final class WithCallbackInput extends MappedObject +final class WithCallbackInput implements MappedObject { /** @@ -1440,7 +1440,7 @@ use Orisai\ObjectMapper\Context\MappedObjectContext; * @Before("beforeObject") * @After("afterObject") */ -final class WithMappedObjectCallbacksInput extends MappedObject +final class WithMappedObjectCallbacksInput implements MappedObject { /** @@ -1489,7 +1489,7 @@ use Orisai\ObjectMapper\Attributes\Callbacks\After; use Orisai\ObjectMapper\Attributes\Expect\StringValue; use Orisai\ObjectMapper\Context\FieldContext; -final class WithFieldCallbacksInput extends MappedObject +final class WithFieldCallbacksInput implements MappedObject { /** @@ -1524,7 +1524,7 @@ use Orisai\ObjectMapper\Attributes\Callbacks\After; use Orisai\ObjectMapper\Attributes\Expect\StringValue; use Orisai\ObjectMapper\Context\FieldContext; -final class WithNotInvokedCallbackInput extends MappedObject +final class WithNotInvokedCallbackInput implements MappedObject { /** @@ -1557,7 +1557,7 @@ use Orisai\ObjectMapper\MappedObject; use Orisai\ObjectMapper\Attributes\Callbacks\After; use Orisai\ObjectMapper\Attributes\Expect\MixedValue; -final class WithReturningCallbackInput extends MappedObject +final class WithReturningCallbackInput implements MappedObject { /** @@ -1588,7 +1588,7 @@ use Orisai\ObjectMapper\Attributes\Expect\StringValue; use Orisai\ObjectMapper\Exception\ValueDoesNotMatch; use Orisai\ObjectMapper\Types\Value; -final class WithNotReturningCallbackInput extends MappedObject +final class WithNotReturningCallbackInput implements MappedObject { /** @@ -1618,7 +1618,7 @@ use Orisai\ObjectMapper\Attributes\Expect\MixedValue; use Orisai\ObjectMapper\Exception\ValueDoesNotMatch; use Orisai\ObjectMapper\Types\Value; -final class WithComplexCallbackInput extends MappedObject +final class WithComplexCallbackInput implements MappedObject { private ExampleService $service; @@ -1681,7 +1681,7 @@ Since PHP 8.0 annotations can be written as attributes. use Orisai\ObjectMapper\Attributes\Expect\MixedValue; use Orisai\ObjectMapper\MappedObject; -final class WithAnnotationsAndAttributesInput extends MappedObject +final class WithAnnotationsAndAttributesInput implements MappedObject { /** @MixedValue() */ @@ -1726,7 +1726,7 @@ use Orisai\ObjectMapper\MappedObject; /** * @CreateWithoutConstructor() */ -final class ConstructorUsingVO extends MappedObject +final class ConstructorUsingVO implements MappedObject { /** @StringValue() */ diff --git a/src/MappedObject.php b/src/MappedObject.php index b6ac62f2..bb13132d 100644 --- a/src/MappedObject.php +++ b/src/MappedObject.php @@ -2,99 +2,10 @@ namespace Orisai\ObjectMapper; -use Nette\Utils\ObjectHelpers; -use ReflectionException; -use ReflectionProperty; - /** - * Base class required for mapped objects + * Interface required for mapped objects */ -abstract class MappedObject +interface MappedObject { - /** - * Checks if the public non-static property exists. - */ - private static function hasProperty(string $class, string $name): bool - { - static $cache; - $prop = &$cache[$class][$name]; - - if ($prop !== null) { - return $prop; - } - - $prop = false; - try { - $ref = new ReflectionProperty($class, $name); - } catch (ReflectionException $e) { - return $prop; - } - - if ( - !$ref->isStatic() - && ( - !$ref->isPrivate() - || $ref->getDeclaringClass()->isFinal() - ) - ) { - $prop = true; - } - - return $prop; - } - - /** - * @return never - */ - final public function __get(string $name): void - { - ObjectHelpers::strictGet(static::class, $name); - } - - /** - * @param mixed $value - */ - final public function __set(string $name, $value): void - { - $class = static::class; - - if (self::hasProperty($class, $name)) { - (fn () => $this->$name = $value) - ->bindTo($this, $this)(); - } else { - ObjectHelpers::strictSet($class, $name); - } - } - - final public function __isset(string $name): bool - { - return false; - } - - public function __unset(string $name): void - { - (function () use ($name): void { - unset($this->$name); - })->bindTo($this, $this)(); - } - - /** - * @param array $arguments - * @return never - */ - final public function __call(string $name, array $arguments): void - { - ObjectHelpers::strictCall(static::class, $name); - } - - /** - * @param array $arguments - * @return never - */ - final public static function __callStatic(string $name, array $arguments): void - { - ObjectHelpers::strictStaticCall(static::class, $name); - } - } diff --git a/src/Processing/DefaultProcessor.php b/src/Processing/DefaultProcessor.php index 81f0143c..31c23617 100644 --- a/src/Processing/DefaultProcessor.php +++ b/src/Processing/DefaultProcessor.php @@ -31,6 +31,8 @@ use Orisai\ObjectMapper\Types\MappedObjectType; use Orisai\ObjectMapper\Types\MessageType; use Orisai\ObjectMapper\Types\Value; +use ReflectionException; +use ReflectionProperty; use stdClass; use function array_diff; use function array_key_exists; @@ -652,13 +654,13 @@ private function fillObject( // Reset mapped properties state $propertiesMeta = $callContext->getMeta()->getProperties(); foreach ($propertiesMeta as $propertyName => $propertyMeta) { - unset($object->$propertyName); + $this->objectUnset($object, $propertyName); } // Set processed data foreach ($data as $fieldName => $value) { $propertyName = $this->fieldNameToPropertyName($fieldName, $meta); - $object->$propertyName = $value; + $this->objectSet($object, $propertyName, $value); } // Set skipped properties @@ -692,6 +694,62 @@ public function getRawValues(MappedObject $object) return $this->rawValuesMap->getRawValues($object); } + /** + * @param mixed $value + */ + private function objectSet(MappedObject $object, string $name, $value): void + { + if ($this->objectHasProperty($object, $name)) { + // phpcs:disable SlevomatCodingStandard.Functions.StaticClosure + (fn () => $object->$name = $value) + ->bindTo($object, $object)(); + // phpcs:enable + } + } + + private function objectUnset(MappedObject $object, string $name): void + { + // phpcs:disable SlevomatCodingStandard.Functions.StaticClosure + (function () use ($object, $name): void { + unset($object->$name); + })->bindTo($object, $object)(); + // phpcs:enable + } + + /** + * Checks if the public non-static property exists. + */ + private function objectHasProperty(MappedObject $object, string $name): bool + { + $class = get_class($object); + + static $cache; + $prop = &$cache[$class][$name]; + + if ($prop !== null) { + return $prop; + } + + $prop = false; + try { + $ref = new ReflectionProperty($class, $name); + } catch (ReflectionException $e) { + return $prop; + } + + if ( + !$ref->isStatic() + && ( + !$ref->isPrivate() + || $ref->getDeclaringClass()->isFinal() + ) + ) { + $prop = true; + } + + return $prop; + } + // ////////////// // // Late processing // // ////////////// // @@ -765,7 +823,7 @@ public function processSkippedProperties( } } - $object->$propertyName = $processed; + $this->objectSet($object, $propertyName, $processed); $skippedPropertiesContext->removeSkippedProperty($propertyName); } diff --git a/tests/Doubles/AfterClassCallbackCurrentTypeInvalidDataVO.php b/tests/Doubles/AfterClassCallbackCurrentTypeInvalidDataVO.php index a16858bc..397d2a88 100644 --- a/tests/Doubles/AfterClassCallbackCurrentTypeInvalidDataVO.php +++ b/tests/Doubles/AfterClassCallbackCurrentTypeInvalidDataVO.php @@ -12,7 +12,7 @@ /** * @After(method="after") */ -final class AfterClassCallbackCurrentTypeInvalidDataVO extends MappedObject +final class AfterClassCallbackCurrentTypeInvalidDataVO implements MappedObject { /** @StringValue() */ diff --git a/tests/Doubles/AfterClassCallbackNewTypeInvalidDataVO.php b/tests/Doubles/AfterClassCallbackNewTypeInvalidDataVO.php index fe81a9c3..0edd5964 100644 --- a/tests/Doubles/AfterClassCallbackNewTypeInvalidDataVO.php +++ b/tests/Doubles/AfterClassCallbackNewTypeInvalidDataVO.php @@ -14,7 +14,7 @@ /** * @After(method="after") */ -final class AfterClassCallbackNewTypeInvalidDataVO extends MappedObject +final class AfterClassCallbackNewTypeInvalidDataVO implements MappedObject { /** @StringValue() */ diff --git a/tests/Doubles/AfterClassCallbackValueDoesNotMatchVO.php b/tests/Doubles/AfterClassCallbackValueDoesNotMatchVO.php index a29a5a0a..909c325a 100644 --- a/tests/Doubles/AfterClassCallbackValueDoesNotMatchVO.php +++ b/tests/Doubles/AfterClassCallbackValueDoesNotMatchVO.php @@ -11,7 +11,7 @@ /** * @After(method="after") */ -final class AfterClassCallbackValueDoesNotMatchVO extends MappedObject +final class AfterClassCallbackValueDoesNotMatchVO implements MappedObject { /** @StringValue() */ diff --git a/tests/Doubles/ArrayOfIntVO.php b/tests/Doubles/ArrayOfIntVO.php index c510ff38..0114b22d 100644 --- a/tests/Doubles/ArrayOfIntVO.php +++ b/tests/Doubles/ArrayOfIntVO.php @@ -6,7 +6,7 @@ use Orisai\ObjectMapper\Attributes\Expect\IntValue; use Orisai\ObjectMapper\MappedObject; -final class ArrayOfIntVO extends MappedObject +final class ArrayOfIntVO implements MappedObject { /** diff --git a/tests/Doubles/ArrayOfStringVO.php b/tests/Doubles/ArrayOfStringVO.php index cd4c4afc..8bcfe2ed 100644 --- a/tests/Doubles/ArrayOfStringVO.php +++ b/tests/Doubles/ArrayOfStringVO.php @@ -6,7 +6,7 @@ use Orisai\ObjectMapper\Attributes\Expect\StringValue; use Orisai\ObjectMapper\MappedObject; -final class ArrayOfStringVO extends MappedObject +final class ArrayOfStringVO implements MappedObject { /** diff --git a/tests/Doubles/AttributesVO.php b/tests/Doubles/AttributesVO.php index 49beaaab..2078b135 100644 --- a/tests/Doubles/AttributesVO.php +++ b/tests/Doubles/AttributesVO.php @@ -5,7 +5,7 @@ use Orisai\ObjectMapper\Attributes\Expect\StringValue; use Orisai\ObjectMapper\MappedObject; -final class AttributesVO extends MappedObject +final class AttributesVO implements MappedObject { #[StringValue] diff --git a/tests/Doubles/BeforeClassCallbackMixedValueVO.php b/tests/Doubles/BeforeClassCallbackMixedValueVO.php index 32a3ec3f..24330fdc 100644 --- a/tests/Doubles/BeforeClassCallbackMixedValueVO.php +++ b/tests/Doubles/BeforeClassCallbackMixedValueVO.php @@ -8,7 +8,7 @@ /** * @Before(method="before") */ -final class BeforeClassCallbackMixedValueVO extends MappedObject +final class BeforeClassCallbackMixedValueVO implements MappedObject { /** diff --git a/tests/Doubles/BeforeClassCallbackValueDoesNotMatchVO.php b/tests/Doubles/BeforeClassCallbackValueDoesNotMatchVO.php index 6327100e..9d7202ff 100644 --- a/tests/Doubles/BeforeClassCallbackValueDoesNotMatchVO.php +++ b/tests/Doubles/BeforeClassCallbackValueDoesNotMatchVO.php @@ -10,7 +10,7 @@ /** * @Before(method="before") */ -final class BeforeClassCallbackValueDoesNotMatchVO extends MappedObject +final class BeforeClassCallbackValueDoesNotMatchVO implements MappedObject { /** diff --git a/tests/Doubles/CallbacksVO.php b/tests/Doubles/CallbacksVO.php index 022468e2..09333b57 100644 --- a/tests/Doubles/CallbacksVO.php +++ b/tests/Doubles/CallbacksVO.php @@ -20,7 +20,7 @@ * @Before(method="beforeClass", runtime=CallbackRuntime::Always) * @After(method="afterClass", runtime=CallbackRuntime::Always) */ -final class CallbacksVO extends MappedObject +final class CallbacksVO implements MappedObject { private string $constructorGivenValue; diff --git a/tests/Doubles/CallbacksVisibilityVO.php b/tests/Doubles/CallbacksVisibilityVO.php index 4de19f98..cfba966c 100644 --- a/tests/Doubles/CallbacksVisibilityVO.php +++ b/tests/Doubles/CallbacksVisibilityVO.php @@ -6,7 +6,7 @@ use Orisai\ObjectMapper\Attributes\Expect\StringValue; use Orisai\ObjectMapper\MappedObject; -final class CallbacksVisibilityVO extends MappedObject +final class CallbacksVisibilityVO implements MappedObject { /** diff --git a/tests/Doubles/CircularAVO.php b/tests/Doubles/CircularAVO.php index a1a0ecd4..5175802f 100644 --- a/tests/Doubles/CircularAVO.php +++ b/tests/Doubles/CircularAVO.php @@ -8,7 +8,7 @@ use Orisai\ObjectMapper\Attributes\Expect\StringValue; use Orisai\ObjectMapper\MappedObject; -final class CircularAVO extends MappedObject +final class CircularAVO implements MappedObject { /** @MappedObjectValue(CircularBVO::class) */ diff --git a/tests/Doubles/CircularBVO.php b/tests/Doubles/CircularBVO.php index 28e0a760..c967c679 100644 --- a/tests/Doubles/CircularBVO.php +++ b/tests/Doubles/CircularBVO.php @@ -7,7 +7,7 @@ use Orisai\ObjectMapper\Attributes\Expect\NullValue; use Orisai\ObjectMapper\MappedObject; -final class CircularBVO extends MappedObject +final class CircularBVO implements MappedObject { /** diff --git a/tests/Doubles/CircularCVO.php b/tests/Doubles/CircularCVO.php index 1d5d1881..102b23a5 100644 --- a/tests/Doubles/CircularCVO.php +++ b/tests/Doubles/CircularCVO.php @@ -6,7 +6,7 @@ use Orisai\ObjectMapper\Attributes\Expect\MappedObjectValue; use Orisai\ObjectMapper\MappedObject; -final class CircularCVO extends MappedObject +final class CircularCVO implements MappedObject { /** @ListOf(@MappedObjectValue(CircularAVO::class)) */ diff --git a/tests/Doubles/ConstructorUsingVO.php b/tests/Doubles/ConstructorUsingVO.php index 21d218de..efd59d80 100644 --- a/tests/Doubles/ConstructorUsingVO.php +++ b/tests/Doubles/ConstructorUsingVO.php @@ -9,7 +9,7 @@ /** * @CreateWithoutConstructor() */ -final class ConstructorUsingVO extends MappedObject +final class ConstructorUsingVO implements MappedObject { /** @StringValue() */ diff --git a/tests/Doubles/DefaultsVO.php b/tests/Doubles/DefaultsVO.php index 73c9f54e..63c49196 100644 --- a/tests/Doubles/DefaultsVO.php +++ b/tests/Doubles/DefaultsVO.php @@ -9,7 +9,7 @@ use Orisai\ObjectMapper\Attributes\Expect\StringValue; use Orisai\ObjectMapper\MappedObject; -final class DefaultsVO extends MappedObject +final class DefaultsVO implements MappedObject { /** @StringValue() */ diff --git a/tests/Doubles/DependentVO.php b/tests/Doubles/DependentVO.php index 48e2a4e3..fbb3fa40 100644 --- a/tests/Doubles/DependentVO.php +++ b/tests/Doubles/DependentVO.php @@ -5,7 +5,7 @@ use Orisai\ObjectMapper\MappedObject; use stdClass; -final class DependentVO extends MappedObject +final class DependentVO implements MappedObject { public ?stdClass $class = null; diff --git a/tests/Doubles/EmptyVO.php b/tests/Doubles/EmptyVO.php index f8e43d18..6b73bffe 100644 --- a/tests/Doubles/EmptyVO.php +++ b/tests/Doubles/EmptyVO.php @@ -4,7 +4,7 @@ use Orisai\ObjectMapper\MappedObject; -final class EmptyVO extends MappedObject +final class EmptyVO implements MappedObject { } diff --git a/tests/Doubles/FieldNameIdenticalWithAnotherPropertyNameVO.php b/tests/Doubles/FieldNameIdenticalWithAnotherPropertyNameVO.php index f7ea9960..b6587ab7 100644 --- a/tests/Doubles/FieldNameIdenticalWithAnotherPropertyNameVO.php +++ b/tests/Doubles/FieldNameIdenticalWithAnotherPropertyNameVO.php @@ -6,7 +6,7 @@ use Orisai\ObjectMapper\Attributes\Modifiers\FieldName; use Orisai\ObjectMapper\MappedObject; -final class FieldNameIdenticalWithAnotherPropertyNameVO extends MappedObject +final class FieldNameIdenticalWithAnotherPropertyNameVO implements MappedObject { /** @StringValue() */ diff --git a/tests/Doubles/FieldNamesVO.php b/tests/Doubles/FieldNamesVO.php index 1d630dee..dffe0925 100644 --- a/tests/Doubles/FieldNamesVO.php +++ b/tests/Doubles/FieldNamesVO.php @@ -6,7 +6,7 @@ use Orisai\ObjectMapper\Attributes\Modifiers\FieldName; use Orisai\ObjectMapper\MappedObject; -final class FieldNamesVO extends MappedObject +final class FieldNamesVO implements MappedObject { /** @StringValue() */ diff --git a/tests/Doubles/InitializingVO.php b/tests/Doubles/InitializingVO.php index 66ec9452..620a96f6 100644 --- a/tests/Doubles/InitializingVO.php +++ b/tests/Doubles/InitializingVO.php @@ -9,7 +9,7 @@ use Orisai\ObjectMapper\MappedObject; use stdClass; -final class InitializingVO extends MappedObject +final class InitializingVO implements MappedObject { /** @DateTimeValue() */ diff --git a/tests/Doubles/MultipleIdenticalFieldNamesVO.php b/tests/Doubles/MultipleIdenticalFieldNamesVO.php index 4ff10034..ac048890 100644 --- a/tests/Doubles/MultipleIdenticalFieldNamesVO.php +++ b/tests/Doubles/MultipleIdenticalFieldNamesVO.php @@ -6,7 +6,7 @@ use Orisai\ObjectMapper\Attributes\Modifiers\FieldName; use Orisai\ObjectMapper\MappedObject; -final class MultipleIdenticalFieldNamesVO extends MappedObject +final class MultipleIdenticalFieldNamesVO implements MappedObject { /** diff --git a/tests/Doubles/NoDefaultsVO.php b/tests/Doubles/NoDefaultsVO.php index e67c05a8..7e71fee7 100644 --- a/tests/Doubles/NoDefaultsVO.php +++ b/tests/Doubles/NoDefaultsVO.php @@ -11,7 +11,7 @@ use Orisai\ObjectMapper\Attributes\Expect\StringValue; use Orisai\ObjectMapper\MappedObject; -final class NoDefaultsVO extends MappedObject +final class NoDefaultsVO implements MappedObject { /** @StringValue() */ diff --git a/tests/Doubles/PropertiesInitVO.php b/tests/Doubles/PropertiesInitVO.php index bae20dc9..cbb6456d 100644 --- a/tests/Doubles/PropertiesInitVO.php +++ b/tests/Doubles/PropertiesInitVO.php @@ -8,7 +8,7 @@ use Orisai\ObjectMapper\Attributes\Expect\StringValue; use Orisai\ObjectMapper\MappedObject; -final class PropertiesInitVO extends MappedObject +final class PropertiesInitVO implements MappedObject { /** diff --git a/tests/Doubles/PropertiesVisibilityVO.php b/tests/Doubles/PropertiesVisibilityVO.php index 959efae2..e98c75b8 100644 --- a/tests/Doubles/PropertiesVisibilityVO.php +++ b/tests/Doubles/PropertiesVisibilityVO.php @@ -5,7 +5,7 @@ use Orisai\ObjectMapper\Attributes\Expect\StringValue; use Orisai\ObjectMapper\MappedObject; -final class PropertiesVisibilityVO extends MappedObject +final class PropertiesVisibilityVO implements MappedObject { /** @StringValue() */ diff --git a/tests/Doubles/PropertyCallbacksFailureVO.php b/tests/Doubles/PropertyCallbacksFailureVO.php index ea8718f2..4525a19b 100644 --- a/tests/Doubles/PropertyCallbacksFailureVO.php +++ b/tests/Doubles/PropertyCallbacksFailureVO.php @@ -15,7 +15,7 @@ * @Before(method="beforeClass") * @After(method="afterClass") */ -final class PropertyCallbacksFailureVO extends MappedObject +final class PropertyCallbacksFailureVO implements MappedObject { /** diff --git a/tests/Doubles/SelfReferenceVO.php b/tests/Doubles/SelfReferenceVO.php index 8ff40892..d723b0bb 100644 --- a/tests/Doubles/SelfReferenceVO.php +++ b/tests/Doubles/SelfReferenceVO.php @@ -8,7 +8,7 @@ use Orisai\ObjectMapper\Attributes\Expect\StringValue; use Orisai\ObjectMapper\MappedObject; -final class SelfReferenceVO extends MappedObject +final class SelfReferenceVO implements MappedObject { /** diff --git a/tests/Doubles/SkippedPropertiesVO.php b/tests/Doubles/SkippedPropertiesVO.php index cdb3ab6d..6e24106c 100644 --- a/tests/Doubles/SkippedPropertiesVO.php +++ b/tests/Doubles/SkippedPropertiesVO.php @@ -6,7 +6,7 @@ use Orisai\ObjectMapper\Attributes\Modifiers\Skipped; use Orisai\ObjectMapper\MappedObject; -final class SkippedPropertiesVO extends MappedObject +final class SkippedPropertiesVO implements MappedObject { /** @StringValue() */ diff --git a/tests/Doubles/StructuresVO.php b/tests/Doubles/StructuresVO.php index b77a23f9..7f46e01f 100644 --- a/tests/Doubles/StructuresVO.php +++ b/tests/Doubles/StructuresVO.php @@ -8,7 +8,7 @@ use Orisai\ObjectMapper\Attributes\Expect\MixedValue; use Orisai\ObjectMapper\MappedObject; -final class StructuresVO extends MappedObject +final class StructuresVO implements MappedObject { /** @MappedObjectValue(DefaultsVO::class) */ diff --git a/tests/Doubles/TransformingVO.php b/tests/Doubles/TransformingVO.php index 1a2b7d6e..a5b20e4d 100644 --- a/tests/Doubles/TransformingVO.php +++ b/tests/Doubles/TransformingVO.php @@ -11,7 +11,7 @@ use Orisai\ObjectMapper\MappedObject; use stdClass; -final class TransformingVO extends MappedObject +final class TransformingVO implements MappedObject { /** @BoolValue(castBoolLike=true) */ diff --git a/tools/phpstan.src.neon b/tools/phpstan.src.neon index ae3717b9..ae965da5 100644 --- a/tools/phpstan.src.neon +++ b/tools/phpstan.src.neon @@ -9,9 +9,6 @@ parameters: # Values mapping to object - message: '#^Variable property access on Orisai\\ObjectMapper\\MappedObject\.$#' path: ../src/Processing/DefaultProcessor.php - count: 3 - - message: '#^Variable property access on \$this\(Orisai\\ObjectMapper\\MappedObject\).$#' - path: ../src/MappedObject.php count: 2 # Callback call - message: '#^Variable static method call on class-string\\.$#'