8000 Merge branch '2.1' · symfony/symfony@3196dbd · GitHub
[go: up one dir, main page]

Skip to content

Commit 3196dbd

Browse files
committed
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
2 parents 7c957e3 + bdc7e91 commit 3196dbd

File tree

10 files changed

+274
-19
lines changed

10 files changed

+274
-19
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ work for you:
2727
* before PHP 5.3.8, if you get an error involving annotations, you've hit a
2828
known PHP bug (see https://bugs.php.net/bug.php?id=55156).
2929

30+
* PHP 5.3.16 has a major bug in the Reflection subsystem and is not suitable to
31+
run Symfony2 (https://bugs.php.net/bug.php?id=62715)
32+
3033
Installation
3134
------------
3235

src/Symfony/Bundle/FrameworkBundle/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ protected function doRequest($request)
108108
$this->kernel->getContainer()->get('profiler')->enable();
109109
}
110110

111-
return $this->kernel->handle($request);
111+
return parent::doRequest($request);
112112
}
113113

114114
/**

src/Symfony/Component/ClassLoader/DebugClassLoader.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ public function loadClass($class)
8484
require $file;
8585

8686
if (!class_exists($class, false) && !interface_exists($class, false) && (!function_exists('trait_exists') || !trait_exists($class, false))) {
87+
if (false !== strpos($class, '/')) {
88+
throw new \RuntimeException(sprintf('Trying to autoload a class with an invalid name "%s". Be careful that the namespace separator is "\" in PHP, not "/".'));
89+
}
90+
8791
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));
8892
}
8993

src/Symfony/Component/DependencyInjection/ContainerBuilder.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -834,19 +834,22 @@ public function findDefinition($id)
834834
*
835835
* @throws RuntimeException When the scope is inactive
836836
* @throws RuntimeException When the factory definition is incomplete
837+
* @throws RuntimeException When the service is a synthetic service
837838
* @throws InvalidArgumentException When configure callable is not callable
838839
*/
839840
private function createService(Definition $definition, $id)
840841
{
842+
if ($definition->isSynthetic()) {
843+
throw new RuntimeException(sprintf('You have requested a synthetic service ("%s"). The DIC does not know how to construct this service.', $id));
844+
}
845+
841846
$parameterBag = $this->getParameterBag();
842847

843848
if (null !== $definition->getFile()) {
844849
require_once $parameterBag->resolveValue($definition->getFile());
845850
}
846851

847-
$arguments = $this->resolveServices(
848-
$parameterBag->unescapeValue($parameterBag->resolveValue($definition->getArguments()))
849-
);
852+
$arguments = $this->resolveServices($parameterBag->unescapeValue($parameterBag->resolveValue($definition->getArguments())));
850853

851854
if (null !== $definition->getFactoryMethod()) {
852855
if (null !== $definition->getFactoryClass()) {

src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,17 @@ public function testCreateServiceConfigurator()
316316
}
317317
}
318318

319+
/**
320+
* @covers Symfony\Component\DependencyInjection\ContainerBuilder::createService
321+
* @expectedException \RuntimeException
322+
*/
323+
public function testCreateSyntheticService()
324+
{
325+
$builder = new ContainerBuilder();
326+
$builder->register('foo', 'FooClass')->setSynthetic(true);
327+
$builder->get('foo');
328+
}
329+
319330
/**
320331
* @covers Symfony\Component\DependencyInjection\ContainerBuilder::resolveServices
321332
*/

src/Symfony/Component/Security/Http/SecurityEvents.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,25 @@
1313

1414
final class SecurityEvents
1515
{
16+
/**
17+
* The INTERACTIVE_LOGIN event occurs after a user is logged in
18+
* interactively for authentication based on http, cookies or X509.
19+
*
20+
* The event listener method receives a
21+
* Symfony\Component\Security\Http\Event\InteractiveLoginEvent instance.
22+
*
23+
* @var string
24+
*/
1625
const INTERACTIVE_LOGIN = 'security.interactive_login';
1726

27+
/**
28+
* The SWITCH_USER event occurs before switch to another user and
29+
* before exit from an already switched user.
30+
*
31+
* The event listener method receives a
32+
* Symfony\Component\Security\Http\Event\SwitchUserEvent instance.
33+
*
34+
* @var string
35+
*/
1836
const SWITCH_USER = 'security.switch_user';
1937
}

src/Symfony/Component/Yaml/Inline.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,23 @@ public static function parse($value, $exceptionOnInvalidType = false, $objectSup
5252
mb_internal_encoding('ASCII');
5353
}
5454

55+
$i = 0;
5556
switch ($value[0]) {
5657
case '[':
57-
$result = self::parseSequence($value);
58+
$result = self::parseSequence($value, $i);
59+
++$i;
5860
break;
5961
case '{':
60-
$result = self::parseMapping($value);
62+
$result = self::parseMapping($value, $i);
63+
++$i;
6164
break;
6265
default:
63-
$i = 0;
6466
$result = self::parseScalar($value, null, array('"', "'"), $i);
67+
}
6568

66-
// some comment can end the scalar
67-
if (preg_replace('/\s+#.*$/A', '', substr($value, $i))) {
68-
throw new ParseException(sprintf('Unexpected characters near "%s".', substr($value, $i)));
69-
}
69+
// some comments are allowed at the end
70+
if (preg_replace('/\s+#.*$/A', '', substr($value, $i))) {
71+
throw new ParseException(sprintf('Unexpected characters near "%s".', substr($value, $i)));
7072
}
7173

7274
if (isset($mbEncoding)) {
@@ -413,6 +415,11 @@ private static function evaluateScalar($scalar)
413415
$cast = intval($scalar);
414416

415417
return '0' == $scalar[0] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw);
418+
case '-' === $scalar[0] && ctype_digit(substr($scalar, 1)):
419+
$raw = $scalar;
420+
$cast = intval($scalar);
421+
422+
return '0' == $scalar[1] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw);
416423
case 'true' === strtolower($scalar):
417424
return true;
418425
case 'false' === strtolower($scalar):

src/Symfony/Component/Yaml/Parser.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,9 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport =
190190
}
191191
}
192192
} else {
193-
// 1-liner followed by newline
194-
if (2 == count($this->lines) && empty($this->lines[1])) {
193+
// 1-liner optionally followed by newline
194+
$lineCount = count($this->lines);
195+
if (1 === $lineCount || (2 === $lineCount && empty($this->lines[1]))) {
195196
try {
196197
$value = Inline::parse($this->lines[0], $exceptionOnInvalidType, $objectSupport);
197198
} catch (ParseException $e) {
@@ -548,10 +549,6 @@ private function cleanup($value)
548549
{
549550
$value = str_replace(array("\r\n", "\r"), "\n", $value);
550551

551-
if (!preg_match("#\n$#", $value)) {
552-
$value .= "\n";
553-
}
554-
555552
// strip YAML header
556553
$count = 0;
557554
$value = preg_replace('#^\%YAML[: ][\d\.]+.*\n#su', '', $value, -1, $count);

src/Symfony/Component/Yaml/Tests/InlineTest.php

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class InlineTest extends \PHPUnit_Framework_TestCase
1919
public function testParse()
2020
{
2121
foreach ($this->getTestsForParse() as $yaml => $value) {
22-
$this->assertEquals($value, Inline::parse($yaml), sprintf('::parse() converts an inline YAML to a PHP structure (%s)', $yaml));
22+
$this->assertSame($value, Inline::parse($yaml), sprintf('::parse() converts an inline YAML to a PHP structure (%s)', $yaml));
2323
}
2424
}
2525

@@ -92,6 +92,22 @@ public function testParseInvalidMappingKeyShouldThrowException()
9292
Inline::parse($value);
9393
}
9494

95+
/**
96+
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
97+
*/
98+
public function testParseInvalidMappingShouldThrowException()
99+
{
100+
Inline::parse('[foo] bar');
101+
}
102+
103+
/**
104+
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
105+
*/
106+
public function testParseInvalidSequenceShouldThrowException()
107+
{
108+
Inline::parse('{ foo: bar } bar');
109+
}
110+
95111
public function testParseScalarWithCorrectlyQuotedStringShouldReturnString()
96112
{
97113
$value = "'don''t do somthin'' like that'";
@@ -108,6 +124,7 @@ protected function getTestsForParse()
108124
'false' => false,
109125
'true' => true,
110126
'12' => 12,
127+
'-12' => -12,
111128
'"quoted string"' => 'quoted string',
112129
"'quoted string'" => 'quoted string',
113130
'12.30e+02' => 12.30e+02,
@@ -117,7 +134,7 @@ protected function getTestsForParse()
117134
'-.Inf' => log(0),
118135
"'686e444'" => '686e444',
119136
'686e444' => 646e444,
120-
'123456789123456789' => '123456789123456789',
137+
'123456789123456789123456789123456789' => '123456789123456789123456789123456789',
121138
'"foo\r\nbar"' => "foo\r\nbar",
122139
"'foo#bar'" => 'foo#bar',
123140
"'foo # bar'" => 'foo # bar',

0 commit comments

Comments
 (0)
0