Changeset View
Changeset View
Standalone View
Standalone View
src/applications/files/markup/PhabricatorEmbedFileRemarkupRule.php
Show First 20 Lines • Show All 191 Lines • ▼ Show 20 Lines | if ($use_size) { | ||||||||
} | } | ||||||||
} | } | ||||||||
$alt = null; | $alt = null; | ||||||||
if (isset($options['alt'])) { | if (isset($options['alt'])) { | ||||||||
$alt = $options['alt']; | $alt = $options['alt']; | ||||||||
} | } | ||||||||
if (!strlen($alt)) { | if (!phutil_nonempty_string($alt)) { | ||||||||
valerio.bozzolan: ✅ The function `phutil_nonempty_string()` will explode for any non-string and non-null types… | |||||||||
$alt = $file->getAltText(); | $alt = $file->getAltText(); | ||||||||
} | } | ||||||||
$attrs['alt'] = $alt; | $attrs['alt'] = $alt; | ||||||||
$img = phutil_tag('img', $attrs); | $img = phutil_tag('img', $attrs); | ||||||||
$embed = javelin_tag( | $embed = javelin_tag( | ||||||||
▲ Show 20 Lines • Show All 131 Lines • ▼ Show 20 Lines | return id(new PhabricatorFileLinkView()) | ||||||||
->setFileName($this->assertFlatText($options['name'])) | ->setFileName($this->assertFlatText($options['name'])) | ||||||||
->setFileDownloadURI($file->getDownloadURI()) | ->setFileDownloadURI($file->getDownloadURI()) | ||||||||
->setFileViewURI($file->getBestURI()) | ->setFileViewURI($file->getBestURI()) | ||||||||
->setFileViewable((bool)$options['viewable']) | ->setFileViewable((bool)$options['viewable']) | ||||||||
->setFileSize(phutil_format_bytes($file->getByteSize())) | ->setFileSize(phutil_format_bytes($file->getByteSize())) | ||||||||
->setFileMonogram($file->getMonogram()); | ->setFileMonogram($file->getMonogram()); | ||||||||
} | } | ||||||||
private function parseDimension($string) { | private function parseDimension($string) { | ||||||||
if ($string !== null) { | |||||||||
Not Done Inline Actions
valerio.bozzolan: | |||||||||
Not Done Inline ActionsWe are inside the PHP pitfall if($string) that excludes the string "0". Interestingly:
So it seems zero is an useful value to keep included at this level. valerio.bozzolan: We are inside the PHP pitfall `if($string)` that excludes the string `"0"`.
Interestingly:
|… | |||||||||
$string = trim($string); | $string = trim($string); | ||||||||
if (preg_match('/^(?:\d*\\.)?\d+%?$/', $string)) { | if (preg_match('/^(?:\d*\\.)?\d+%?$/', $string)) { | ||||||||
Done Inline ActionsFor the records apparently this regex was designed to capture stuff like:
valerio.bozzolan: For the records apparently this regex was designed to capture stuff like:
- `0`
- `1`
- `0.1`… | |||||||||
return $string; | return $string; | ||||||||
} | } | ||||||||
} | |||||||||
return null; | return null; | ||||||||
} | } | ||||||||
} | } |
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
✅ The function phutil_nonempty_string() will explode for any non-string and non-null types, and that is OK here.