Code Monkey home page Code Monkey logo

platform.di's People

Contributors

actions-user avatar bastianschwarz avatar dependabot-preview[bot] avatar dependabot[bot] avatar jrfnl avatar

Watchers

 avatar  avatar

platform.di's Issues

Bring repo back up to standards

It's been a while since I put any amount of effort into this package (mostly because it still works like it's supposed to).

But some outdated stuff should be brought back up to speed:

  • Remove Jenkins build and include travis
  • #18
  • Add Psalm, phplint, update to PHPUnit 9, ... all the good stuff
  • Strict typing
  • Maybe think about moving to composition instead of inheritance, there aren't that many methods to take care of
  • Make classes final

ContainerBuilder interface needs DI\ContainerBuilder methods

When migrating to composition I forgot that addDefinitions (and maybe other public methods) might be in use and are not available in the interface anymore. Those should be added again and declared as deprecated if I don't want to support them in the future anymore.

Self creating dependencies

There is a feature request to automatically add dependencies. Although I'm not a huge fan of it I understand the wish to only add the "top level providers" and have the dependencies added automatically.

  • Create a new "RecursiveDependencies" collection
  • Add the dependencies recurisvley before adding the provider
  • Check if the dependency is already added (use a diff) before the recursion
  • Create a provider factory interface to create the provider classes from the dependency class names to have at least some flexibility in how the dependencies are created
  • Create a "SimpleNew" factory implementation and set it in the "RecursiveDependencies" constructor as default

Update release workflow

After a release was created, the readme should be updated with the new tag in default branch as well as in the new tag itself.

Autoconfiguration for Libraries

There should be a way to auto configure libraries by adding a provider class to the builder.

1st step idea:

There a several provider interfaces, e.g. iGlobPathProvider, iDefinitionsProvider, ...

Extend dependency check to topo graph

The current dependency check just collects the added dependencies in an array. If a provider is added its dependencies are checked against that array. If the dependency is missing an exception is thrown.

This has the advantage that the logic behind it is very easy and that missing dependencies are detected early. But it comes with the disadvantage that dependencies actually have to be added in the correct order which can be cumbersome when there a lot of providers and one might also group similar providers together for better readability.

One solution might be to collect the dependencies and then do a topological sort (possible candidate: https://github.com/marcj/topsort.php) before the container is built.

While comparatively complicated this would also have the nice bonus that the handling of the providers would have to be extracted from the container builder which is something I wanted to do anyway since adding a new provider type requires changes to the existing code and also makes testing more difficult.

Initial idea:

  • Rework to collection system
  • Rework ClassnamesInArray to new collection
  • Add TopoGraph collection
  • The existing ClassNamesInArray can basically stay the same in the way that it still adds and checks the depencies as they are added and the "build" step doesn't do anything

Files from glob path should be added directly, not just on build

The glob files should be discovered directly when they are added. Otherwise, they would always overwrite everything else as they are added last (on build).

Example:

$builder->addGlobPath(...); //would overwrite definitions in next line since the files are discovered and added later
$builder->addDefinitions([]); //would not overwrite definitions in glob

Add MetaProvider interface

It sometimes makes sense to spread definitions across multiple providers. To prevent having to add multiple classes or change the configuration when a new provider was added a MetaProvider interface that can add multiple providers at once would make sense

Dependency handling only collects class if the interface is given

The dependency handling adds the class only if the iDependency interface exsists. If not, the class is never added to the existing dependencies. If another class depends on it the dependency can never be satisfied.

The class names of added providers should be recorder even if no interface is set. Otherwise, classes have to explicitly enabled to be dependencies which kind of defeats the purpose.

Add trait

There should be a trait for the member and getter/setter using the iContainer interface

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.