Coder Social home page Coder Social logo

Comments (9)

lonnieezell avatar lonnieezell commented on July 28, 2024

Someone else brought this up before too. :)

That's actually what it's currently using in CI3, and matches the naming scheme of the other methods. The unset method of a class doesn't class with a standalone function name.

from codeigniter4.

jim-parry avatar jim-parry commented on July 28, 2024

Hmmm. The latest NetBeans, with PHP7 support, flags that as an error.
If it isn't used anywhere, do we need it?

from codeigniter4.

lonnieezell avatar lonnieezell commented on July 28, 2024

Um... it's how the users unset data from the session that they've set. So, the framework doesn't use it, but the users do. :)

from codeigniter4.

jim-parry avatar jim-parry commented on July 28, 2024

We could be compliant with the PHP reserved name list if we changed the "unset" method name.
For instance, java.util.Map (comparable container) uses get/put/remove where we use get/set/unset.
What do you think of having get, set & put, and remove? "put" would be alias for set.

from codeigniter4.

jim-parry avatar jim-parry commented on July 28, 2024

Another thing I notice is that we have set, setTempdata and setFlashdata. The latter two can take a key & value, OR an associative array with keys & related values implied. This feels like the PHP equivalent of an overloaded method in Java.

It looks like the same is expected of "set", though that isn't spelled out in the docs ... will fix :)

from codeigniter4.

lonnieezell avatar lonnieezell commented on July 28, 2024

While I don't 100% think it's necessary to change them, it's not a bad idea. I mean, it has worked throughout all of CI 2 and 3 that way so there's no technical reason to - at the moment. But, quoting from the PHP reserved keywords page:

You cannot use any of the following words as constants, class names, function or method names.

So it's probably best to rename them now just in case the interpreter decides to enforce that at some point.

I'm fine with get, set, and remove, but think that aliasing in put is unnecessary and confusing. And set is used throughout the framework and I really don't feel like changing everything. :) We will have to keep an eye out for other places where we have methods with similar roles (cache layer will have this, and probably others) so that we can keep a consistent naming scheme.

from codeigniter4.

lonnieezell avatar lonnieezell commented on July 28, 2024

Another thing I notice is that we have set, setTempdata and setFlashdata. The latter two can take a key & value, OR an associative array with keys & related values implied. This feels like the PHP equivalent of an overloaded method in Java.

You are correct. And it's always been used in the query builder that way too. I don't generally have a problem with it in these cases.

from codeigniter4.

jim-parry avatar jim-parry commented on July 28, 2024

Ok - will prep a PR for unset->remove, and update the API docs for these.

from codeigniter4.

jim-parry avatar jim-parry commented on July 28, 2024

I think this can be closed - methods have been renamed & API docs updated.
The user guide still needs work, but that is a separate issue.

from codeigniter4.

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.