Remove the Property interface, use native types
Spawned from #19, gonna give this a try...
Does the Property
abstaction add value? Should we be using native PHP types instead? I'm thinking in particular about property transformers, which now look like:
public function transform(Property $data) : Property;
And anytime the property is actually being transformed (i.e., in pretty much any property transformer other than Copy
) it has to construct a new Property
instance to return. Which means transformers need to have a PropertyFactory
injected.
What if instead we leveraged PHP's parameter contravariance and return covariance. E.g.
interface PropertyTransformer extends ConfigurableComponent
{
public function transform($data);
}
class Increment extends PropertyTransformerBase
{
public function transform(int $data) : int
{
// Instead of
// return $this->getConfigurationValue('property_factory')->create($data->getValue() + 1);
return $data + 1;
}
}
Implementation is simplified, and native type-checking leveraged.