Merge branch '2.1'
* 2.1: [DependencyInjection] fixed the creation of synthetic services in ContainerBuilder [Security] PHPDoc in SecurityEvents Fix typos in README Added an error message in the DebugClassLoader when using / instead of \. KNOWN_ISSUES with php 5.3.16 [FrameworkBundle] fixed Client::doRequest that must call its parent method (closes #6737) [Yaml] fixed ignored text when parsing an inlined mapping or sequence (closes #6786) [Yaml] fixed #6773 [Yaml] fixed #6770 bumped Symfony version to 2.1.8-DEV bumped Symfony version to 2.0.23-DEV Conflicts: src/Symfony/Bundle/FrameworkBundle/Client.php src/Symfony/Component/HttpKernel/Kernel.php
This commit is contained in:
commit
3196dbdf52
@ -27,6 +27,9 @@ work for you:
|
||||
* before PHP 5.3.8, if you get an error involving annotations, you've hit a
|
||||
known PHP bug (see https://bugs.php.net/bug.php?id=55156).
|
||||
|
||||
* PHP 5.3.16 has a major bug in the Reflection subsystem and is not suitable to
|
||||
run Symfony2 (https://bugs.php.net/bug.php?id=62715)
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
|
@ -108,7 +108,7 @@ class Client extends BaseClient
|
||||
$this->kernel->getContainer()->get('profiler')->enable();
|
||||
}
|
||||
|
||||
return $this->kernel->handle($request);
|
||||
return parent::doRequest($request);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -84,6 +84,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 "/".'));
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
|
@ -834,19 +834,22 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
||||
*
|
||||
* @throws RuntimeException When the scope is inactive
|
||||
* @throws RuntimeException When the factory definition is incomplete
|
||||
* @throws RuntimeException When the service is a synthetic service
|
||||
* @throws InvalidArgumentException When configure callable is not callable
|
||||
*/
|
||||
private function createService(Definition $definition, $id)
|
||||
{
|
||||
if ($definition->isSynthetic()) {
|
||||
throw new RuntimeException(sprintf('You have requested a synthetic service ("%s"). The DIC does not know how to construct this service.', $id));
|
||||
}
|
||||
|
||||
$parameterBag = $this->getParameterBag();
|
||||
|
||||
if (null !== $definition->getFile()) {
|
||||
require_once $parameterBag->resolveValue($definition->getFile());
|
||||
}
|
||||
|
||||
$arguments = $this->resolveServices(
|
||||
$parameterBag->unescapeValue($parameterBag->resolveValue($definition->getArguments()))
|
||||
);
|
||||
$arguments = $this->resolveServices($parameterBag->unescapeValue($parameterBag->resolveValue($definition->getArguments())));
|
||||
|
||||
if (null !== $definition->getFactoryMethod()) {
|
||||
if (null !== $definition->getFactoryClass()) {
|
||||
|
@ -316,6 +316,17 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\DependencyInjection\ContainerBuilder::createService
|
||||
* @expectedException \RuntimeException
|
||||
*/
|
||||
public function testCreateSyntheticService()
|
||||
{
|
||||
$builder = new ContainerBuilder();
|
||||
$builder->register('foo', 'FooClass')->setSynthetic(true);
|
||||
$builder->get('foo');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\DependencyInjection\ContainerBuilder::resolveServices
|
||||
*/
|
||||
|
@ -13,7 +13,25 @@ namespace Symfony\Component\Security\Http;
|
||||
|
||||
final class SecurityEvents
|
||||
{
|
||||
/**
|
||||
* The INTERACTIVE_LOGIN event occurs after a user is logged in
|
||||
* interactively for authentication based on http, cookies or X509.
|
||||
*
|
||||
* The event listener method receives a
|
||||
* Symfony\Component\Security\Http\Event\InteractiveLoginEvent instance.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const INTERACTIVE_LOGIN = 'security.interactive_login';
|
||||
|
||||
/**
|
||||
* The SWITCH_USER event occurs before switch to another user and
|
||||
* before exit from an already switched user.
|
||||
*
|
||||
* The event listener method receives a
|
||||
* Symfony\Component\Security\Http\Event\SwitchUserEvent instance.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const SWITCH_USER = 'security.switch_user';
|
||||
}
|
||||
|
@ -52,21 +52,23 @@ class Inline
|
||||
mb_internal_encoding('ASCII');
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
switch ($value[0]) {
|
||||
case '[':
|
||||
$result = self::parseSequence($value);
|
||||
$result = self::parseSequence($value, $i);
|
||||
++$i;
|
||||
break;
|
||||
case '{':
|
||||
$result = self::parseMapping($value);
|
||||
$result = self::parseMapping($value, $i);
|
||||
++$i;
|
||||
break;
|
||||
default:
|
||||
$i = 0;
|
||||
$result = self::parseScalar($value, null, array('"', "'"), $i);
|
||||
}
|
||||
|
||||
// some comment can end the scalar
|
||||
if (preg_replace('/\s+#.*$/A', '', substr($value, $i))) {
|
||||
throw new ParseException(sprintf('Unexpected characters near "%s".', substr($value, $i)));
|
||||
}
|
||||
// some comments are allowed at the end
|
||||
if (preg_replace('/\s+#.*$/A', '', substr($value, $i))) {
|
||||
throw new ParseException(sprintf('Unexpected characters near "%s".', substr($value, $i)));
|
||||
}
|
||||
|
||||
if (isset($mbEncoding)) {
|
||||
@ -413,6 +415,11 @@ class Inline
|
||||
$cast = intval($scalar);
|
||||
|
||||
return '0' == $scalar[0] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw);
|
||||
case '-' === $scalar[0] && ctype_digit(substr($scalar, 1)):
|
||||
$raw = $scalar;
|
||||
$cast = intval($scalar);
|
||||
|
||||
return '0' == $scalar[1] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw);
|
||||
case 'true' === strtolower($scalar):
|
||||
return true;
|
||||
case 'false' === strtolower($scalar):
|
||||
|
@ -190,8 +190,9 @@ class Parser
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 1-liner followed by newline
|
||||
if (2 == count($this->lines) && empty($this->lines[1])) {
|
||||
// 1-liner optionally followed by newline
|
||||
$lineCount = count($this->lines);
|
||||
if (1 === $lineCount || (2 === $lineCount && empty($this->lines[1]))) {
|
||||
try {
|
||||
$value = Inline::parse($this->lines[0], $exceptionOnInvalidType, $objectSupport);
|
||||
} catch (ParseException $e) {
|
||||
@ -548,10 +549,6 @@ class Parser
|
||||
{
|
||||
$value = str_replace(array("\r\n", "\r"), "\n", $value);
|
||||
|
||||
if (!preg_match("#\n$#", $value)) {
|
||||
$value .= "\n";
|
||||
}
|
||||
|
||||
// strip YAML header
|
||||
$count = 0;
|
||||
$value = preg_replace('#^\%YAML[: ][\d\.]+.*\n#su', '', $value, -1, $count);
|
||||
|
@ -19,7 +19,7 @@ class InlineTest extends \PHPUnit_Framework_TestCase
|
||||
public function testParse()
|
||||
{
|
||||
foreach ($this->getTestsForParse() as $yaml => $value) {
|
||||
$this->assertEquals($value, Inline::parse($yaml), sprintf('::parse() converts an inline YAML to a PHP structure (%s)', $yaml));
|
||||
$this->assertSame($value, Inline::parse($yaml), sprintf('::parse() converts an inline YAML to a PHP structure (%s)', $yaml));
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,6 +92,22 @@ class InlineTest extends \PHPUnit_Framework_TestCase
|
||||
Inline::parse($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
*/
|
||||
public function testParseInvalidMappingShouldThrowException()
|
||||
{
|
||||
Inline::parse('[foo] bar');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
*/
|
||||
public function testParseInvalidSequenceShouldThrowException()
|
||||
{
|
||||
Inline::parse('{ foo: bar } bar');
|
||||
}
|
||||
|
||||
public function testParseScalarWithCorrectlyQuotedStringShouldReturnString()
|
||||
{
|
||||
$value = "'don''t do somthin'' like that'";
|
||||
@ -108,6 +124,7 @@ class InlineTest extends \PHPUnit_Framework_TestCase
|
||||
'false' => false,
|
||||
'true' => true,
|
||||
'12' => 12,
|
||||
'-12' => -12,
|
||||
'"quoted string"' => 'quoted string',
|
||||
"'quoted string'" => 'quoted string',
|
||||
'12.30e+02' => 12.30e+02,
|
||||
@ -117,7 +134,7 @@ class InlineTest extends \PHPUnit_Framework_TestCase
|
||||
'-.Inf' => log(0),
|
||||
"'686e444'" => '686e444',
|
||||
'686e444' => 646e444,
|
||||
'123456789123456789' => '123456789123456789',
|
||||
'123456789123456789123456789123456789' => '123456789123456789123456789123456789',
|
||||
'"foo\r\nbar"' => "foo\r\nbar",
|
||||
"'foo#bar'" => 'foo#bar',
|
||||
"'foo # bar'" => 'foo # bar',
|
||||
|
@ -105,6 +105,201 @@ EOF;
|
||||
$this->assertEquals('foo', $this->parser->parse($yaml));
|
||||
}
|
||||
|
||||
public function getBlockChompingTests()
|
||||
{
|
||||
$tests = array();
|
||||
|
||||
$yaml = <<<'EOF'
|
||||
foo: |-
|
||||
one
|
||||
two
|
||||
|
||||
bar: |-
|
||||
one
|
||||
two
|
||||
|
||||
EOF;
|
||||
$expected = array(
|
||||
'foo' => "one\ntwo",
|
||||
'bar' => "one\ntwo",
|
||||
);
|
||||
$tests['Literal block chomping strip with trailing newline'] = array($expected, $yaml);
|
||||
|
||||
$yaml = <<<'EOF'
|
||||
foo: |-
|
||||
one
|
||||
two
|
||||
bar: |-
|
||||
one
|
||||
two
|
||||
EOF;
|
||||
$expected = array(
|
||||
'foo' => "one\ntwo",
|
||||
'bar' => "one\ntwo",
|
||||
);
|
||||
$tests['Literal block chomping strip without trailing newline'] = array($expected, $yaml);
|
||||
|
||||
$yaml = <<<'EOF'
|
||||
foo: |
|
||||
one
|
||||
two
|
||||
|
||||
bar: |
|
||||
one
|
||||
two
|
||||
|
||||
EOF;
|
||||
$expected = array(
|
||||
'foo' => "one\ntwo\n",
|
||||
'bar' => "one\ntwo\n",
|
||||
);
|
||||
$tests['Literal block chomping clip with trailing newline'] = array($expected, $yaml);
|
||||
|
||||
$yaml = <<<'EOF'
|
||||
foo: |
|
||||
one
|
||||
two
|
||||
bar: |
|
||||
one
|
||||
two
|
||||
EOF;
|
||||
$expected = array(
|
||||
'foo' => "one\ntwo\n",
|
||||
'bar' => "one\ntwo\n",
|
||||
);
|
||||
$tests['Literal block chomping clip without trailing newline'] = array($expected, $yaml);
|
||||
|
||||
$yaml = <<<'EOF'
|
||||
foo: |+
|
||||
one
|
||||
two
|
||||
|
||||
bar: |+
|
||||
one
|
||||
two
|
||||
|
||||
EOF;
|
||||
$expected = array(
|
||||
'foo' => "one\ntwo\n\n",
|
||||
'bar' => "one\ntwo\n\n",
|
||||
);
|
||||
$tests['Literal block chomping keep with trailing newline'] = array($expected, $yaml);
|
||||
|
||||
$yaml = <<<'EOF'
|
||||
foo: |+
|
||||
one
|
||||
two
|
||||
bar: |+
|
||||
one
|
||||
two
|
||||
EOF;
|
||||
$expected = array(
|
||||
'foo' => "one\ntwo\n",
|
||||
'bar' => "one\ntwo\n",
|
||||
);
|
||||
$tests['Literal block chomping keep without trailing newline'] = array($expected, $yaml);
|
||||
|
||||
$yaml = <<<'EOF'
|
||||
foo: >-
|
||||
one
|
||||
two
|
||||
|
||||
bar: >-
|
||||
one
|
||||
two
|
||||
|
||||
EOF;
|
||||
$expected = array(
|
||||
'foo' => "one two",
|
||||
'bar' => "one two",
|
||||
);
|
||||
$tests['Folded block chomping strip with trailing newline'] = array($expected, $yaml);
|
||||
|
||||
$yaml = <<<'EOF'
|
||||
foo: >-
|
||||
one
|
||||
two
|
||||
bar: >-
|
||||
one
|
||||
two
|
||||
EOF;
|
||||
$expected = array(
|
||||
'foo' => "one two",
|
||||
'bar' => "one two",
|
||||
);
|
||||
$tests['Folded block chomping strip without trailing newline'] = array($expected, $yaml);
|
||||
|
||||
$yaml = <<<'EOF'
|
||||
foo: >
|
||||
one
|
||||
two
|
||||
|
||||
bar: >
|
||||
one
|
||||
two
|
||||
|
||||
EOF;
|
||||
$expected = array(
|
||||
'foo' => "one two\n",
|
||||
'bar' => "one two\n",
|
||||
);
|
||||
$tests['Folded block chomping clip with trailing newline'] = array($expected, $yaml);
|
||||
|
||||
$yaml = <<<'EOF'
|
||||
foo: >
|
||||
one
|
||||
two
|
||||
bar: >
|
||||
one
|
||||
two
|
||||
EOF;
|
||||
$expected = array(
|
||||
'foo' => "one two\n",
|
||||
'bar' => "one two\n",
|
||||
);
|
||||
$tests['Folded block chomping clip without trailing newline'] = array($expected, $yaml);
|
||||
|
||||
$yaml = <<<'EOF'
|
||||
foo: >+
|
||||
one
|
||||
two
|
||||
|
||||
bar: >+
|
||||
one
|
||||
two
|
||||
|
||||
EOF;
|
||||
$expected = array(
|
||||
'foo' => "one two\n\n",
|
||||
'bar' => "one two\n\n",
|
||||
);
|
||||
$tests['Folded block chomping keep with trailing newline'] = array($expected, $yaml);
|
||||
|
||||
$yaml = <<<'EOF'
|
||||
foo: >+
|
||||
one
|
||||
two
|
||||
bar: >+
|
||||
one
|
||||
two
|
||||
EOF;
|
||||
$expected = array(
|
||||
'foo' => "one two\n",
|
||||
'bar' => "one two\n",
|
||||
);
|
||||
$tests['Folded block chomping keep without trailing newline'] = array($expected, $yaml);
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getBlockChompingTests
|
||||
*/
|
||||
public function testBlockChomping($expected, $yaml)
|
||||
{
|
||||
$this->assertSame($expected, $this->parser->parse($yaml));
|
||||
}
|
||||
|
||||
public function testObjectSupportEnabled()
|
||||
{
|
||||
$input = <<<EOF
|
||||
|
Reference in New Issue
Block a user