u/Accomplished-Fan3195

▲ 0 r/PHP

Fala pessoal 👋

Esses dias me peguei estranhando uma coisa no PHP e queria saber se sou só eu ou mais gente já passou por isso 😅

Vi um código assim:

if (! $authUser->isSuperAdmin()) {

E na hora me deu um bug mental… pra mim o “normal” sempre foi escrever sem espaço:

if (!$authUser->isSuperAdmin()) {

Aí fui pesquisar e vi que com espaço (! $var) segue o padrão PSR-12 e é totalmente válido não muda absolutamente nada no funcionamento.

Mas mesmo assim, visualmente ainda acho meio estranho kkk

Queria saber de vocês:

  • vocês usam com espaço ou sem?
  • já estranharam isso também?
  • seguem PSR-12 à risca ou vão mais pelo costume?

Curioso pra ver como a galera costuma escrever isso no dia a dia 🤔

-------------------------------------------------------------------------------------------------------------

Hey everyone 👋

The other day I caught myself finding something in PHP a bit odd, and I wanted to know if it’s just me or if others have felt the same 😅

I saw code like this:

if (! $authUser->isSuperAdmin()) {

And it kind of gave me a mental glitch… for me, the “normal” way has always been without the space:

if (!$authUser->isSuperAdmin()) {

So I looked it up and found that using the space (! $var) actually follows the PSR-12 standard and is totally valid it doesn’t change anything in how the code works.

But even so, visually it still feels a bit weird to me lol

So I wanted to ask you all:

  • do you use it with or without the space?
  • did it ever feel strange to you too?
  • do you strictly follow PSR-12 or just go with what you’re used to?

Curious to see how people usually write this day-to-day 🤔

reddit.com
u/Accomplished-Fan3195 — 14 days ago