Giter Site home page Giter Site logo

Comments (11)

hiqsol avatar hiqsol commented on August 30, 2024 2

Please note it's not static.
To be used: $this->app->t(...)
And Yii::t() is not removed.

from yii-core.

SilverFire avatar SilverFire commented on August 30, 2024 2

The main point is "destatification" inside the framework core. While static methods can serve as good shortcuts for faster code composing, they encourage developers to rely on global application state, that is usually not a good thing. You don't like to use $_GLOBALS variable, right?

There are some posts [1], [2] that explain problem a bit wider.

from yii-core.

gagatust avatar gagatust commented on August 30, 2024 1

@slinstj I think the problem is that Yii::t() is not pure function. Yii:t() behavior depends on settings. We can change the settings at any time and change the behavior.

from yii-core.

gagatust avatar gagatust commented on August 30, 2024

Which is better to use $this->app->t() or Yii::t() and why?

from yii-core.

gagatust avatar gagatust commented on August 30, 2024

Do you plan to remove Yii::t()?

from yii-core.

hiqsol avatar hiqsol commented on August 30, 2024

Not now. And only after having very good alternative(s).

from yii-core.

hiqsol avatar hiqsol commented on August 30, 2024

At the moment we are only trying to clean up the framework core.

from yii-core.

tecnoterabyte avatar tecnoterabyte commented on August 30, 2024

Excelent "destatification" helpers also.

from yii-core.

sdlins avatar sdlins commented on August 30, 2024

Hi guys!

About the "destatification", as I was reading the pointed articles, I tended to discord of them. I think it could be just "over-engineering" to simple situations. When I got to the end of the article, many comments came with strong variated contrary arguments (like this).

I think the "Yeah, it is" could be lost if Yii3 "dificult" some simple things. And helpers are this: simple things. They have no state. They dont change states. They are simple functions.

It would be great to hear really "strong" arguments to remove (or substitute) static helpers, because I read the pointed articles and I could not find them (nor the most of the commenters). Hope to hear you here... thank you.

from yii-core.

hiqsol avatar hiqsol commented on August 30, 2024

@slinstj
First of all Yii::t() is not about to be removed.
But things are being cleaned up.

$this->app->t() will be used in the framework where possible.
And we recommend to use it this way.

It is more "clean" because Yii::t() is not actually simple static stateless function, it just hides from you that some global Application and I18N objects are used behind the scene.
Getting $this->app with constructor DI and then calling $this->app->t() makes everything explicit hopefully without making troubles. But you are free to choose :)

I'm trying to bring modern approaches and more "clean" OOP while keeping "Yes, it is" style and soul.

P.S.
Finishing Yii 3.0 changes description. It will be available soon.

from yii-core.

sdlins avatar sdlins commented on August 30, 2024

Thank you @gagatust and @hiqsol.

I meant in my comment (maybe I had not been clear) was about remove "all" utilities/helpers for the sake of "destatification". This is what I think that would be "over-engineering". But in the answers I see this doesn't seem to be the intention. 👍

from yii-core.

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.