Git Product home page Git Product logo

Comments (5)

weierophinney avatar weierophinney commented on August 17, 2024

My code editor also doesn't agree on a closure being returned by ServiceManager :)
I get big fat red lines under my DefaultAuthenticationListenerFactory class.

Deep down in the ZF2 ServiceLocatorInterface the return values from a service manager should be either an object or an array:

    /**
     * Retrieve a registered instance
     *
     * @param  string  $name
     * @throws Exception\ServiceNotFoundException
     * @return object|array
     */
    public function get($name);

In the ZF\MvcAuth\Factory\DefaultAuthenticationListenerFactory the following is done:

return new OAuth2Adapter($factory()); (https://github.com/zfcampus/zf-mvc-auth/blob/master/src/Factory/DefaultAuthenticationListenerFactory.php#L105)

That is why I get the following error comment:
Function name must be callable - a string, Closure or class implementing _invoke, currently array |object

I also get an error here

return new OAuth2Adapter($serverFactory(null)); (https://github.com/zfcampus/zf-mvc-auth/blob/master/src/Factory/DefaultAuthenticationListenerFactory.php#L128)

Since the php doc is not correct it looks like we are instantiating OAuth2\Server class here which is not possible.

I think it would be better to return the OAuth2\Server instead of the factory here or at least make sure all documentation is up to date so that it makes sense to my SDK.
I can make a PR if necessary.


Originally posted by @Wilt at zfcampus/zf-oauth2#114 (comment)

from api-tools-oauth2.

weierophinney avatar weierophinney commented on August 17, 2024

@Wilt PR ? :)


Originally posted by @jguittard at zfcampus/zf-oauth2#114 (comment)

from api-tools-oauth2.

weierophinney avatar weierophinney commented on August 17, 2024

@jguittard I was awaiting response from someone working on this repository to get some feedback on how to improve this...

@weierophinney Do you have time to take a quick look and make a suggestion on how to deal with this in a PR?

IMHO it would be good if this essential part of the zf-mvc-auth module becomes a bit more readable/understandable... All these $factory calls inside other factories are a bit ambiguous. As I mentioned before my code editor also doesn't agree with it:

image


Originally posted by @Wilt at zfcampus/zf-oauth2#114 (comment)

from api-tools-oauth2.

weierophinney avatar weierophinney commented on August 17, 2024

@Wilt This was done due to issues with the design of oauth2-server. Essentially, the OAuth2\Server instance does work on initialization that can lead to issues with the HTTP request, database connections, and more. We had to provide a way to lazy-load it to solve the problems.

We can maybe solve the IDE issues with typehints, and some of these may be solved now (I did some work on the AuthControllerFactory earlier today). But I'm not sure we can make any other changes unless we change out the oauth2 server infrastructure or get changes pushed upstream to oauth2-server-php.


Originally posted by @weierophinney at zfcampus/zf-oauth2#114 (comment)

from api-tools-oauth2.

weierophinney avatar weierophinney commented on August 17, 2024

@weierophinney Thanks for the explanation.

Would it be possible to use a lazy services pattern (using delegators) for this instead of this invokable factory? Or is this not sufficient to solve those issues you refer to?


Originally posted by @Wilt at zfcampus/zf-oauth2#114 (comment)

from api-tools-oauth2.

Related Issues (20)

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.