Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't inherit global rules #186

Open
pattisahusiwa opened this issue Jul 11, 2020 · 1 comment
Open

Can't inherit global rules #186

pattisahusiwa opened this issue Jul 11, 2020 · 1 comment

Comments

@pattisahusiwa
Copy link

Code to replicate this issue.

interface GlobalInterface
{

}

class GlobalImplementation implements GlobalInterface
{

}

interface GlobalRuleInterface
{

}

class GlobalRuleImplementation implements GlobalRuleInterface
{

}

class Global4
{
    public $glb;
    public $glbr;
    public function __construct(GlobalInterface $glb, GlobalRuleInterface $glbr)
    {
        $this->glb = $glb;
        $this->glbr = $glbr;
    }
}

$glbRule = [
    'substitutions' => ['GlobalRuleInterface' => 'GlobalRuleImplementation']
];
$glb4Rule = [
    'substitutions' => ['GlobalInterface' => 'GlobalImplementation']
];
$dice = $dice->addRule('*', $glbRule);
$dice = $dice->addRule('Global4', $glb4Rule);

$obj = $dice->create('Global4');
@pattisahusiwa
Copy link
Author

The code above works. However, when adding rule for a class and then provide global rule, instance of the object can't be created.

From the code above, this works

$dice = $dice->addRule('*', $glbRule);
$dice = $dice->addRule('Global4', $glb4Rule);

and this doesn't work

$dice = $dice->addRule('Global4', $glb4Rule);
$dice = $dice->addRule('*', $glbRule);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant