Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/editor/PhabricatorEditorURIEngine.php
Show All 10 Lines | final class PhabricatorEditorURIEngine | ||||
public static function newForViewer(PhabricatorUser $viewer) { | public static function newForViewer(PhabricatorUser $viewer) { | ||||
if (!$viewer->isLoggedIn()) { | if (!$viewer->isLoggedIn()) { | ||||
return null; | return null; | ||||
} | } | ||||
$pattern = $viewer->getUserSetting(PhabricatorEditorSetting::SETTINGKEY); | $pattern = $viewer->getUserSetting(PhabricatorEditorSetting::SETTINGKEY); | ||||
if (!strlen(trim($pattern))) { | if ($pattern === null || !strlen(trim($pattern))) { | ||||
return null; | return null; | ||||
} | } | ||||
speck: This could be simplified | |||||
Not Done Inline ActionsPlease avoid having nested if statements with simple conditions, see suggested change. speck: Please avoid having nested if statements with simple conditions, see suggested change. | |||||
Done Inline ActionsAnother safe approach thanks to the return type of trim: if ($pattern === null || trim($pattern) === '') { valerio.bozzolan: Another safe approach thanks to the return type of trim:
```lang=php
if ($pattern === null ||… | |||||
$engine = id(new self()) | $engine = id(new self()) | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->setPattern($pattern); | ->setPattern($pattern); | ||||
// If there's a problem with the pattern, | // If there's a problem with the pattern, | ||||
try { | try { | ||||
▲ Show 20 Lines • Show All 337 Lines • Show Last 20 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0
This could be simplified