markshust / magento2-module-simpledata

The SimpleData module simplifies calling Magento data structures.
MIT License
94 stars 7 forks source link

DX issue: class_alias #5

Closed schmengler closed 3 years ago

schmengler commented 3 years ago
// Create an alias for WriterInterface so it's easier to remember
class_alias(WriterInterface::class, SimpleConfig::class);

This class alias may(!) make it easier to remember but causes trouble in DI compilation:

Type Error occurred when creating object: XXX\Setup\Patch\Data\XXX, Argument 2 passed to MarkShust\SimpleData\Setup\Patch\SimpleDataPatch::__construct() must be an instance of MarkShust\SimpleData\Api\Config\SimpleConfig, instance of Magento\Framework\App\Config\Storage\Writer given, called in xxx/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 121

No matter what the root cause here is, the error message is super confusing if you don't know about the class alias (and you shouldn't have to).

Is there any reason not to drop it?

markshust commented 3 years ago

Hi Fabian, yes it makes sense to drop it after these reports. I'll close this as a dupe of https://github.com/markshust/magento2-module-simpledata/issues/4 and work on an update in that issue.