PHP长的三元运算符行和120个字符长的PSR规则



有没有一种好的方法来格式化长的三元运算符行?比方说:

$order = new Order($this->isProfessionalChildCollaborator($this->getUser()) ? $this->getUser()->getParent() : $this->getUser());

根据PSR中定义的每行120个字符,这太长了。我应该这样做吗:

$order = new Order(
$this->isProfessionalChildCollaborator($this->getUser()) ?
$this->getUser()->getParent() :
$this->getUser()
);

或者还有其他最佳实践吗?

PSR中没有相关规则,但我更喜欢中描述的这种样式

$documentProcessingIndicatorId = $object->isProcessingDocument()
? $object->getDocumentProcessingIndicatorId()
: null;

最新更新