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

OO API #1

Open
brzuchal opened this issue Apr 13, 2018 · 2 comments
Open

OO API #1

brzuchal opened this issue Apr 13, 2018 · 2 comments

Comments

@brzuchal
Copy link

IMO the project has a potential.
Are you going to provide OO API so there won't be a plenty of global space functions to be used?

@brzuchal
Copy link
Author

It can be similar to composer ClassLoader

class ClassLoader {
    public function getPrefixes(): array;

    public function addPsr0(string $prefix, string|array $paths, bool $prepend = false): void;
    public function setPsr0(string $prefix, string|array $path, bool $prepend = false): void;
    public function getPsr0Prefixes(): array;

    public function addPsr4(string $prefix, string|array $path, bool $prepend = false): void;
    public function setPsr4(string $prefix, string|array $path, bool $prepend = false): void;
    public function getPsr4Prefixes(): array;

    public function register(bool $prepend = false): void; // registers [$this, 'loadClass']
    public function unregister(): void; // unregisters [$this, 'loadClass']
    public function loadClass(string $class): bool?;

    public function findFile(string $class): string?;
}

@pprkut
Copy link
Owner

pprkut commented Apr 15, 2018

Not anytime soon, no. I intentionally went for functions instead of objects for this extension because I don't see how autoloading warrants the added complexity.
Further, there's not going to be a whole lot of global functions to begin with. Of the 11 example methods you listed, 2 currently exist, 1 of which isn't really meant for users. I could see myself adding functions for getting the registered PSR-4 prefixes and unregistering a PSR-4 prefix and then that's about the functionality this extension needs, IMHO.

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

No branches or pull requests

2 participants