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

Skip to content

Commit e00f037

Browse files
committed
minor #14323 Use PSR-4 everywhere instead of PSR-0 (Tobion, Seldaek)
This PR was merged into the 2.7 branch. Discussion ---------- Use PSR-4 everywhere instead of PSR-0 | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #11189 | License | MIT Rebased and updated #12466 Commits ------- 8072213 adjust phpdoc for class not found handler e2bbf07 add phpunit bridge to psr4 60d4994 Tweak classmap paths cc17234 Add two more components to psr-4 17f61af Add psr-4 support to the ClassNotFoundFatalErrorHandler 4e85901 Use PSR-4 everywhere instead of PSR-0
2 parents 3761140 + 8072213 commit e00f037

File tree

47 files changed

+84
-102
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+84
-102
lines changed

composer.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,14 @@
7979
"egulias/email-validator": "~1.2"
8080
},
8181
"autoload": {
82-
"psr-0": {
83-
"Symfony\\Bridge\\Doctrine\\": "src/",
84-
"Symfony\\Bridge\\Monolog\\": "src/",
85-
"Symfony\\Bridge\\ProxyManager\\": "src/",
86-
"Symfony\\Bridge\\Swiftmailer\\": "src/",
87-
"Symfony\\Bridge\\Twig\\": "src/",
88-
"Symfony\\Bundle\\": "src/",
89-
"Symfony\\Component\\": "src/"
82+
"psr-4": {
83+
"Symfony\\Bridge\\Doctrine\\": "src/Symfony/Bridge/Doctrine/",
84+
"Symfony\\Bridge\\Monolog\\": "src/Symfony/Bridge/Monolog/",
85+
"Symfony\\Bridge\\ProxyManager\\": "src/Symfony/Bridge/ProxyManager/",
86+
"Symfony\\Bridge\\Swiftmailer\\": "src/Symfony/Bridge/Swiftmailer/",
87+
"Symfony\\Bridge\\Twig\\": "src/Symfony/Bridge/Twig/",
88+
"Symfony\\Bundle\\": "src/Symfony/Bundle/",
89+
"Symfony\\Component\\": "src/Symfony/Component/"
9090
},
9191
"classmap": [
9292
"src/Symfony/Component/HttpFoundation/Resources/stubs",

src/Symfony/Bridge/Doctrine/composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@
4242
"doctrine/orm": ""
4343
},
4444
"autoload": {
45-
"psr-0": { "Symfony\\Bridge\\Doctrine\\": "" }
45+
"psr-4": { "Symfony\\Bridge\\Doctrine\\": "" }
4646
},
47-
"target-dir": "Symfony/Bridge/Doctrine",
4847
"minimum-stability": "dev",
4948
"extra": {
5049
"branch-alias": {

src/Symfony/Bridge/Monolog/composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@
3131
"symfony/event-dispatcher": "Needed when using log messages in console commands."
3232
},
3333
"autoload": {
34-
"psr-0": { "Symfony\\Bridge\\Monolog\\": "" }
34+
"psr-4": { "Symfony\\Bridge\\Monolog\\": "" }
3535
},
36-
"target-dir": "Symfony/Bridge/Monolog",
3736
"minimum-stability": "dev",
3837
"extra": {
3938
"branch-alias": {

src/Symfony/Bridge/PhpUnit/composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@
2323
},
2424
"autoload": {
2525
"files": [ "bootstrap.php" ],
26-
"psr-0": { "Symfony\\Bridge\\PhpUnit\\": "" }
26+
"psr-4": { "Symfony\\Bridge\\PhpUnit\\": "" }
2727
},
28-
"target-dir": "Symfony/Bridge/PhpUnit",
2928
"minimum-stability": "dev",
3029
"extra": {
3130
"branch-alias": {

src/Symfony/Bridge/ProxyManager/composer.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,8 @@
2525
"symfony/config": "~2.3"
2626
},
2727
"autoload": {
28-
"psr-0": {
29-
"Symfony\\Bridge\\ProxyManager\\": ""
30-
}
28+
"psr-4": { "Symfony\\Bridge\\ProxyManager\\": "" }
3129
},
32-
"target-dir": "Symfony/Bridge/ProxyManager",
3330
"minimum-stability": "dev",
3431
"extra": {
3532
"branch-alias": {

src/Symfony/Bridge/Swiftmailer/composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@
2626
"symfony/http-kernel": ""
2727
},
2828
"autoload": {
29-
"psr-0": { "Symfony\\Bridge\\Swiftmailer\\": "" }
29+
"psr-4": { "Symfony\\Bridge\\Swiftmailer\\": "" }
3030
},
31-
"target-dir": "Symfony/Bridge/Swiftmailer",
3231
"minimum-stability": "dev",
3332
"extra": {
3433
"branch-alias": {

src/Symfony/Bridge/Twig/composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,8 @@
5151
"symfony/expression-language": "For using the ExpressionExtension"
5252
},
5353
"autoload": {
54-
"psr-0": { "Symfony\\Bridge\\Twig\\": "" }
54+
"psr-4": { "Symfony\\Bridge\\Twig\\": "" }
5555
},
56-
"target-dir": "Symfony/Bridge/Twig",
5756
"minimum-stability": "dev",
5857
"extra": {
5958
"branch-alias": {

src/Symfony/Bundle/DebugBundle/composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@
3131
"symfony/dependency-injection": "For using as a service from the container"
3232
},
3333
"autoload": {
34-
"psr-0": { "Symfony\\Bundle\\DebugBundle\\": "" }
34+
"psr-4": { "Symfony\\Bundle\\DebugBundle\\": "" }
3535
},
36-
"target-dir": "Symfony/Bundle/DebugBundle",
3736
"minimum-stability": "dev",
3837
"extra": {
3938
"branch-alias": {

src/Symfony/Bundle/FrameworkBundle/composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,8 @@
5757
"doctrine/cache": "For using alternative cache drivers"
5858
},
5959
"autoload": {
60-
"psr-0": { "Symfony\\Bundle\\FrameworkBundle\\": "" }
60+
"psr-4": { "Symfony\\Bundle\\FrameworkBundle\\": "" }
6161
},
62-
"target-dir": "Symfony/Bundle/FrameworkBundle",
6362
"minimum-stability": "dev",
6463
"extra": {
6564
"branch-alias": {

src/Symfony/Bundle/SecurityBundle/composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@
4141
"ircmaxell/password-compat": "~1.0"
4242
},
4343
"autoload": {
44-
"psr-0": { "Symfony\\Bundle\\SecurityBundle\\": "" }
44+
"psr-4": { "Symfony\\Bundle\\SecurityBundle\\": "" }
4545
},
46-
"target-dir": "Symfony/Bundle/SecurityBundle",
4746
"minimum-stability": "dev",
4847
"extra": {
4948
"branch-alias": {

src/Symfony/Bundle/TwigBundle/composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@
3333
"symfony/framework-bundle": "~2.7"
3434
},
3535
"autoload": {
36-
"psr-0": { "Symfony\\Bundle\\TwigBundle\\": "" }
36+
"psr-4": { "Symfony\\Bundle\\TwigBundle\\": "" }
3737
},
38-
"target-dir": "Symfony/Bundle/TwigBundle",
3938
"minimum-stability": "dev",
4039
"extra": {
4140
"branch-alias": {

src/Symfony/Bundle/WebProfilerBundle/composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,8 @@
2929
"symfony/stopwatch": "~2.2"
3030
},
3131
"autoload": {
32-
"psr-0": { "Symfony\\Bundle\\WebProfilerBundle\\": "" }
32+
"psr-4": { "Symfony\\Bundle\\WebProfilerBundle\\": "" }
3333
},
34-
"target-dir": "Symfony/Bundle/WebProfilerBundle",
3534
"minimum-stability": "dev",
3635
"extra": {
3736
"branch-alias": {

src/Symfony/Component/BrowserKit/composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@
2828
"symfony/process": ""
2929
},
3030
"autoload": {
31-
"psr-0": { "Symfony\\Component\\BrowserKit\\": "" }
31+
"psr-4": { "Symfony\\Component\\BrowserKit\\": "" }
3232
},
33-
"target-dir": "Symfony/Component/BrowserKit",
3433
"minimum-stability": "dev",
3534
"extra": {
3635
"branch-alias": {

src/Symfony/Component/ClassLoader/composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@
2424
"symfony/finder": "~2.0,>=2.0.5"
2525
},
2626
"autoload": {
27-
"psr-0": { "Symfony\\Component\\ClassLoader\\": "" }
27+
"psr-4": { "Symfony\\Component\\ClassLoader\\": "" }
2828
},
29-
"target-dir": "Symfony/Component/ClassLoader",
3029
"extra": {
3130
"branch-alias": {
3231
"dev-master": "2.7-dev"

src/Symfony/Component/Config/composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@
2323
"symfony/phpunit-bridge": "~2.7"
2424
},
2525
"autoload": {
26-
"psr-0": { "Symfony\\Component\\Config\\": "" }
26+
"psr-4": { "Symfony\\Component\\Config\\": "" }
2727
},
28-
"target-dir": "Symfony/Component/Config",
2928
"minimum-stability": "dev",
3029
"extra": {
3130
"branch-alias": {

src/Symfony/Component/Console/composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@
3030
"psr/log": "For using the console logger"
3131
},
3232
"autoload": {
33-
"psr-0": { "Symfony\\Component\\Console\\": "" }
33+
"psr-4": { "Symfony\\Component\\Console\\": "" }
3434
},
35-
"target-dir": "Symfony/Component/Console",
3635
"minimum-stability": "dev",
3736
"extra": {
3837
"branch-alias": {

src/Symfony/Component/CssSelector/composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@
2626
"symfony/phpunit-bridge": "~2.7"
2727
},
2828
"autoload": {
29-
"psr-0": { "Symfony\\Component\\CssSelector\\": "" }
29+
"psr-4": { "Symfony\\Component\\CssSelector\\": "" }
3030
},
31-
"target-dir": "Symfony/Component/CssSelector",
3231
"minimum-stability": "dev",
3332
"extra": {
3433
"branch-alias": {

src/Symfony/Component/Debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function handleError(array $error, FatalErrorException $exception)
7777
/**
7878
* Tries to guess the full namespace for a given class name.
7979
*
80-
* By default, it looks for PSR-0 classes registered via a Symfony or a Composer
80+
* By default, it looks for PSR-0 and PSR-4 classes registered via a Symfony or a Composer
8181
* autoloader (that should cover all common cases).
8282
*
8383
* @param string $class A class name (without its namespace)
@@ -118,6 +118,13 @@ private function getClassCandidates($class)
118118
}
119119
}
120120
}
121+
if ($function[0] instanceof ComposerClassLoader) {
122+
foreach ($function[0]->getPrefixesPsr4() as $prefix => $paths) {
123+
foreach ($paths as $path) {
124+
$classes = array_merge($classes, $this->findClassInPath($path, $class, $prefix));
125+
}
126+
}
127+
}
121128
}
122129

123130
return array_unique($classes);

src/Symfony/Component/Debug/Tests/FatalErrorHandler/ClassNotFoundFatalErrorHandlerTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,30 @@
1515
use Symfony\Component\ClassLoader\UniversalClassLoader as SymfonyUniversalClassLoader;
1616
use Symfony\Component\Debug\Exception\FatalErrorException;
1717
use Symfony\Component\Debug\FatalErrorHandler\ClassNotFoundFatalErrorHandler;
18+
use Symfony\Component\Debug\DebugClassLoader;
19+
use Composer\Autoload\ClassLoader as ComposerClassLoader;
1820

1921
class ClassNotFoundFatalErrorHandlerTest extends \PHPUnit_Framework_TestCase
2022
{
23+
public static function setUpBeforeClass()
24+
{
25+
foreach (spl_autoload_functions() as $function) {
26+
if (!is_array($function)) {
27+
continue;
28+
}
29+
30+
// get class loaders wrapped by DebugClassLoader
31+
if ($function[0] instanceof DebugClassLoader) {
32+
$function = $function[0]->getClassLoader();
33+
}
34+
35+
if ($function[0] instanceof ComposerClassLoader) {
36+
$function[0]->add('Symfony\Component\Debug\Tests\Fixtures', dirname(dirname(dirname(dirname(dirname(__DIR__))))));
37+
break;
38+
}
39+
}
40+
}
41+
2142
/**
2243
* @dataProvider provideClassNotFoundData
2344
*/

src/Symfony/Component/Debug/composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@
3333
"symfony/http-kernel": ""
3434
},
3535
"autoload": {
36-
"psr-0": { "Symfony\\Component\\Debug\\": "" }
36+
"psr-4": { "Symfony\\Component\\Debug\\": "" }
3737
},
38-
"target-dir": "Symfony/Component/Debug",
3938
"minimum-stability": "dev",
4039
"extra": {
4140
"branch-alias": {

src/Symfony/Component/DependencyInjection/composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@
3333
"symfony/proxy-manager-bridge": "Generate service proxies to lazy load them"
3434
},
3535
"autoload": {
36-
"psr-0": { "Symfony\\Component\\DependencyInjection\\": "" }
36+
"psr-4": { "Symfony\\Component\\DependencyInjection\\": "" }
3737
},
38-
"target-dir": "Symfony/Component/DependencyInjection",
3938
"minimum-stability": "dev",
4039
"extra": {
4140
"branch-alias": {

src/Symfony/Component/DomCrawler/composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@
2626
"symfony/css-selector": ""
2727
},
2828
"autoload": {
29-
"psr-0": { "Symfony\\Component\\DomCrawler\\": "" }
29+
"psr-4": { "Symfony\\Component\\DomCrawler\\": "" }
3030
},
31-
"target-dir": "Symfony/Component/DomCrawler",
3231
"minimum-stability": "dev",
3332
"extra": {
3433
"branch-alias": {

src/Symfony/Component/EventDispatcher/composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@
3131
"symfony/http-kernel": ""
3232
},
3333
"autoload": {
34-
"psr-0": { "Symfony\\Component\\EventDispatcher\\": "" }
34+
"psr-4": { "Symfony\\Component\\EventDispatcher\\": "" }
3535
},
36-
"target-dir": "Symfony/Component/EventDispatcher",
3736
"minimum-stability": "dev",
3837
"extra": {
3938
"branch-alias": {

src/Symfony/Component/ExpressionLanguage/composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@
2222
"symfony/phpunit-bridge": "~2.7"
2323
},
2424
"autoload": {
25-
"psr-0": { "Symfony\\Component\\ExpressionLanguage\\": "" }
25+
"psr-4": { "Symfony\\Component\\ExpressionLanguage\\": "" }
2626
},
27-
"target-dir": "Symfony/Component/ExpressionLanguage",
2827
"minimum-stability": "dev",
2928
"extra": {
3029
"branch-alias": {

src/Symfony/Component/Filesystem/composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@
2222
"symfony/phpunit-bridge": "~2.7"
2323
},
2424
"autoload": {
25-
"psr-0": { "Symfony\\Component\\Filesystem\\": "" }
25+
"psr-4": { "Symfony\\Component\\Filesystem\\": "" }
2626
},
27-
"target-dir": "Symfony/Component/Filesystem",
2827
"minimum-stability": "dev",
2928
"extra": {
3029
"branch-alias": {

src/Symfony/Component/Finder/composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@
2222
"symfony/phpunit-bridge": "~2.7"
2323
},
2424
"autoload": {
25-
"psr-0": { "Symfony\\Component\\Finder\\": "" }
25+
"psr-4": { "Symfony\\Component\\Finder\\": "" }
2626
},
27-
"target-dir": "Symfony/Component/Finder",
2827
"minimum-stability": "dev",
2928
"extra": {
3029
"branch-alias": {

src/Symfony/Component/Form/composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,8 @@
4343
"symfony/framework-bundle": "For templating with PHP."
4444
},
4545
"autoload": {
46-
"psr-0": { "Symfony\\Component\\Form\\": "" }
46+
"psr-4": { "Symfony\\Component\\Form\\": "" }
4747
},
48-
"target-dir": "Symfony/Component/Form",
4948
"minimum-stability": "dev",
5049
"extra": {
5150
"branch-alias": {

src/Symfony/Component/HttpFoundation/composer.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@
2323
"symfony/expression-language": "~2.4"
2424
},
2525
"autoload": {
26-
"psr-0": { "Symfony\\Component\\HttpFoundation\\": "" },
27-
"classmap": [ "Symfony/Component/HttpFoundation/Resources/stubs" ]
26+
"psr-4": { "Symfony\\Component\\HttpFoundation\\": "" },
27+
"classmap": [ "Resources/stubs" ]
2828
},
29-
"target-dir": "Symfony/Component/HttpFoundation",
3029
"minimum-stability": "dev",
3130
"extra": {
3231
"branch-alias": {

src/Symfony/Component/HttpKernel/composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,8 @@
5353
"symfony/var-dumper": ""
5454
},
5555
"autoload": {
56-
"psr-0": { "Symfony\\Component\\HttpKernel\\": "" }
56+
"psr-4": { "Symfony\\Component\\HttpKernel\\": "" }
5757
},
58-
"target-dir": "Symfony/Component/HttpKernel",
5958
"minimum-stability": "dev",
6059
"extra": {
6160
"branch-alias": {

src/Symfony/Component/Intl/composer.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,10 @@
3434
"ext-intl": "to use the component with locales other than \"en\""
3535
},
3636
"autoload": {
37-
"psr-0": { "Symfony\\Component\\Intl\\": "" },
38-
"classmap": [ "Symfony/Component/Intl/Resources/stubs" ],
39-
"files": [ "Symfony/Component/Intl/Resources/stubs/functions.php" ]
37+
"psr-4": { "Symfony\\Component\\Intl\\": "" },
38+
"classmap": [ "Resources/stubs" ],
39+
"files": [ "Resources/stubs/functions.php" ]
4040
},
41-
"target-dir": "Symfony/Component/Intl",
4241
"minimum-stability": "dev",
4342
"extra": {
4443
"branch-alias": {

src/Symfony/Component/Locale/composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@
2323
"symfony/phpunit-bridge": "~2.7"
2424
},
2525
"autoload": {
26-
"psr-0": { "Symfony\\Component\\Locale\\": "" }
26+
"psr-4": { "Symfony\\Component\\Locale\\": "" }
2727
},
28-
"target-dir": "Symfony/Component/Locale",
2928
"minimum-stability": "dev",
3029
"extra": {
3130
"branch-alias": {

0 commit comments

Comments
 (0)