EC-CUBE /
ec-cube
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | /* |
||
| 4 | * This file is part of EC-CUBE |
||
| 5 | * |
||
| 6 | * Copyright(c) LOCKON CO.,LTD. All Rights Reserved. |
||
| 7 | * |
||
| 8 | * http://www.lockon.co.jp/ |
||
| 9 | * |
||
| 10 | * For the full copyright and license information, please view the LICENSE |
||
| 11 | * file that was distributed with this source code. |
||
| 12 | */ |
||
| 13 | |||
| 14 | namespace Eccube\Doctrine\ORM\Mapping\Driver; |
||
| 15 | |||
| 16 | use Doctrine\Common\Persistence\Mapping\MappingException; |
||
| 17 | |||
| 18 | class AnnotationDriver extends \Doctrine\ORM\Mapping\Driver\AnnotationDriver |
||
| 19 | { |
||
| 20 | protected $trait_proxies_directory; |
||
| 21 | |||
| 22 | 1285 | public function setTraitProxiesDirectory($dir) |
|
| 23 | { |
||
| 24 | 1285 | $this->trait_proxies_directory = $dir; |
|
| 25 | } |
||
| 26 | |||
| 27 | /** |
||
| 28 | * {@inheritdoc} |
||
| 29 | */ |
||
| 30 | 13 | public function getAllClassNames() |
|
| 31 | { |
||
| 32 | 13 | if ($this->classNames !== null) { |
|
| 33 | 4 | return $this->classNames; |
|
| 34 | } |
||
| 35 | |||
| 36 | 13 | if (!$this->paths) { |
|
|
0 ignored issues
–
show
|
|||
| 37 | throw MappingException::pathRequired(); |
||
| 38 | } |
||
| 39 | |||
| 40 | 13 | $classes = []; |
|
| 41 | 13 | $includedFiles = []; |
|
| 42 | |||
| 43 | 13 | foreach ($this->paths as $path) { |
|
| 44 | 13 | if (!is_dir($path)) { |
|
| 45 | throw MappingException::fileMappingDriversRequireConfiguredDirectoryPath($path); |
||
| 46 | } |
||
| 47 | |||
| 48 | 13 | $iterator = new \RegexIterator( |
|
| 49 | 13 | new \RecursiveIteratorIterator( |
|
| 50 | 13 | new \RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS), |
|
| 51 | 13 | \RecursiveIteratorIterator::LEAVES_ONLY |
|
| 52 | ), |
||
| 53 | 13 | '/^.+'.preg_quote($this->fileExtension).'$/i', |
|
| 54 | 13 | \RecursiveRegexIterator::GET_MATCH |
|
| 55 | ); |
||
| 56 | |||
| 57 | 13 | foreach ($iterator as $file) { |
|
| 58 | 13 | $sourceFile = $file[0]; |
|
| 59 | |||
| 60 | 13 | if (!preg_match('(^phar:)i', $sourceFile)) { |
|
| 61 | 13 | $sourceFile = realpath($sourceFile); |
|
| 62 | } |
||
| 63 | |||
| 64 | 13 | View Code Duplication | foreach ($this->excludePaths as $excludePath) { |
| 65 | $exclude = str_replace('\\', '/', realpath($excludePath)); |
||
| 66 | $current = str_replace('\\', '/', $sourceFile); |
||
| 67 | |||
| 68 | if (strpos($current, $exclude) !== false) { |
||
| 69 | continue 2; |
||
| 70 | } |
||
| 71 | } |
||
| 72 | |||
| 73 | 13 | $proxyFile = str_replace($path, $this->trait_proxies_directory, $sourceFile); |
|
| 74 | 13 | if (file_exists($proxyFile)) { |
|
| 75 | require_once $proxyFile; |
||
| 76 | |||
| 77 | $sourceFile = $proxyFile; |
||
| 78 | } else { |
||
| 79 | 13 | require_once $sourceFile; |
|
| 80 | } |
||
| 81 | |||
| 82 | 13 | $includedFiles[] = $sourceFile; |
|
| 83 | } |
||
| 84 | } |
||
| 85 | |||
| 86 | 13 | $declared = get_declared_classes(); |
|
| 87 | |||
| 88 | 13 | foreach ($declared as $className) { |
|
| 89 | 13 | $rc = new \ReflectionClass($className); |
|
| 90 | 13 | $sourceFile = $rc->getFileName(); |
|
| 91 | 13 | if (in_array($sourceFile, $includedFiles) && !$this->isTransient($className)) { |
|
| 92 | 13 | $classes[] = $className; |
|
| 93 | } |
||
| 94 | } |
||
| 95 | |||
| 96 | 13 | $this->classNames = $classes; |
|
| 97 | |||
| 98 | 13 | return $classes; |
|
| 99 | } |
||
| 100 | } |
||
| 101 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.