[BUGFIX] Do not call non static methods statically 09/43509/3
authorHelmut Hummel <helmut.hummel@typo3.org>
Wed, 23 Sep 2015 18:58:11 +0000 (20:58 +0200)
committerGeorg Ringer <georg.ringer@gmail.com>
Wed, 23 Sep 2015 19:10:35 +0000 (21:10 +0200)
ClassInformationGenerator used to be a class with static methods.
Remove all static calls to methods which are not static any more.

Also make the property non static, so that we do not have to reset
the state if we do generate the class info twice in one request.

Resolves: #70057
Releases: master
Change-Id: I1323d40b1181676001f08c8a791c1f312308389c
Reviewed-on: http://review.typo3.org/43509
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Reviewed-by: Michael Oehlhof <typo3@oehlhof.de>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
typo3/sysext/core/Classes/Core/ClassLoadingInformationGenerator.php

index bb6430d..b6b5720 100644 (file)
@@ -30,7 +30,7 @@ class ClassLoadingInformationGenerator {
        /**
         * @var PackageInterface[]
         */
-       static protected $activeExtensionPackages;
+       protected $activeExtensionPackages;
 
        /**
         * Returns class loading information for a single package
@@ -44,7 +44,7 @@ class ClassLoadingInformationGenerator {
                $psr4 = array();
                $packagePath = $package->getPackagePath();
 
-               $manifest = self::getPackageManager()->getComposerManifest($package->getPackagePath());
+               $manifest = $this->getPackageManager()->getComposerManifest($package->getPackagePath());
                if (!empty($manifest->autoload->{'psr-4'})) {
                        $psr4manifest = json_decode(json_encode($manifest->autoload->{'psr-4'}), TRUE);
                        if (is_array($psr4manifest)) {
@@ -66,7 +66,7 @@ class ClassLoadingInformationGenerator {
                                        continue;
                                }
                                if ($useRelativePaths) {
-                                       $classMap[$class] = self::makePathRelative($packagePath, $path);
+                                       $classMap[$class] = $this->makePathRelative($packagePath, $path);
                                } else {
                                        $classMap[$class] = $path;
                                }
@@ -140,9 +140,6 @@ class ClassLoadingInformationGenerator {
         * @internal
         */
        public function buildAutoloadInformationFiles() {
-               // Ensure that for each re-build, the packages are fetched again from the package manager
-               self::$activeExtensionPackages = NULL;
-
                $psr4File = $classMapFile = <<<EOF
 <?php
 
@@ -156,7 +153,7 @@ EOF;
                $classMap = array();
                $psr4 = array();
                foreach ($this->getActiveExtensionPackages() as $package) {
-                       $classLoadingInformation = self::buildClassLoadingInformationForPackage($package, TRUE);
+                       $classLoadingInformation = $this->buildClassLoadingInformationForPackage($package, TRUE);
                        $classMap = array_merge($classMap, $classLoadingInformation['classMap']);
                        $psr4 = array_merge($psr4, $classLoadingInformation['psr-4']);
                }
@@ -164,12 +161,12 @@ EOF;
                ksort($classMap);
                ksort($psr4);
                foreach ($classMap as $class => $relativePath) {
-                       $classMapFile .= sprintf('    %s => %s,', var_export($class, TRUE), self::getPathCode($relativePath)) . LF;
+                       $classMapFile .= sprintf('    %s => %s,', var_export($class, TRUE), $this->getPathCode($relativePath)) . LF;
                }
                $classMapFile .= ");\n";
 
                foreach ($psr4 as $prefix => $relativePath) {
-                       $psr4File .= sprintf('    %s => array(%s),', var_export($prefix, TRUE), self::getPathCode($relativePath)) . LF;
+                       $psr4File .= sprintf('    %s => array(%s),', var_export($prefix, TRUE), $this->getPathCode($relativePath)) . LF;
                }
                $psr4File .= ");\n";
 
@@ -217,8 +214,8 @@ EOF;
        public function buildClassAliasMapFile() {
                $aliasToClassNameMapping = array();
                $classNameToAliasMapping = array();
-               foreach (self::getActiveExtensionPackages() as $package) {
-                       $aliasMappingForPackage = self::buildClassAliasMapForPackage($package);
+               foreach ($this->getActiveExtensionPackages() as $package) {
+                       $aliasMappingForPackage = $this->buildClassAliasMapForPackage($package);
                        $aliasToClassNameMapping = array_merge($aliasToClassNameMapping, $aliasMappingForPackage['aliasToClassNameMapping']);
                        $classNameToAliasMapping = array_merge($classNameToAliasMapping, $aliasMappingForPackage['classNameToAliasMapping']);
                }
@@ -238,18 +235,18 @@ EOF;
         * @return PackageInterface[]
         */
        protected function getActiveExtensionPackages() {
-               if (self::$activeExtensionPackages === NULL) {
-                       self::$activeExtensionPackages = array();
-                       foreach (self::getPackageManager()->getActivePackages() as $package) {
-                               if (self::isFrameworkPackage($package)) {
+               if ($this->activeExtensionPackages === NULL) {
+                       $this->activeExtensionPackages = array();
+                       foreach ($this->getPackageManager()->getActivePackages() as $package) {
+                               if ($this->isFrameworkPackage($package)) {
                                        // Skip all core packages as the class loading info is prepared for them already
                                        continue;
                                }
-                               self::$activeExtensionPackages[] = $package;
+                               $this->activeExtensionPackages[] = $package;
                        }
                }
 
-               return self::$activeExtensionPackages;
+               return $this->activeExtensionPackages;
        }
 
        /**