Skip to content

Replace file_exists() calls with is_file() where it is needed #225

Merged
merged 1 commit into from Nov 20, 2012
View
2 lib/Doctrine/Common/Annotations/AnnotationRegistry.php
@@ -120,7 +120,7 @@ static public function loadAnnotationClass($class)
}
} else {
foreach((array)$dirs AS $dir) {
- if (file_exists($dir . DIRECTORY_SEPARATOR . $file)) {
+ if (is_file($dir . DIRECTORY_SEPARATOR . $file)) {
require $dir . DIRECTORY_SEPARATOR . $file;
return true;
}
View
6 lib/Doctrine/Common/Annotations/FileCacheReader.php
@@ -91,7 +91,7 @@ public function getClassAnnotations(\ReflectionClass $class)
}
$path = $this->dir.'/'.strtr($key, '\\', '-').'.cache.php';
- if (!file_exists($path)) {
+ if (!is_file($path)) {
$annot = $this->reader->getClassAnnotations($class);
$this->saveCacheFile($path, $annot);
return $this->loadedAnnotations[$key] = $annot;
@@ -129,7 +129,7 @@ public function getPropertyAnnotations(\ReflectionProperty $property)
}
$path = $this->dir.'/'.strtr($key, '\\', '-').'.cache.php';
- if (!file_exists($path)) {
+ if (!is_file($path)) {
$annot = $this->reader->getPropertyAnnotations($property);
$this->saveCacheFile($path, $annot);
return $this->loadedAnnotations[$key] = $annot;
@@ -167,7 +167,7 @@ public function getMethodAnnotations(\ReflectionMethod $method)
}
$path = $this->dir.'/'.strtr($key, '\\', '-').'.cache.php';
- if (!file_exists($path)) {
+ if (!is_file($path)) {
$annot = $this->reader->getMethodAnnotations($method);
$this->saveCacheFile($path, $annot);
return $this->loadedAnnotations[$key] = $annot;
View
4 lib/Doctrine/Common/Annotations/PhpParser.php
@@ -46,7 +46,7 @@ public function parseClass(\ReflectionClass $class)
}
$content = $this->getFileContent($filename, $class->getStartLine());
-
+
if (null === $content) {
return array();
}
@@ -69,7 +69,7 @@ public function parseClass(\ReflectionClass $class)
*/
private function getFileContent($filename, $lineNumber)
{
- if ( ! file_exists($filename)) {
+ if ( ! is_file($filename)) {
return null;
}
View
4 lib/Doctrine/Common/Cache/FilesystemCache.php
@@ -44,7 +44,7 @@ protected function doFetch($id)
$lifetime = -1;
$filename = $this->getFilename($id);
- if ( ! file_exists($filename)) {
+ if ( ! is_file($filename)) {
return false;
}
@@ -77,7 +77,7 @@ protected function doContains($id)
$lifetime = -1;
$filename = $this->getFilename($id);
- if ( ! file_exists($filename)) {
+ if ( ! is_file($filename)) {
return false;
}
View
4 lib/Doctrine/Common/Cache/PhpFileCache.php
@@ -42,7 +42,7 @@ protected function doFetch($id)
{
$filename = $this->getFilename($id);
- if ( ! file_exists($filename)) {
+ if ( ! is_file($filename)) {
return false;
}
@@ -62,7 +62,7 @@ protected function doContains($id)
{
$filename = $this->getFilename($id);
- if ( ! file_exists($filename)) {
+ if ( ! is_file($filename)) {
return false;
}
View
2 lib/Doctrine/Common/ClassLoader.php
@@ -181,7 +181,7 @@ public function canLoadClass($className)
$file = str_replace($this->namespaceSeparator, DIRECTORY_SEPARATOR, $className) . $this->fileExtension;
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));
View
4 lib/Doctrine/Common/Persistence/Mapping/Driver/DefaultFileLocator.php
@@ -109,7 +109,7 @@ public function findMappingFile($className)
// Check whether file exists
foreach ($this->paths as $path) {
- if (file_exists($path . DIRECTORY_SEPARATOR . $fileName)) {
+ if (is_file($path . DIRECTORY_SEPARATOR . $fileName)) {
return $path . DIRECTORY_SEPARATOR . $fileName;
}
}
@@ -160,7 +160,7 @@ public function fileExists($className)
// Check whether file exists
foreach ((array) $this->paths as $path) {
- if (file_exists($path . DIRECTORY_SEPARATOR . $fileName)) {
+ if (is_file($path . DIRECTORY_SEPARATOR . $fileName)) {
return true;
}
}
View
2 lib/Doctrine/Common/Reflection/Psr0FindFile.php
@@ -73,7 +73,7 @@ public function findFile($class)
foreach ($this->prefixes as $prefix => $dirs) {
if (0 === strpos($class, $prefix)) {
foreach ($dirs as $dir) {
- if (file_exists($dir . DIRECTORY_SEPARATOR . $classPath)) {
+ if (is_file($dir . DIRECTORY_SEPARATOR . $classPath)) {
return $dir . DIRECTORY_SEPARATOR . $classPath;
}
}
View
4 tests/Doctrine/Tests/TestInit.php
@@ -11,14 +11,14 @@
{
if (0 === strpos($class, 'Doctrine\Tests\\')) {
$path = __DIR__.'/../../'.strtr($class, '\\', '/').'.php';
- if (file_exists($path) && is_readable($path)) {
+ if (is_file($path) && is_readable($path)) {
require_once $path;
return true;
}
} else if (0 === strpos($class, 'Doctrine\Common\\')) {
$path = __DIR__.'/../../../lib/'.($class = strtr($class, '\\', '/')).'.php';
- if (file_exists($path) && is_readable($path)) {
+ if (is_file($path) && is_readable($path)) {
require_once $path;
return true;
View
2 tests/NativePhpunitTask.php
@@ -124,7 +124,7 @@ public function main()
"failures (".$result->skippedCount()." skipped, ".$result->notImplementedCount()." not implemented)");
// 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);
$content = file_get_contents($this->coverageClover);
$content = str_replace("\\", ".", $content);
Something went wrong with that request. Please try again.