summaryrefslogtreecommitdiffstats
path: root/php-symfony3-generate-autoloaders.php
diff options
context:
space:
mode:
authorRemi Collet <remi@remirepo.net>2017-08-21 13:09:30 +0200
committerRemi Collet <remi@remirepo.net>2017-08-21 13:09:30 +0200
commit72c1a0177d421712c1bc2856a9563a35714b5d92 (patch)
tree466f67f31f9b19f98b9c86e6332f394d157211af /php-symfony3-generate-autoloaders.php
parent13761a01dc4aeccde3cab1284805f77fe22de539 (diff)
sync with Fedora
Diffstat (limited to 'php-symfony3-generate-autoloaders.php')
-rwxr-xr-xphp-symfony3-generate-autoloaders.php97
1 files changed, 79 insertions, 18 deletions
diff --git a/php-symfony3-generate-autoloaders.php b/php-symfony3-generate-autoloaders.php
index 9b6f152..3f0fcc3 100755
--- a/php-symfony3-generate-autoloaders.php
+++ b/php-symfony3-generate-autoloaders.php
@@ -16,7 +16,8 @@ $finder->in(SYMFONY_SOURCE_DIR)->name('composer.json')->sortByName();
foreach ($finder as $composerFile) {
$autoloadGenerator = new AutoloadGenerator($composerFile);
- echo $autoloadGenerator->getFilename(), "\n";
+ echo $autoloadGenerator->getFilename().PHP_EOL;
+ echo $autoloadGenerator->getDevFilename().PHP_EOL;
}
@@ -25,6 +26,10 @@ foreach ($finder as $composerFile) {
final class AutoloadGenerator {
private static $pkgMap = [
+ 'cache/integration-tests' => [
+ 'prefix' => 'FEDORA_SYMFONY3_PHP_DIR',
+ 'path' => 'Cache/IntegrationTests/autoload.php',
+ ],
'doctrine/annotations' => [
'prefix' => 'FEDORA_SYMFONY3_PHP_DIR',
'path' => 'Doctrine/Common/Annotations/autoload.php',
@@ -33,6 +38,10 @@ final class AutoloadGenerator {
'prefix' => 'FEDORA_SYMFONY3_PHP_DIR',
'path' => 'Doctrine/Common/Cache/autoload.php',
],
+ 'doctrine/collections' => [
+ 'prefix' => 'FEDORA_SYMFONY3_PHP_DIR',
+ 'path' => 'Doctrine/Common/Collections/autoload.php',
+ ],
'doctrine/common' => [
'prefix' => 'FEDORA_SYMFONY3_PHP_DIR',
'path' => 'Doctrine/Common/autoload.php',
@@ -45,6 +54,10 @@ final class AutoloadGenerator {
'prefix' => 'FEDORA_SYMFONY3_PHP_DIR',
'path' => 'Doctrine/DBAL/autoload.php',
],
+ 'doctrine/doctrine-bundle' => [
+ 'prefix' => 'FEDORA_SYMFONY3_PHP_DIR',
+ 'path' => 'Doctrine/Bundle/DoctrineBundle/autoload.php',
+ ],
'doctrine/orm' => [
'prefix' => 'FEDORA_SYMFONY3_PHP_DIR',
'path' => 'Doctrine/ORM/autoload.php',
@@ -69,6 +82,7 @@ final class AutoloadGenerator {
'prefix' => 'FEDORA_SYMFONY3_PHP_DIR',
'path' => 'phpDocumentor/Reflection/DocBlock/autoload.php',
],
+ 'predis/predis' => false,
'psr/cache-implementation' => false,
'psr/cache' => [
'prefix' => 'FEDORA_SYMFONY3_PHP_DIR',
@@ -90,6 +104,7 @@ final class AutoloadGenerator {
'prefix' => 'FEDORA_SYMFONY3_PHP_DIR',
'path' => 'Psr/SimpleCache/autoload.php',
],
+ 'sensio/framework-extra-bundle' => false,
'symfony/asset' => [
'prefix' => 'FEDORA_SYMFONY3_DIR',
'path' => 'Component/Asset/autoload.php',
@@ -255,7 +270,7 @@ final class AutoloadGenerator {
],
'symfony/security-acl' => [
'prefix' => 'FEDORA_SYMFONY3_PHP_DIR',
- 'path' => 'Component/Security/Acl/autoload.php',
+ 'path' => 'Symfony/Component/Security/Acl/autoload.php',
],
'symfony/security-bundle' => [
'prefix' => 'FEDORA_SYMFONY3_DIR',
@@ -321,6 +336,10 @@ final class AutoloadGenerator {
'prefix' => 'FEDORA_SYMFONY3_DIR',
'path' => 'Bundle/WebProfilerBundle/autoload.php',
],
+ 'symfony/workflow' => [
+ 'prefix' => 'FEDORA_SYMFONY3_DIR',
+ 'path' => 'Component/Workflow/autoload.php',
+ ],
'symfony/yaml' => [
'prefix' => 'FEDORA_SYMFONY3_DIR',
'path' => 'Component/Yaml/autoload.php',
@@ -336,22 +355,39 @@ final class AutoloadGenerator {
private $filename = null;
+ private $devFilename = null;
+
public function __construct(SplFileInfo $composerFile) {
$composerJson = static::composerJson($composerFile);
+
+ // autoload.php
$content = static::content(
$composerJson,
- static::dependencyAutoloaders($composerJson, true),
- static::dependencyAutoloaders($composerJson, false)
+ static::dependencyAutoloaders($composerJson, 'require'),
+ static::dependencyAutoloaders($composerJson, 'suggest')
);
-
$this->filename = $composerFile->getPath() . '/autoload.php';
-
if (FALSE == file_put_contents($this->filename, $content)) {
throw new Exception(sprintf(
'Failed to generate autoload file "%s"',
$this->filename
));
}
+
+ // autoload-dev.php
+ $content = static::content(
+ $composerJson,
+ static::dependencyAutoloaders($composerJson, 'require-dev'),
+ [],
+ true
+ );
+ $this->devFilename = $composerFile->getPath() . '/autoload-dev.php';
+ if (FALSE == file_put_contents($this->devFilename, $content)) {
+ throw new Exception(sprintf(
+ 'Failed to generate autoload file "%s"',
+ $this->filename
+ ));
+ }
}
private static function composerJson(SplFileInfo $composerFile) {
@@ -370,9 +406,8 @@ final class AutoloadGenerator {
return $composerJson;
}
- private static function dependencyAutoloaders($composerJson, $required) {
+ private static function dependencyAutoloaders($composerJson, $composerKey) {
$dependencyAutoloaders = [];
- $composerKey = $required ? 'require' : 'suggest';
if (isset($composerJson[$composerKey])) {
$dependencies = array_keys(array_filter(
@@ -384,6 +419,15 @@ final class AutoloadGenerator {
));
foreach ($dependencies as $pkg) {
+ // Use Symfony cache component as PSR cache implementation
+ // for "require-dev" dependency.
+ if (
+ ('require-dev' == $composerKey)
+ && ('psr/cache-implementation' == $pkg)
+ ) {
+ $pkg = 'symfony/cache';
+ }
+
if ($autoloader = self::pkg2Autoload($pkg)) {
$dependencyAutoloaders[] = $autoloader;
}
@@ -413,7 +457,7 @@ final class AutoloadGenerator {
: sprintf("%s.'/%s'", $prefix, $path);
}
- public function content($composerJson, array $dependencyAutoloadersRequired, array $dependencyAutoloadersOptional) {
+ public function content($composerJson, array $dependencyAutoloadersRequired, array $dependencyAutoloadersOptional = [], $dev = false) {
$pkg = explode('/', $composerJson['name'])[1];
$content = <<<AUTOLOAD
@@ -426,15 +470,28 @@ final class AutoloadGenerator {
AUTOLOAD;
// This switch statement handles the "autoload-common" require for sub-sub-modules.
- switch ($pkg) {
- case 'security-core':
- case 'security-csrf':
- case 'security-guard':
- case 'security-http':
- $content .= "require_once dirname(dirname(dirname(__DIR__))).'/autoload-common.php';".PHP_EOL;
- break;
- default:
- $content .= "require_once dirname(dirname(__DIR__)).'/autoload-common.php';".PHP_EOL;
+ if (!$dev) {
+ switch ($pkg) {
+ case 'security-core':
+ case 'security-csrf':
+ case 'security-guard':
+ case 'security-http':
+ $content .= "require_once dirname(dirname(dirname(__DIR__))).'/autoload-common.php';".PHP_EOL;
+ break;
+ default:
+ $content .= "require_once dirname(dirname(__DIR__)).'/autoload-common.php';".PHP_EOL;
+ }
+ } else {
+ switch ($pkg) {
+ case 'security-core':
+ case 'security-csrf':
+ case 'security-guard':
+ case 'security-http':
+ $content .= "require_once dirname(__DIR__).'/autoload.php';".PHP_EOL;
+ break;
+ default:
+ $content .= "require_once __DIR__.'/autoload.php';".PHP_EOL;
+ }
}
if (!empty($dependencyAutoloadersRequired)) {
@@ -465,4 +522,8 @@ DEPENDENCY_AUTOLOADERS_REQUIRED;
public function getFilename() {
return $this->filename;
}
+
+ public function getDevFilename() {
+ return $this->devFilename;
+ }
}