Skip to content

1.1.0

Compare
Choose a tag to compare
@Chrico Chrico released this 21 May 08:36
· 127 commits to master since this release
e7de7c1

Improvements

ReadOnlyContainer now allows support for mixed return values as Services from Modules and from 3rd party PSR Containers.

See also here: #4

<?php

declare(strict_types=1);

use Inpsyde\Modularity\Module\ServiceModule;
use Inpsyde\Modularity\Module\ModuleClassNameIdTrait;
use Psr\Container\ContainerInterface;

class ModuleWhichProvidesServices implements ServiceModule
{
    use ModuleClassNameIdTrait;

    public function services() : array
    {
        return [
            ServiceOne::class => static function(ContainerInterface $container): ServiceOne {
                return new ServiceOne($container->get('string-value'));
            },
            // NEW:
            'string-value' => static function(): string {
                return 'my-string';
            },
            'array-value' => static function(): array {
                return ['foo', 'bar', 'baz'];
            },
            'int-value' => static function(): int {
                return 7411;
            } 
        ];
    }
}

Code quality

  • ThemeProperties // removed inline DocBlock which is not needed.
  • ReadOnlyContainer // remove inline DocBlock for resolved external Services.