Skip to content

Deprecate Yoda conditions on both sources and documentation. #12965

@DocFX

Description

@DocFX

Preamble:

  • Simple community question (not asking for more unless concensus).
  • This question is not about raising all the syntax trolls out there. :)
  • This question is only about Documentation first, as Documentation show more custom sample code than internal Symfony code. But depending on results, question shall be raised on Symfony code repositories as well, for coherence purposes, let's not kick the anthill too fast.

Hi all!

Bumped into this today, while getting feedback on a Symfony Doc PR.

First: sorry if this is not the appropriate place nor form, I usually only correct doc straight away and not create full-text conditions to creating PRs.

This topic was internally solved positively (i.e. removed) a few years ago, since PHP7, pretty much everywhere I touched code, home, work, etc.
Also, being used to contributing / reading code from sources that are not Symfony as much as sources that are Symfony, it seems the latter (which matters right now) is one of the only that uses Yoda conditions.
Most other projects don't, as far as I know. Don't enter a project quoting / namedropping contest, please, this is not the place for it, even though simple mentions would be useful.

So, my question would be, in one straight sentence: could we consider dropping the Yoda conditions, as mentioned in: https://symfony.com/doc/current/contributing/code/standards.html, or do they still make sense in a full triple-equal syntax world?

I won't add all arguments here, at a glance:

Version suggestion: should only affect 5+, thanks to dependency on PHP 7.2.+ and strict + nullable typing, no real link between those two things, but surely can help, considering there should be no "==" left anywhere in the source code, especially when encouraged to use strict typing.

Thanks for the read! :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions