diff --git a/Classes/Core/Model/AbstractBaseType.php b/Classes/Core/Model/AbstractBaseType.php index abaf9ff6..b1ab2663 100644 --- a/Classes/Core/Model/AbstractBaseType.php +++ b/Classes/Core/Model/AbstractBaseType.php @@ -13,6 +13,7 @@ /** * This class provides the logic for both, a single type and a multiple type. + * It is not for use in custom extensions. Use AbstractType instead. * * @internal */ @@ -33,7 +34,7 @@ abstract class AbstractBaseType implements TypeInterface */ protected array $properties = []; - public function setId($id): self + public function setId($id): static { if (! $this->isValidDataTypeForId($id)) { throw new \InvalidArgumentException( @@ -84,7 +85,7 @@ public function hasProperty(string $propertyName): bool return true; } - public function getProperty(string $propertyName) + public function getProperty(string $propertyName): mixed { $this->checkPropertyExists($propertyName); @@ -106,7 +107,7 @@ private function checkPropertyExists(string $propertyName): void } } - public function setProperty(string $propertyName, $propertyValue): self + public function setProperty(string $propertyName, $propertyValue): static { $propertyValue = $this->stringifyNumericValue($propertyValue); $this->checkProperty($propertyName, $propertyValue); @@ -165,7 +166,7 @@ private function isValidDataTypeForPropertyValue(mixed $propertyValue): bool || $propertyValue instanceof EnumerationInterface; } - public function addProperty(string $propertyName, $propertyValue): self + public function addProperty(string $propertyName, $propertyValue): static { $propertyValue = $this->stringifyNumericValue($propertyValue); $this->checkProperty($propertyName, $propertyValue); @@ -194,7 +195,7 @@ public function addProperty(string $propertyName, $propertyValue): self return $this; } - public function setProperties(array $properties): self + public function setProperties(array $properties): static { foreach ($properties as $propertyName => $propertyValue) { $this->setProperty($propertyName, $propertyValue); @@ -203,7 +204,7 @@ public function setProperties(array $properties): self return $this; } - public function clearProperty(string $propertyName): self + public function clearProperty(string $propertyName): static { $this->checkPropertyExists($propertyName); diff --git a/Classes/Core/Model/TypeInterface.php b/Classes/Core/Model/TypeInterface.php index 07276c24..c54cf5c5 100644 --- a/Classes/Core/Model/TypeInterface.php +++ b/Classes/Core/Model/TypeInterface.php @@ -17,7 +17,8 @@ interface TypeInterface extends NodeIdentifierInterface * Set the id. * * @param NodeIdentifierInterface|string|null $id The id - * @return self + * @return static + * @todo Declare return type in method with v4.0.0 */ public function setId($id); @@ -33,6 +34,7 @@ public function hasProperty(string $propertyName): bool; * * @param string $propertyName The property name * @return mixed + * @todo Declare return type in method with v4.0.0 */ public function getProperty(string $propertyName); @@ -41,7 +43,8 @@ public function getProperty(string $propertyName); * * @param string $propertyName The property name * @param mixed $propertyValue The value of the property - * @return self + * @return static + * @todo Declare return type in method with v4.0.0 */ public function setProperty(string $propertyName, mixed $propertyValue); @@ -50,7 +53,8 @@ public function setProperty(string $propertyName, mixed $propertyValue); * * @param string $propertyName The property name * @param mixed $propertyValue The property value - * @return self + * @return static + * @todo Declare return type in method with v4.0.0 */ public function addProperty(string $propertyName, mixed $propertyValue); @@ -62,7 +66,8 @@ public function addProperty(string $propertyName, mixed $propertyValue); * value = property value * * @param array $properties - * @return self + * @return static + * @todo Declare return type in method with v4.0.0 */ public function setProperties(array $properties); @@ -70,7 +75,8 @@ public function setProperties(array $properties); * Clear a property. * * @param string $propertyName The property name - * @return self + * @return static + * @todo Declare return type in method with v4.0.0 */ public function clearProperty(string $propertyName); diff --git a/Documentation/Developer/Api.rst b/Documentation/Developer/Api.rst index 4c91ca0c..3d887bd0 100644 --- a/Documentation/Developer/Api.rst +++ b/Documentation/Developer/Api.rst @@ -285,10 +285,11 @@ class. Available type model methods ---------------------------- -The type models which extend :php:`\Brotkrueml\Schema\Core\Model\AbstractType` -expose the following methods: +The type models which implement :php:`\Brotkrueml\Schema\Core\Model\TypeInterface` +or extend :php:`\Brotkrueml\Schema\Core\Model\AbstractType` expose the following +methods: -.. confval:: setId($id) +.. confval:: setId($id): static :name: abstracttype-setid The method sets the unique ID of the model. With the ID, you can @@ -322,7 +323,7 @@ expose the following methods: A previously set ID or null (if not defined). -.. confval:: setProperty($propertyName, $propertyValue) +.. confval:: setProperty($propertyName, $propertyValue): static :name: abstracttype-setproperty Call this method to set a property or overwrite a previously one. @@ -340,7 +341,7 @@ expose the following methods: Reference to the model itself. -.. confval:: addProperty($propertyName, $propertyValue) +.. confval:: addProperty($propertyName, $propertyValue): static :name: abstracttype-addproperty Call this method if you want to add a value to an existing one. In the @@ -364,7 +365,7 @@ expose the following methods: Reference to the model itself. -.. confval:: setProperties($properties) +.. confval:: setProperties($properties): static :name: abstracttype-setproperties Set multiple properties at once. @@ -379,7 +380,7 @@ expose the following methods: Reference to the model itself. -.. confval:: getProperty($propertyName) +.. confval:: getProperty($propertyName): mixed :name: abstracttype-getproperty Get the value of a property. @@ -394,7 +395,7 @@ expose the following methods: strings, array of models, null). -.. confval:: hasProperty($propertyName) +.. confval:: hasProperty($propertyName): bool :name: abstracttype-hasproperty Check whether the property name exists in a particular model. @@ -407,7 +408,7 @@ expose the following methods: :php:`true`, if the property exists and :php:`false`, otherwise. -.. confval:: clearProperty($propertyName) +.. confval:: clearProperty($propertyName): static :name: abstracttype-clearproperty Resets the value of the property (set it to :php:`null`). @@ -421,7 +422,7 @@ expose the following methods: Reference to the model itself. -.. confval:: getPropertyNames() +.. confval:: getPropertyNames(): array :name: abstracttype-getpropertynames Get the names of all properties of the model. @@ -430,7 +431,7 @@ expose the following methods: Array of all property names of the model. -.. confval:: getType() +.. confval:: getType(): string|string[] :name: abstracttype-gettype Get the type of the model.