Giter Site home page Giter Site logo

container's People

Contributors

artoodetoo avatar drprofesq avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

miovisman

container's Issues

Передавать контейнер прямо в конструктор

Я все успокоится не могу :)
Предлагаю ссылку на контейнер передавать не через метод setContainer(), а прямо в конструктор.
Заменяем

$service = new $class(...$args);
if ($service instanceof ContainerAwareInterface) {
    $service->setContainer($this);
}

на

$args[] = $this; // передача контейнера сразу в конструктор
$service = new $class(...$args);

В результате избавляемся от не нужного метода setContainer() (и маленькой кучки дополнительной писанины) и получаем ссылку сразу в конструкторе созданного класса.

А если контейнер в классе не нужен, то в аргументах __construct() не задаем последний аргумент для него.

Метод resolve()

Нужен ли он в публичном доступе?
Не понятно, что можно получить с его помощью извне класса.

Warning: array_key_exists() expects parameter 2 to be array, integer given in ...

Тестировал метод getParameter(). Вероятно аналогичная ошибка будет в методе setParameter().
Тесты с другими вариантами проверок (is_array() + array_key_exists() и isset() + is_array() + array_key_exists() <- это вариант быстрее, особенно на 5.6.x):

  1. Нормальное поведение, элемент отличный от null - http://sandbox.onlinephpfunctions.com/code/7219247d1584531490acdb5be4ac71015d17ca28
  2. Нормальное поведение, элемент равен null - http://sandbox.onlinephpfunctions.com/code/0acde0551d609bc028096f389e8e4b858f44aa6b
  3. Поведение с ошибкой, элемент не null - http://sandbox.onlinephpfunctions.com/code/d2ae6641b87c95b3e0bca00bb3e04fd4b27c7fe6
  4. Поведение с ошибкой, элемент null - http://sandbox.onlinephpfunctions.com/code/479e0f1f8d82535cefada8107c17726e83e3cad9

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.