Compare commits

...

11 Commits

Author SHA1 Message Date
Xavier Amado 093e495498 Fixed missing class argument when throwing exception 2013-01-26 08:21:53 +01:00
Christophe Coevoet 3f23850c82 Added an error message in the DebugClassLoader when using / instead of \. 2013-01-19 08:47:26 +01:00
Fabien Potencier 585c3e06bf removed the .gitattributes files (closes #6605, reverts #5674) 2013-01-09 09:51:07 +01:00
Fabien Potencier 28fcb90894 Merge branch '2.0' into 2.1
* 2.0:
  updated license year
  Update src/Symfony/Component/HttpFoundation/Response.php
  [Console] fixed unitialized properties (closes #5935)
  [Bundle] [FrameworkBundle] fixed typo in phpdoc of the SessionListener.
  bumped Symfony version to 2.0.21-DEV
  updated VERSION for 2.0.21
  updated CHANGELOG for 2.0.21

Conflicts:
	src/Symfony/Bundle/SwiftmailerBundle/LICENSE
	src/Symfony/Component/Filesystem/LICENSE
	src/Symfony/Component/HttpFoundation/Response.php
	src/Symfony/Component/HttpKernel/Kernel.php
2013-01-04 18:00:54 +01:00
Fabien Potencier 3527a2b300 updated license year 2013-01-04 17:59:43 +01:00
Martin Hasoň 097c9cadb8 Removed useless branch alias for dev-master in composer.json 2012-12-06 11:00:55 +01:00
Włodzimierz Gajda 29e26e8a3d Fix export-ignore on Windows 2012-11-08 10:51:48 +01:00
Fabien Potencier d095c397b0 Merge branch '2.0' into 2.1
* 2.0:
  [ClassLoader] fixed unbracketed namespaces (closes #5747)

Conflicts:
	src/Symfony/Component/ClassLoader/ClassCollectionLoader.php
	tests/Symfony/Tests/Component/ClassLoader/ClassCollectionLoaderTest.php
2012-10-27 17:59:21 +02:00
Fabien Potencier c393e86a03 [ClassLoader] fixed unbracketed namespaces (closes #5747) 2012-10-27 17:55:46 +02:00
Igor Wiedler 1de4a18fa9 [2.1] Exclude tests from zips via gitattributes 2012-10-04 17:17:57 +02:00
Fabien Potencier 475b92bd71 fixed CS (mainly method signatures) 2012-07-09 14:43:50 +02:00
5 changed files with 45 additions and 52 deletions
+14 -1
View File
@@ -20,6 +20,7 @@ class ClassCollectionLoader
{
private static $loaded;
private static $seen;
private static $useTokenizer = true;
/**
* Loads a list of classes and caches them in one big file.
@@ -135,7 +136,11 @@ class ClassCollectionLoader
*/
public static function fixNamespaceDeclarations($source)
{
if (!function_exists('token_get_all')) {
if (!function_exists('token_get_all') || !self::$useTokenizer) {
if (preg_match('/namespace(.*?)\s*;/', $source)) {
$source = preg_replace('/namespace(.*?)\s*;/', "namespace$1\n{", $source)."}\n";
}
return $source;
}
@@ -317,4 +322,12 @@ class ClassCollectionLoader
return $classes;
}
/**
* This method is only useful for testing.
*/
public static function enableTokenizer($bool)
{
self::$useTokenizer = (Boolean) $bool;
}
}
+4
View File
@@ -82,6 +82,10 @@ class DebugClassLoader
require $file;
if (!class_exists($class, false) && !interface_exists($class, false) && (!function_exists('trait_exists') || !trait_exists($class, false))) {
if (false !== strpos($class, '/')) {
throw new \RuntimeException(sprintf('Trying to autoload a class with an invalid name "%s". Be careful that the namespace separator is "\" in PHP, not "/".', $class));
}
throw new \RuntimeException(sprintf('The autoloader expected class "%s" to be defined in file "%s". The file was found but the class was not in it, the class name or namespace probably has a typo.', $class, $file));
}
+1 -1
View File
@@ -1,4 +1,4 @@
Copyright (c) 2004-2012 Fabien Potencier
Copyright (c) 2004-2013 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
+25 -44
View File
@@ -117,53 +117,34 @@ class ClassCollectionLoaderTest extends \PHPUnit_Framework_TestCase
);
}
public function testFixNamespaceDeclarations()
/**
* @dataProvider getFixNamespaceDeclarationsData
*/
public function testFixNamespaceDeclarations($source, $expected)
{
$source = <<<EOF
<?php
$this->assertEquals('<?php '.$expected, ClassCollectionLoader::fixNamespaceDeclarations('<?php '.$source));
}
namespace Foo;
class Foo {}
namespace Bar ;
class Foo {}
namespace Foo\Bar;
class Foo {}
namespace Foo\Bar\Bar
{
class Foo {}
}
namespace
{
class Foo {}
}
EOF;
/**
* @dataProvider getFixNamespaceDeclarationsData
*/
public function testFixNamespaceDeclarationsWithoutTokenizer($source, $expected)
{
ClassCollectionLoader::enableTokenizer(false);
$this->assertEquals('<?php '.$expected, ClassCollectionLoader::fixNamespaceDeclarations('<?php '.$source));
ClassCollectionLoader::enableTokenizer(true);
}
$expected = <<<EOF
<?php
namespace Foo
{
class Foo {}
}
namespace Bar
{
class Foo {}
}
namespace Foo\Bar
{
class Foo {}
}
namespace Foo\Bar\Bar
{
class Foo {}
}
namespace
{
class Foo {}
}
EOF;
$this->assertEquals($expected, ClassCollectionLoader::fixNamespaceDeclarations($source));
public function getFixNamespaceDeclarationsData()
{
return array(
array("namespace;\nclass Foo {}\n", "namespace\n{\nclass Foo {}\n}\n"),
array("namespace Foo;\nclass Foo {}\n", "namespace Foo\n{\nclass Foo {}\n}\n"),
array("namespace Bar ;\nclass Foo {}\n", "namespace Bar\n{\nclass Foo {}\n}\n"),
array("namespace Foo\Bar;\nclass Foo {}\n", "namespace Foo\Bar\n{\nclass Foo {}\n}\n"),
array("namespace Foo\Bar\Bar\n{\nclass Foo {}\n}\n", "namespace Foo\Bar\Bar\n{\nclass Foo {}\n}\n"),
array("namespace\n{\nclass Foo {}\n}\n", "namespace\n{\nclass Foo {}\n}\n"),
);
}
/**
+1 -6
View File
@@ -26,10 +26,5 @@
"psr-0": { "Symfony\\Component\\ClassLoader": "" }
},
"target-dir": "Symfony/Component/ClassLoader",
"minimum-stability": "dev",
"extra": {
"branch-alias": {
"dev-master": "2.1-dev"
}
}
"minimum-stability": "dev"
}