Skip to content

Commit 3172788

Browse files
Use is_file() instead of file_exists() where possible
1 parent 3cbcbf8 commit 3172788

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Caster/ExceptionCaster.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,15 +212,15 @@ public static function castFrameStub(FrameStub $frame, array $a, Stub $stub, boo
212212
$ellipsisTail = isset($ellipsis->attr['ellipsis-tail']) ? $ellipsis->attr['ellipsis-tail'] : 0;
213213
$ellipsis = isset($ellipsis->attr['ellipsis']) ? $ellipsis->attr['ellipsis'] : 0;
214214

215-
if (file_exists($f['file']) && 0 <= self::$srcContext) {
215+
if (is_file($f['file']) && 0 <= self::$srcContext) {
216216
if (!empty($f['class']) && (is_subclass_of($f['class'], 'Twig\Template') || is_subclass_of($f['class'], 'Twig_Template')) && method_exists($f['class'], 'getDebugInfo')) {
217217
$template = isset($f['object']) ? $f['object'] : unserialize(sprintf('O:%d:"%s":0:{}', \strlen($f['class']), $f['class']));
218218

219219
$ellipsis = 0;
220220
$templateSrc = method_exists($template, 'getSourceContext') ? $template->getSourceContext()->getCode() : (method_exists($template, 'getSource') ? $template->getSource() : '');
221221
$templateInfo = $template->getDebugInfo();
222222
if (isset($templateInfo[$f['line']])) {
223-
if (!method_exists($template, 'getSourceContext') || !file_exists($templatePath = $template->getSourceContext()->getPath())) {
223+
if (!method_exists($template, 'getSourceContext') || !is_file($templatePath = $template->getSourceContext()->getPath())) {
224224
$templatePath = null;
225225
}
226226
if ($templateSrc) {

Caster/LinkStub.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function __construct($label, int $line = 0, $href = null)
4343

4444
return;
4545
}
46-
if (!file_exists($href)) {
46+
if (!is_file($href)) {
4747
return;
4848
}
4949
if ($line) {
@@ -72,7 +72,7 @@ private function getComposerRoot(string $file, bool &$inVendor)
7272
if ('C' === $class[0] && 0 === strpos($class, 'ComposerAutoloaderInit')) {
7373
$r = new \ReflectionClass($class);
7474
$v = \dirname($r->getFileName(), 2);
75-
if (file_exists($v.'/composer/installed.json')) {
75+
if (is_file($v.'/composer/installed.json')) {
7676
self::$vendorRoots[] = $v.\DIRECTORY_SEPARATOR;
7777
}
7878
}
@@ -91,7 +91,7 @@ private function getComposerRoot(string $file, bool &$inVendor)
9191
}
9292

9393
$parent = $dir;
94-
while (!@file_exists($parent.'/composer.json')) {
94+
while (!@is_file($parent.'/composer.json')) {
9595
if (!@file_exists($parent)) {
9696
// open_basedir restriction in effect
9797
break;

0 commit comments

Comments
 (0)