laminas / laminas-hydrator

Serialize objects to arrays, and vice versa
https://docs.laminas.dev/laminas-hydrator/
BSD 3-Clause "New" or "Revised" License
123 stars 32 forks source link

Type of Laminas\\Hydrator\\HydratorPluginManager::$sharedByDefault must be bool #126

Open mairo744 opened 5 days ago

mairo744 commented 5 days ago

Bug Report

Q A
Version(s) 4.15.0

Summary

This issue appeared after updating laminas/laminas-servicemanager to v4

Error message:

Type of Laminas\\Hydrator\\HydratorPluginManager::$sharedByDefault must be bool (as in class Laminas\\ServiceManager\\AbstractPluginManager
)","file":"/var/www/vendor/laminas/laminas-hydrator/src/HydratorPluginManager.php

In the new version of Laminas\ServiceManager\AbstractPluginManager, properties have type declarations:

protected bool $sharedByDefault = true;

Laminas\Hydrator\HydratorPluginManager extends Laminas\ServiceManager\AbstractPluginManager, but its properties are only typed through annotations:

/**
     * Whether or not to share by default (v3)
     *
     * @var bool
     */
    protected $sharedByDefault = false;

Composer allows the installation of laminas/laminas-servicemanager version 4 because it is only a development requirement: https://packagist.org/packages/laminas/laminas-hydrator#4.15.0

Current behavior

The issue does not occur with laminas/laminas-servicemanager version 3.

How to reproduce

Update laminas/laminas-servicemanager to version 4, then observe a crash during the initialization of Laminas\Hydrator\HydratorPluginManager in Laminas\Hydrator\HydratorPluginManagerFactory

$pluginManager = new HydratorPluginManager($container, $options ?? []);

Expected behavior

The HydratorPluginManager should be initialized without type conflicts.

gsteel commented 4 days ago

This library does not yet support laminas/servicemanager@4.0 - the bug is that it is an undeclared dependency and it shouldn't really be installable with service manager v4.

Upgrading to SMv4 here will be a BC break and will need to happen in the next major release

See https://github.com/laminas/laminas-servicemanager/issues/216