Skip to content

Commit

Permalink
Replace file_exists() calls with is_file() where it is needed
Browse files Browse the repository at this point in the history
  • Loading branch information
fruit committed Nov 20, 2012
1 parent 3fd7343 commit c17b9da
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion lib/Doctrine/Common/Annotations/AnnotationRegistry.php
Expand Up @@ -120,7 +120,7 @@ static public function loadAnnotationClass($class)
} }
} else { } else {
foreach((array)$dirs AS $dir) { foreach((array)$dirs AS $dir) {
if (file_exists($dir . DIRECTORY_SEPARATOR . $file)) { if (is_file($dir . DIRECTORY_SEPARATOR . $file)) {
require $dir . DIRECTORY_SEPARATOR . $file; require $dir . DIRECTORY_SEPARATOR . $file;
return true; return true;
} }
Expand Down
6 changes: 3 additions & 3 deletions lib/Doctrine/Common/Annotations/FileCacheReader.php
Expand Up @@ -91,7 +91,7 @@ public function getClassAnnotations(\ReflectionClass $class)
} }


$path = $this->dir.'/'.strtr($key, '\\', '-').'.cache.php'; $path = $this->dir.'/'.strtr($key, '\\', '-').'.cache.php';
if (!file_exists($path)) { if (!is_file($path)) {
$annot = $this->reader->getClassAnnotations($class); $annot = $this->reader->getClassAnnotations($class);
$this->saveCacheFile($path, $annot); $this->saveCacheFile($path, $annot);
return $this->loadedAnnotations[$key] = $annot; return $this->loadedAnnotations[$key] = $annot;
Expand Down Expand Up @@ -129,7 +129,7 @@ public function getPropertyAnnotations(\ReflectionProperty $property)
} }


$path = $this->dir.'/'.strtr($key, '\\', '-').'.cache.php'; $path = $this->dir.'/'.strtr($key, '\\', '-').'.cache.php';
if (!file_exists($path)) { if (!is_file($path)) {
$annot = $this->reader->getPropertyAnnotations($property); $annot = $this->reader->getPropertyAnnotations($property);
$this->saveCacheFile($path, $annot); $this->saveCacheFile($path, $annot);
return $this->loadedAnnotations[$key] = $annot; return $this->loadedAnnotations[$key] = $annot;
Expand Down Expand Up @@ -167,7 +167,7 @@ public function getMethodAnnotations(\ReflectionMethod $method)
} }


$path = $this->dir.'/'.strtr($key, '\\', '-').'.cache.php'; $path = $this->dir.'/'.strtr($key, '\\', '-').'.cache.php';
if (!file_exists($path)) { if (!is_file($path)) {
$annot = $this->reader->getMethodAnnotations($method); $annot = $this->reader->getMethodAnnotations($method);
$this->saveCacheFile($path, $annot); $this->saveCacheFile($path, $annot);
return $this->loadedAnnotations[$key] = $annot; return $this->loadedAnnotations[$key] = $annot;
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/Common/Annotations/PhpParser.php
Expand Up @@ -46,7 +46,7 @@ public function parseClass(\ReflectionClass $class)
} }


$content = $this->getFileContent($filename, $class->getStartLine()); $content = $this->getFileContent($filename, $class->getStartLine());

if (null === $content) { if (null === $content) {
return array(); return array();
} }
Expand All @@ -69,7 +69,7 @@ public function parseClass(\ReflectionClass $class)
*/ */
private function getFileContent($filename, $lineNumber) private function getFileContent($filename, $lineNumber)
{ {
if ( ! file_exists($filename)) { if ( ! is_file($filename)) {
return null; return null;
} }


Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/Common/Cache/FilesystemCache.php
Expand Up @@ -44,7 +44,7 @@ protected function doFetch($id)
$lifetime = -1; $lifetime = -1;
$filename = $this->getFilename($id); $filename = $this->getFilename($id);


if ( ! file_exists($filename)) { if ( ! is_file($filename)) {
return false; return false;
} }


Expand Down Expand Up @@ -77,7 +77,7 @@ protected function doContains($id)
$lifetime = -1; $lifetime = -1;
$filename = $this->getFilename($id); $filename = $this->getFilename($id);


if ( ! file_exists($filename)) { if ( ! is_file($filename)) {
return false; return false;
} }


Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/Common/Cache/PhpFileCache.php
Expand Up @@ -42,7 +42,7 @@ protected function doFetch($id)
{ {
$filename = $this->getFilename($id); $filename = $this->getFilename($id);


if ( ! file_exists($filename)) { if ( ! is_file($filename)) {
return false; return false;
} }


Expand All @@ -62,7 +62,7 @@ protected function doContains($id)
{ {
$filename = $this->getFilename($id); $filename = $this->getFilename($id);


if ( ! file_exists($filename)) { if ( ! is_file($filename)) {
return false; return false;
} }


Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/Common/ClassLoader.php
Expand Up @@ -181,7 +181,7 @@ public function canLoadClass($className)
$file = str_replace($this->namespaceSeparator, DIRECTORY_SEPARATOR, $className) . $this->fileExtension; $file = str_replace($this->namespaceSeparator, DIRECTORY_SEPARATOR, $className) . $this->fileExtension;


if ($this->includePath !== null) { if ($this->includePath !== null) {
return file_exists($this->includePath . DIRECTORY_SEPARATOR . $file); return is_file($this->includePath . DIRECTORY_SEPARATOR . $file);
} }


return (false !== stream_resolve_include_path($file)); return (false !== stream_resolve_include_path($file));
Expand Down
Expand Up @@ -109,7 +109,7 @@ public function findMappingFile($className)


// Check whether file exists // Check whether file exists
foreach ($this->paths as $path) { foreach ($this->paths as $path) {
if (file_exists($path . DIRECTORY_SEPARATOR . $fileName)) { if (is_file($path . DIRECTORY_SEPARATOR . $fileName)) {
return $path . DIRECTORY_SEPARATOR . $fileName; return $path . DIRECTORY_SEPARATOR . $fileName;
} }
} }
Expand Down Expand Up @@ -160,7 +160,7 @@ public function fileExists($className)


// Check whether file exists // Check whether file exists
foreach ((array) $this->paths as $path) { foreach ((array) $this->paths as $path) {
if (file_exists($path . DIRECTORY_SEPARATOR . $fileName)) { if (is_file($path . DIRECTORY_SEPARATOR . $fileName)) {
return true; return true;
} }
} }
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/Common/Reflection/Psr0FindFile.php
Expand Up @@ -73,7 +73,7 @@ public function findFile($class)
foreach ($this->prefixes as $prefix => $dirs) { foreach ($this->prefixes as $prefix => $dirs) {
if (0 === strpos($class, $prefix)) { if (0 === strpos($class, $prefix)) {
foreach ($dirs as $dir) { foreach ($dirs as $dir) {
if (file_exists($dir . DIRECTORY_SEPARATOR . $classPath)) { if (is_file($dir . DIRECTORY_SEPARATOR . $classPath)) {
return $dir . DIRECTORY_SEPARATOR . $classPath; return $dir . DIRECTORY_SEPARATOR . $classPath;
} }
} }
Expand Down
4 changes: 2 additions & 2 deletions tests/Doctrine/Tests/TestInit.php
Expand Up @@ -11,14 +11,14 @@
{ {
if (0 === strpos($class, 'Doctrine\Tests\\')) { if (0 === strpos($class, 'Doctrine\Tests\\')) {
$path = __DIR__.'/../../'.strtr($class, '\\', '/').'.php'; $path = __DIR__.'/../../'.strtr($class, '\\', '/').'.php';
if (file_exists($path) && is_readable($path)) { if (is_file($path) && is_readable($path)) {
require_once $path; require_once $path;


return true; return true;
} }
} else if (0 === strpos($class, 'Doctrine\Common\\')) { } else if (0 === strpos($class, 'Doctrine\Common\\')) {
$path = __DIR__.'/../../../lib/'.($class = strtr($class, '\\', '/')).'.php'; $path = __DIR__.'/../../../lib/'.($class = strtr($class, '\\', '/')).'.php';
if (file_exists($path) && is_readable($path)) { if (is_file($path) && is_readable($path)) {
require_once $path; require_once $path;


return true; return true;
Expand Down
2 changes: 1 addition & 1 deletion tests/NativePhpunitTask.php
Expand Up @@ -124,7 +124,7 @@ public function main()
"failures (".$result->skippedCount()." skipped, ".$result->notImplementedCount()." not implemented)"); "failures (".$result->skippedCount()." skipped, ".$result->notImplementedCount()." not implemented)");


// Hudson for example doesn't like the backslash in class names // Hudson for example doesn't like the backslash in class names
if (file_exists($this->coverageClover)) { if (is_file($this->coverageClover)) {
$this->log("Generated Clover Coverage XML to: ".$this->coverageClover); $this->log("Generated Clover Coverage XML to: ".$this->coverageClover);
$content = file_get_contents($this->coverageClover); $content = file_get_contents($this->coverageClover);
$content = str_replace("\\", ".", $content); $content = str_replace("\\", ".", $content);
Expand Down

0 comments on commit c17b9da

Please sign in to comment.