Skip to content

Commit 0eae562

Browse files
committed
converted file_exists calls to either is_file or is_dir where it makes sense
1 parent 4e70b1a commit 0eae562

File tree

26 files changed

+46
-46
lines changed

26 files changed

+46
-46
lines changed

src/Symfony/Bridge/Doctrine/CacheWarmer/ProxyCacheWarmer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function warmUp($cacheDir)
5050
{
5151
foreach ($this->registry->getEntityManagers() as $em) {
5252
// we need the directory no matter the proxy cache generation strategy
53-
if (!file_exists($proxyCacheDir = $em->getConfiguration()->getProxyDir())) {
53+
if (!is_dir($proxyCacheDir = $em->getConfiguration()->getProxyDir())) {
5454
if (false === @mkdir($proxyCacheDir, 0777, true)) {
5555
throw new \RuntimeException(sprintf('Unable to create the Doctrine Proxy directory "%s".', dirname($proxyCacheDir)));
5656
}

src/Symfony/Bridge/Doctrine/Mapping/Driver/XmlDriver.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ protected function initialize()
123123
$this->_classCache = array();
124124
if (null !== $this->_globalBasename) {
125125
foreach ($this->_paths as $path) {
126-
if (file_exists($file = $path.'/'.$this->_globalBasename.$this->_fileExtension)) {
126+
if (is_file($file = $path.'/'.$this->_globalBasename.$this->_fileExtension)) {
127127
$this->_classCache = array_merge($this->_classCache, $this->_loadMappingFile($file));
128128
}
129129
}
@@ -135,7 +135,7 @@ protected function _findMappingFile($className)
135135
$defaultFileName = str_replace('\\', '.', $className).$this->_fileExtension;
136136
foreach ($this->_paths as $path) {
137137
if (!isset($this->_prefixes[$path])) {
138-
if (file_exists($path.DIRECTORY_SEPARATOR.$defaultFileName)) {
138+
if (is_file($path.DIRECTORY_SEPARATOR.$defaultFileName)) {
139139
return $path.DIRECTORY_SEPARATOR.$defaultFileName;
140140
}
141141

@@ -149,7 +149,7 @@ protected function _findMappingFile($className)
149149
}
150150

151151
$filename = $path.'/'.strtr(substr($className, strlen($prefix)+1), '\\', '.').$this->_fileExtension;
152-
if (file_exists($filename)) {
152+
if (is_file($filename)) {
153153
return $filename;
154154
}
155155

src/Symfony/Bridge/Doctrine/Mapping/Driver/YamlDriver.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ protected function initialize()
123123
$this->_classCache = array();
124124
if (null !== $this->_globalBasename) {
125125
foreach ($this->_paths as $path) {
126-
if (file_exists($file = $path.'/'.$this->_globalBasename.$this->_fileExtension)) {
126+
if (is_file($file = $path.'/'.$this->_globalBasename.$this->_fileExtension)) {
127127
$this->_classCache = array_merge($this->_classCache, $this->_loadMappingFile($file));
128128
}
129129
}
@@ -135,7 +135,7 @@ protected function _findMappingFile($className)
135135
$defaultFileName = str_replace('\\', '.', $className).$this->_fileExtension;
136136
foreach ($this->_paths as $path) {
137137
if (!isset($this->_prefixes[$path])) {
138-
if (file_exists($path.DIRECTORY_SEPARATOR.$defaultFileName)) {
138+
if (is_file($path.DIRECTORY_SEPARATOR.$defaultFileName)) {
139139
return $path.DIRECTORY_SEPARATOR.$defaultFileName;
140140
}
141141

@@ -149,7 +149,7 @@ protected function _findMappingFile($className)
149149
}
150150

151151
$filename = $path.'/'.strtr(substr($className, strlen($prefix)+1), '\\', '.').$this->_fileExtension;
152-
if (file_exists($filename)) {
152+
if (is_file($filename)) {
153153
return $filename;
154154
}
155155

src/Symfony/Bundle/DoctrineAbstractBundle/DependencyInjection/AbstractDoctrineExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ protected function loadMappingInformation(array $objectManager, ContainerBuilder
6565
$mappingConfig['dir'] = $container->getParameterBag()->resolveValue($mappingConfig['dir']);
6666
// a bundle configuration is detected by realizing that the specified dir is not absolute and existing
6767
if (!isset($mappingConfig['is_bundle'])) {
68-
$mappingConfig['is_bundle'] = !file_exists($mappingConfig['dir']);
68+
$mappingConfig['is_bundle'] = !is_dir($mappingConfig['dir']);
6969
}
7070

7171
if ($mappingConfig['is_bundle']) {
@@ -234,7 +234,7 @@ protected function assertValidMappingConfiguration(array $mappingConfig, $object
234234
throw new \InvalidArgumentException(sprintf('Mapping definitions for Doctrine manager "%s" require at least the "type", "dir" and "prefix" options.', $objectManagerName));
235235
}
236236

237-
if (!file_exists($mappingConfig['dir'])) {
237+
if (!is_dir($mappingConfig['dir'])) {
238238
throw new \InvalidArgumentException(sprintf('Specified non-existing directory "%s" as Doctrine mapping source.', $mappingConfig['dir']));
239239
}
240240

src/Symfony/Bundle/DoctrineBundle/DoctrineBundle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class_exists('Doctrine\ORM\Mapping\Driver\AnnotationDriver');
4848
$className = substr($class, strlen($namespace) +1);
4949
$file = $dir.DIRECTORY_SEPARATOR.$className.'.php';
5050

51-
if (!file_exists($file)) {
51+
if (!is_file($file)) {
5252
throw new \RuntimeException(sprintf('The proxy file "%s" does not exist. If you still have objects serialized in the session, you need to clear the session manually.', $file));
5353
}
5454

src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ private function getContainerBuilder()
183183
throw new \LogicException(sprintf('Debug information about the container is only available in debug mode.'));
184184
}
185185

186-
if (!file_exists($cachedFile = $this->getContainer()->getParameter('debug.container.dump'))) {
186+
if (!is_file($cachedFile = $this->getContainer()->getParameter('debug.container.dump'))) {
187187
throw new \LogicException(sprintf('Debug information about the container could not be found. Please clear the cache and try again.'));
188188
}
189189

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ private function getValidatorXmlMappingFiles(ContainerBuilder $container)
548548

549549
foreach ($container->getParameter('kernel.bundles') as $bundle) {
550550
$reflection = new \ReflectionClass($bundle);
551-
if (file_exists($file = dirname($reflection->getFilename()).'/Resources/config/validation.xml')) {
551+
if (is_file($file = dirname($reflection->getFilename()).'/Resources/config/validation.xml')) {
552552
$files[] = realpath($file);
553553
$container->addResource(new FileResource($file));
554554
}
@@ -563,7 +563,7 @@ private function getValidatorYamlMappingFiles(ContainerBuilder $container)
563563

564564
foreach ($container->getParameter('kernel.bundles') as $bundle) {
565565
$reflection = new \ReflectionClass($bundle);
566-
if (file_exists($file = dirname($reflection->getFilename()).'/Resources/config/validation.yml')) {
566+
if (is_file($file = dirname($reflection->getFilename()).'/Resources/config/validation.yml')) {
567567
$files[] = realpath($file);
568568
$container->addResource(new FileResource($file));
569569
}

src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public function formatFile($file, $line, $text = null)
189189
*/
190190
public function getFileLink($file, $line)
191191
{
192-
if ($this->fileLinkFormat && file_exists($file)) {
192+
if ($this->fileLinkFormat && is_file($file)) {
193193
return strtr($this->fileLinkFormat, array('%f' => $file, '%l' => $line));
194194
}
195195

src/Symfony/Bundle/FrameworkBundle/Templating/Loader/TemplateLocator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class TemplateLocator implements FileLocatorInterface
3333
*/
3434
public function __construct(FileLocatorInterface $locator, $cacheDir = null)
3535
{
36-
if (null !== $cacheDir && file_exists($cache = $cacheDir.'/templates.php')) {
36+
if (null !== $cacheDir && is_file($cache = $cacheDir.'/templates.php')) {
3737
$this->cache = require $cache;
3838
}
3939

src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ static protected function getPhpUnitXmlDir()
6161

6262
$dir = static::getPhpUnitCliConfigArgument();
6363
if ($dir === null &&
64-
(file_exists(getcwd().DIRECTORY_SEPARATOR.'phpunit.xml') ||
65-
file_exists(getcwd().DIRECTORY_SEPARATOR.'phpunit.xml.dist'))) {
64+
(is_file(getcwd().DIRECTORY_SEPARATOR.'phpunit.xml') ||
65+
is_file(getcwd().DIRECTORY_SEPARATOR.'phpunit.xml.dist'))) {
6666
$dir = getcwd();
6767
}
6868

0 commit comments

Comments
 (0)