You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/** * Retrieves the storage that is currently set. * * @return StorageInterface|null */publicfunctiongetStorage(): null
{
return$this->storage;
}
/** * Sets the storage to use. * * @param StorageInterface|null $storage * * @return void */publicfunctionsetStorage($storage): void
{
$this->storage = $storage;
}
As you can see, the setter is missing a type hint and the getter has an incorrect type hint. This is likely due to the use of nullability.
The expected behavior is that the return type hint for the getter and the type hint of the setter parameter is ?StorageInterface. In PHP 8.0, StorageInterface|null would also be valid due to union types, but the former would still be supported.
For completeness, my templates:
module.exports=(property)=>` /** * Sets the ${property.getName()} to use. * * @param ${property.getType() ? property.getType() : 'mixed'} \$${property.getName()} * * @return void */ public function ${property.setterName()}(${property.getTypeHint() ? property.getTypeHint()+' ' : ''}\$${property.getName()}): void { $this->${property.getName()} = \$${property.getName()}; }`
module.exports=(property)=>` /** * Retrieves the ${property.getName()} that is currently set. * * @return ${property.getType() ? property.getType() : 'mixed'} */ public function ${property.getterName()}()${property.getType() ? (': '+property.getTypeHint()) : ''} { return $this->${property.getName()}; }`
The text was updated successfully, but these errors were encountered:
This property:
Generates the following getter and setter:
As you can see, the setter is missing a type hint and the getter has an incorrect type hint. This is likely due to the use of nullability.
The expected behavior is that the return type hint for the getter and the type hint of the setter parameter is
?StorageInterface
. In PHP 8.0,StorageInterface|null
would also be valid due to union types, but the former would still be supported.For completeness, my templates:
The text was updated successfully, but these errors were encountered: