Skip to content

Commit

Permalink
bug #19298 [ClassLoader] Fix declared classes being computed when not…
Browse files Browse the repository at this point in the history
… needed (nicolas-grekas)

This PR was merged into the 2.7 branch.

Discussion
----------

[ClassLoader] Fix declared classes being computed when not needed

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | no
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Commits
-------

d513eae [ClassLoader] Fix declared classes being computed when not needed
  • Loading branch information
nicolas-grekas committed Jul 10, 2016
2 parents b7ed32a + d513eae commit 7c39ac1
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/Symfony/Component/ClassLoader/ClassCollectionLoader.php
Expand Up @@ -43,12 +43,12 @@ public static function load($classes, $cacheDir, $name, $autoReload, $adaptive =

self::$loaded[$name] = true;

$declared = array_merge(get_declared_classes(), get_declared_interfaces());
if (function_exists('get_declared_traits')) {
$declared = array_merge($declared, get_declared_traits());
}

if ($adaptive) {
$declared = array_merge(get_declared_classes(), get_declared_interfaces());
if (function_exists('get_declared_traits')) {
$declared = array_merge($declared, get_declared_traits());
}

// don't include already declared classes
$classes = array_diff($classes, $declared);

Expand Down Expand Up @@ -87,11 +87,17 @@ public static function load($classes, $cacheDir, $name, $autoReload, $adaptive =
}
}

if (!$reload && is_file($cache)) {
if (!$reload && file_exists($cache)) {
require_once $cache;

return;
}
if (!$adaptive) {
$declared = array_merge(get_declared_classes(), get_declared_interfaces());
if (function_exists('get_declared_traits')) {
$declared = array_merge($declared, get_declared_traits());
}
}

$files = array();
$content = '';
Expand Down

0 comments on commit 7c39ac1

Please sign in to comment.