Giter Site home page Giter Site logo

Comments (9)

leocavalcante avatar leocavalcante commented on May 21, 2024

Well, actually this isn't a bug. The constructor of TestController will always be called, indeed, you're doing it at [(new TestController), "page"], it is not something on the Siler internals... We can't prevent or predict user code inside a lib/framework.

from siler.

Sinevia avatar Sinevia commented on May 21, 2024

I agree it cannot be prevented, this is why I propose a workaround that will work with non-static methods without side effects

from siler.

leocavalcante avatar leocavalcante commented on May 21, 2024

Handling class construction isn't a Siler concern, at least for now, you should look for something like Pimple. Yet you could just wrap it in a Closure:

Route\get('user', function () {
  $c = new TestController();
  return $c->page();
});

from siler.

Sinevia avatar Sinevia commented on May 21, 2024

@leocavalcante this is actually a problem as the documentation says the router can use any callable. In this case it is a problem as it causes code execution that the user will be unaware of. I agree its not a problem with Siler per se, but this is the way this particular callable works. If Siler decides not to address this, this is fine, but the documentation needs to be updated to caveat this case.

I believe other routers have recognized this as a problem and have come up with a solution:

image

Example at:
https://github.com/magnus-eriksson/router

from siler.

Sinevia avatar Sinevia commented on May 21, 2024

@leocavalcante this is actually a problem as the documentation says the router can use any callable. In this case it is a problem as it causes code execution that the user will be unaware of. I agree its not a problem with Siler per se, but this is the way this particular callable works. If Siler decides not to address this, this is fine, but the documentation needs to be updated to caveat this case.

I believe other routers have recognized this as a problem and have come up with a solution:

image

Example at:
https://github.com/magnus-eriksson/router

from siler.

Sinevia avatar Sinevia commented on May 21, 2024

@leocavalcante this is actually a problem as the documentation says the router can use any callable. In this case it is a problem as it causes code execution that the user will be unaware of. I agree its not a problem with Siler per se, but this is the way this particular callable works. If Siler decides not to address this, this is fine, but the documentation needs to be updated to caveat this case.

I believe other routers have recognized this as a problem and have come up with a solution:

image

Example at:
https://github.com/magnus-eriksson/router

from siler.

Sinevia avatar Sinevia commented on May 21, 2024

@leocavalcante this is actually a problem as the documentation says the router can use any callable. In this case it is a problem as it causes code execution that the user will be unaware of. I agree its not a problem with Siler per se, but this is the way this particular callable works. If Siler decides not to address this, this is fine, but the documentation needs to be updated to caveat this case.

I believe other routers have recognized this as a problem and have come up with a solution:

image

Example at:
https://github.com/magnus-eriksson/router

from siler.

Sinevia avatar Sinevia commented on May 21, 2024

Sorry for reposting so many times. Github was showing 500 page and unable to post message.

from siler.

leocavalcante avatar leocavalcante commented on May 21, 2024

NP, I got some buggy behavior from Github too.

from siler.

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.