1 | <?php |
||
11 | final class NameAndFolderResolveTemplatePath implements ResolveTemplatePath |
||
12 | { |
||
13 | /** |
||
14 | * Identifier of the main namespace. |
||
15 | * |
||
16 | * @var string |
||
17 | */ |
||
18 | const MAIN_NAMESPACE = '__main__'; |
||
19 | |||
20 | /** |
||
21 | * Collection of template folders. |
||
22 | */ |
||
23 | protected $paths = []; |
||
24 | |||
25 | public function __invoke(Name $name): string |
||
38 | |||
39 | public function exists(Name $name): bool |
||
48 | |||
49 | public function resolvePath(Name $name) |
||
68 | |||
69 | /** |
||
70 | * Returns the paths to the templates. |
||
71 | */ |
||
72 | public function getPaths(string $namespace = self::MAIN_NAMESPACE): array |
||
78 | |||
79 | /** |
||
80 | * Returns the path namespaces. |
||
81 | * |
||
82 | * The main namespace is always defined. |
||
83 | */ |
||
84 | public function getNamespaces(): array |
||
88 | |||
89 | /** |
||
90 | * @param string|array $paths A path or an array of paths where to look for templates |
||
91 | */ |
||
92 | public function setPaths($paths, string $namespace = self::MAIN_NAMESPACE): void |
||
103 | |||
104 | /** |
||
105 | * @throws \Exception |
||
106 | */ |
||
107 | public function addPath(string $path, string $namespace = self::MAIN_NAMESPACE) |
||
115 | |||
116 | public function prependPath(string $path, string $namespace = self::MAIN_NAMESPACE): void |
||
130 | |||
131 | protected function normalizePath($path, Name $name): string |
||
139 | |||
140 | /** |
||
141 | * Get the default templates directory. |
||
142 | * @return string |
||
143 | */ |
||
144 | protected function getDefaultDirectory(Name $name) |
||
157 | |||
158 | protected function normalizeNamespace($namespace = self::MAIN_NAMESPACE): string |
||
166 | } |
||
167 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.