Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

202
Visualizações
PHPCS Allow simple methods in one line

I find the code

$ids = array_map(function ($entity) { return $entity->getId(); }, $entities);

much more readable than

$ids = array_map(function ($entity) { 
    return $entity->getId(); 
}, $entities);

However, the PHPCS forces me to use the second style, because the first one fails with the following for PSR-2 styles:

  • Squiz.Functions.MultiLineFunctionDeclaration.ContentAfterBrace says that Opening brace must be the last content on the line
  • Squiz.WhiteSpace.ScopeClosingBrace.ContentBefore says that Closing brace must be on a line by itself
  • Generic.Formatting.DisallowMultipleStatements.SameLine says that Each PHP statement must be on a line by itself

While I generally agree with these checks in other places, in this case they are completely wrong.

Is there a rule that would say to PHPCS that it should allow Simple methods in one line just like PHPStorm does?

Simple methods in one line in PHPStorm

I know I can ignore PHPCS checks in such places but I would prefer tackling this in a global configuration.

about 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda