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

Support PHP 8.4 lazy objects #104

Open
roxblnfk opened this issue Jan 22, 2025 · 0 comments
Open

Support PHP 8.4 lazy objects #104

roxblnfk opened this issue Jan 22, 2025 · 0 comments
Labels
type:feature New feature

Comments

@roxblnfk
Copy link
Member

I think it will be useful to have an ability to create lazy objects.

It might look like:

  1. New methods:

    class Injector {
        // ...
    
        public function makeGhost(string $class, array $arguments = []): object {}
    
        public function makeProxy(string $class, array $arguments = []): object {}
    }
  2. A new parameter of the make method

    enum Laziness {
        case Regular; // or Disable
        case Proxy;
        case Ghost;
    }
    
    class Injector {
        // ...
    
        public function make(string $class, array $arguments = [], Laziness $laziness = Laziness::Disable): object
    }
  3. A new option:

    $injector
        ->withLaziness(Laziness::Proxy)
        ->make(...)

    But in this case the option won't affect $injector->invoke() (does make sense?)

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

No branches or pull requests

1 participant