Skip to content

Commit

Permalink
main
Browse files Browse the repository at this point in the history
  • Loading branch information
6562680 committed May 25, 2024
1 parent a58cce9 commit 6f7bdd8
Show file tree
Hide file tree
Showing 24 changed files with 1,332 additions and 826 deletions.
6 changes: 1 addition & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,4 @@
/.idea

/vendor
composer.lock

/.data
/.new
/.old
composer.lock
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,8 @@
"optimize-autoloader": true,

"sort-packages": false
},
"require-dev": {
"symfony/var-dumper": "^5.4"
}
}
}
4 changes: 2 additions & 2 deletions helpers/di.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@


/**
* @return Di
* @return DiInterface
*/
function _di(DiInterface $di = null)
{
static $instance;

$before = $instance;

$instance = $di ?? $instance ?? new Di();
$instance = $di ?? $instance ?? (new DiFactory())->newDi();

if ($before !== $instance) {
$instance::setInstance($instance);
Expand Down
8 changes: 8 additions & 0 deletions src/Container/Container.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace Gzhegow\Di\Container;


class Container extends ContainerPsr
{
}
8 changes: 8 additions & 0 deletions src/Container/ContainerInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace Gzhegow\Di\Container;


interface ContainerInterface extends ContainerPsrInterface
{
}
9 changes: 4 additions & 5 deletions src/Container.php → src/Container/ContainerPsr.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<?php

namespace Gzhegow\Di;
namespace Gzhegow\Di\Container;


class Container implements ContainerInterface
{
/** > gzhegow, это адаптер для Psr\Container\ContainerInterface */
use Gzhegow\Di\DiInterface;


class ContainerPsr implements ContainerPsrInterface
{
/**
* @var DiInterface
*/
Expand Down
37 changes: 37 additions & 0 deletions src/Container/ContainerPsr10000.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace Gzhegow\Di\Container;

use Gzhegow\Di\DiInterface;


class ContainerPsr10000 implements ContainerPsr10000Interface
{
/**
* @var DiInterface
*/
protected $di;


public function __construct(DiInterface $di)
{
$this->di = $di;
}


public function getDi() : DiInterface
{
return $this->di;
}


public function has($id) : bool
{
return $this->di->has($id);
}

public function get($id) // : mixed
{
return $this->di->get($id);
}
}
12 changes: 12 additions & 0 deletions src/Container/ContainerPsr10000Interface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace Gzhegow\Di\Container;

use Gzhegow\Di\DiInterface;
use Psr\Container\ContainerInterface as PsrContainerInterface;


interface ContainerPsr10000Interface extends PsrContainerInterface
{
public function getDi() : DiInterface;
}
12 changes: 12 additions & 0 deletions src/Container/ContainerPsrInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace Gzhegow\Di\Container;

use Gzhegow\Di\DiInterface;
use Psr\Container\ContainerInterface as PsrContainerInterface;


interface ContainerPsrInterface extends PsrContainerInterface
{
public function getDi() : DiInterface;
}
11 changes: 0 additions & 11 deletions src/ContainerInterface.php

This file was deleted.

Loading

0 comments on commit 6f7bdd8

Please sign in to comment.