plugin-php icon indicating copy to clipboard operation
plugin-php copied to clipboard

Null coalesce operator getting too verbose sometimes

Open antonioribeiro opened this issue 5 years ago • 2 comments

Options

### General
trailingComma: all
printWidth: 80
tabWidth: 4
useTabs: false
singleQuote: true
requirePragma: false
insertPragma: false

### JavaScript
semi: false

### VueJS
vueIndentScriptAndStyle: true

### PHP
phpVersion: "7.4"
trailingCommaPHP: true
braceStyle: psr-2

Input:

return $data['template_name'] ?? $data['templateName'] ?? $this->templateName ?? $this->template_name ?? null;

Output:

return $data['template_name'] ??
    ($data['templateName'] ??
        ($this->templateName ?? ($this->template_name ?? null)));

Expected behavior:

return $data['template_name'] 
    ?? $data['templateName']
    ?? $this->templateName 
    ?? $this->template_name 
    ?? null;

antonioribeiro avatar May 23 '20 11:05 antonioribeiro

Prettier do same https://prettier.io/playground/#N4Igxg9gdgLgprEAuEAnOMCuqoAIAkAJgIYzEDaA5PALYAOANqXAPpTE1yUC6uAOnlxCA-MIIkyVWo2YA5Dl24ChIsfhgALAJYBnAHTSm8eZ36DVBTboNx6R1u1PKVo3FEwMGAbhAAaEBB0MFrQOsigxKioEADuAAqRCGEoxAwxxACeYf4ARqjEYADWGADKdAVaUADmyDComHD+GjA0DADq2vA65WBwJUlawQBugxnI4DrZIJU6cKgwcflVNMTIAGaps-4AVjoAHgBC+UWlCgAylXDrm40gu3sllVUMcACKmBDw1wxbIOWos1Q4xyxBycAYfj+qEqMDaWkImmQAA4AAz+OjRWZtfJ0cYYuCAoZXfwARw+8EWgWSIGIOgAtFA4HBCMzIegyVp0ItiMtVkgNj9brMaFpavUhU8Xu9Pld+Td-GQcnCERpkAAmBX5LQMJ4AYQgNBW4wJAFZIZhZgAVUHJAW-IYNACSUBZsBKYGhQQAgi6SjAMi9vrMAL7BoA, just put it on right side

alexander-akait avatar May 23 '20 11:05 alexander-akait

So we should improve it

alexander-akait avatar May 23 '20 11:05 alexander-akait