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
|
1326 |
|
public function setTraitProxiesDirectory($dir) |
23
|
|
|
{ |
24
|
1326 |
|
$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) { |
|
|
|
|
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
|
13 |
View Code Duplication |
if ('\\' === DIRECTORY_SEPARATOR) { |
73
|
|
|
$path = str_replace('\\', '/', $path); |
74
|
|
|
$this->trait_proxies_directory = str_replace('\\', '/', $this->trait_proxies_directory); |
75
|
|
|
$sourceFile = str_replace('\\', '/', $sourceFile); |
76
|
|
|
} |
77
|
13 |
|
$proxyFile = str_replace($path, $this->trait_proxies_directory, $sourceFile); |
78
|
13 |
|
if (file_exists($proxyFile)) { |
79
|
|
|
require_once $proxyFile; |
80
|
|
|
|
81
|
|
|
$sourceFile = $proxyFile; |
82
|
|
|
} else { |
83
|
13 |
|
require_once $sourceFile; |
84
|
|
|
} |
85
|
|
|
|
86
|
13 |
|
$includedFiles[] = realpath($sourceFile); |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|
90
|
13 |
|
$declared = get_declared_classes(); |
91
|
|
|
|
92
|
13 |
|
foreach ($declared as $className) { |
93
|
13 |
|
$rc = new \ReflectionClass($className); |
94
|
13 |
|
$sourceFile = $rc->getFileName(); |
95
|
13 |
|
if (in_array($sourceFile, $includedFiles) && !$this->isTransient($className)) { |
96
|
13 |
|
$classes[] = $className; |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|
100
|
13 |
|
$this->classNames = $classes; |
101
|
|
|
|
102
|
13 |
|
return $classes; |
103
|
|
|
} |
104
|
|
|
} |
105
|
|
|
|
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.