Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9d534ee

Browse files
author
Pascal Montoya
committed
refs #26898
Check if projectDir is not null before loop
1 parent 9fd49cd commit 9d534ee

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Symfony/Bridge/Twig/Command/DebugCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,13 +274,13 @@ private function findWrongBundleOverrides(): array
274274
$alternatives = array();
275275
$bundleNames = array();
276276

277-
if ($this->rootDir) {
277+
if ($this->rootDir && $this->projectDir) {
278278
$folders = glob($this->rootDir.'/Resources/*/views', GLOB_ONLYDIR);
279279
$relativePath = ltrim(substr($this->rootDir.'/Resources/', \strlen($this->projectDir)), DIRECTORY_SEPARATOR);
280280
$bundleNames = array_reduce(
281281
$folders,
282282
function ($carry, $absolutePath) use ($relativePath) {
283-
if (null !== $this->projectDir && 0 === strpos($absolutePath, $this->projectDir)) {
283+
if (0 === strpos($absolutePath, $this->projectDir)) {
284284
$name = basename(\dirname($absolutePath));
285285
$path = $relativePath.$name;
286286
$carry[$name] = $path;
@@ -292,13 +292,13 @@ function ($carry, $absolutePath) use ($relativePath) {
292292
);
293293
}
294294

295-
if ($this->twigDefaultPath) {
295+
if ($this->twigDefaultPath && $this->projectDir) {
296296
$folders = glob($this->twigDefaultPath.'/bundles/*', GLOB_ONLYDIR);
297297
$relativePath = ltrim(substr($this->twigDefaultPath.'/bundles', \strlen($this->projectDir)), DIRECTORY_SEPARATOR);
298298
$bundleNames = array_reduce(
299299
$folders,
300300
function ($carry, $absolutePath) use ($relativePath) {
301-
if (null !== $this->projectDir && 0 === strpos($absolutePath, $this->projectDir)) {
301+
if (0 === strpos($absolutePath, $this->projectDir)) {
302302
$path = ltrim(substr($absolutePath, \strlen($this->projectDir)), DIRECTORY_SEPARATOR);
303303
$name = ltrim(substr($path, \strlen($relativePath)), DIRECTORY_SEPARATOR);
304304
$carry[$name] = $path;

0 commit comments

Comments
 (0)