1

I am using Doctrine and have this line in PHP:

    $result = $entityManager->getRepository('Example\Entity\Users')->findOneBy(array(
        'address' => $address->getId(),
        'email' => $email->getEmail(),
        'type' => $type->getId(),
    ));

I would like to know if there is any code standards for setting lines with multiple calls. I looked through the Symphony and some of the others PSRs but couldn't find anything this specific.

Rafael
  • 1,495
  • 1
  • 14
  • 25

1 Answers1

1

PSR currently doesn't specify them. I usually take jQuery approach when chaining methods, e.g., each chain link is on its own line indented. So, using your code as an example, I'd do something like this:

$result = $entityManager
            ->getRepository('Example\Entity\Users')
            ->findOneBy(
                array(
                    'address' => $address->getId(),
                    'email'   => $email->getEmail(),
                    'type'    => $type->getId(),
                )
            );

But then again, some people will find it ugly, some will not :) It's PHP, afterall, no other language generates so many mixed opinions :)

Eihwaz
  • 1,234
  • 10
  • 14
  • I agree.. but then again, working on an environment that has so many different people coding, it would be good to have something to follow up. Have a problem like that it had only 2 lines and was escaping my 22" monitor. By the way, not a single one specifies this much? – Rafael Apr 06 '16 at 08:24