Hey everyone,
I’m debugging a plugin that gives a fatal error when I try to activate it (WordPress by the way). Now I found out that both the theme framework and the plugin use php-di.
The problem I am facing is that is calling a function with the same namespace. But one is more strickt than the other.
Fatal error: Declaration of DI\Definition\Helper\ObjectDefinitionHelper::getDefinition($entryName) must be compatible with DI\Definition\Helper\DefinitionHelper::getDefinition(string $entryName): DI\Definition\Definition in /data/sites/web/xxxxx/subsites/xxxx/wp-content/plugins/cookiebot/addons/lib/ioc/php-di/php-di/src/DI/Definition/Helper/ObjectDefinitionHelper.php on line 21
So in the plugin I found this file:
<?php
/**
* PHP-DI
*
* @link http://php-di.org/
* @copyright Matthieu Napoli (http://mnapoli.fr/)
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
*/
namespace DI\Definition\Helper;
/**
* Helps defining container entries.
*
* @author Matthieu Napoli <matthieu@mnapoli.fr>
*/
interface DefinitionHelper
{
/**
* @param string $entryName Container entry name
* @return \DI\Definition\Definition
*/
public function getDefinition($entryName);
}
And in the vendor folder from the theme / framework I found this:
<?php
declare(strict_types=1);
namespace DI\Definition\Helper;
use DI\Definition\Definition;
/**
* Helps defining container entries.
*
* @author Matthieu Napoli <matthieu@mnapoli.fr>
*/
interface DefinitionHelper
{
/**
* @param string $entryName Container entry name
*/
public function getDefinition(string $entryName) : Definition;
}
So the class ObjectDefinitionHelper implements DefinitionHelper
.
But kinda the wrong one, since they are sharing the same namespace.
Is there a good way to stay in the same project folder
somehow?
Besides that I do not really understand what this means:
public function getDefinition(string $entryName) : Definition;
What do they mean with Definition
. As far as I know, that is the expected result of the method.
But I never heard about Definition
what is this?