Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fc50ad9

Browse filesBrowse files
Merge branch '2.8' into 3.0
* 2.8: use stable 1.0.x Composer versions Fix typo in VarDumper README [DI] Fix AutowirePass fatal error with classes that have non-existing parents [DependencyInjection] Tests for AutowirePass with missing parent class [WebProfilerBunde] Give an absolute url in case the request occured from another domain
2 parents ffb7573 + 38bbb57 commit fc50ad9
Copy full SHA for fc50ad9

File tree

Expand file treeCollapse file tree

8 files changed

+82
-14
lines changed
Filter options
Expand file treeCollapse file tree

8 files changed

+82
-14
lines changed

‎.travis.yml

Copy file name to clipboardExpand all lines: .travis.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ before_install:
4949
- if [[ ! $skip && $PHP = 5.* ]]; then pecl install -f memcached-2.1.0; fi
5050
- if [[ ! $skip && $PHP != hhvm ]]; then echo extension = ldap.so >> $INI_FILE; fi
5151
- if [[ ! $skip && $PHP != hhvm ]]; then phpenv config-rm xdebug.ini; fi
52-
- if [[ ! $skip ]]; then composer self-update; fi
52+
- if [[ ! $skip ]]; then composer self-update --stable; fi
5353
- if [[ ! $skip ]]; then cp .composer/* ~/.composer/; composer global install; fi
5454
- if [[ ! $skip ]]; then ./phpunit install; fi
5555
- if [[ ! $skip && $deps ]]; then composer global remove hirak/prestissimo; fi

‎appveyor.yml

Copy file name to clipboardExpand all lines: appveyor.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ install:
4646
- IF %PHP%==1 echo extension=php_ldap.dll >> php.ini-max
4747
- IF %PHP%==1 echo extension=php_curl.dll >> php.ini-max
4848
- IF %PHP%==1 echo curl.cainfo=c:\php\cacert.pem >> php.ini-max
49-
- appveyor DownloadFile https://getcomposer.org/composer.phar
49+
- IF %PHP%==1 appveyor DownloadFile https://getcomposer.org/download/1.0.2/composer.phar
5050
- copy /Y php.ini-max php.ini
5151
- cd c:\projects\symfony
5252
- mkdir %APPDATA%\Composer

‎src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function onKernelResponse(FilterResponseEvent $event)
6565
try {
6666
$response->headers->set(
6767
'X-Debug-Token-Link',
68-
$this->urlGenerator->generate('_profiler', array('token' => $response->headers->get('X-Debug-Token')))
68+
$this->urlGenerator->generate('_profiler', array('token' => $response->headers->get('X-Debug-Token')), UrlGeneratorInterface::ABSOLUTE_URL)
6969
);
7070
} catch (\Exception $e) {
7171
$response->headers->set('X-Debug-Error', get_class($e).': '.$e->getMessage());

‎src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\HttpFoundation\Response;
1717
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
1818
use Symfony\Component\HttpKernel\HttpKernelInterface;
19+
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
1920

2021
class WebDebugToolbarListenerTest extends \PHPUnit_Framework_TestCase
2122
{
@@ -195,16 +196,16 @@ public function testXDebugUrlHeader()
195196
$urlGenerator
196197
->expects($this->once())
197198
->method('generate')
198-
->with('_profiler', array('token' => 'xxxxxxxx'))
199-
->will($this->returnValue('/_profiler/xxxxxxxx'))
199+
->with('_profiler', array('token' => 'xxxxxxxx'), UrlGeneratorInterface::ABSOLUTE_URL)
200+
->will($this->returnValue('http://mydomain.com/_profiler/xxxxxxxx'))
200201
;
201202

202203
$event = new FilterResponseEvent($this->getKernelMock(), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response);
203204

204205
$listener = new WebDebugToolbarListener($this->getTwigMock(), false, WebDebugToolbarListener::ENABLED, 'bottom', $urlGenerator);
205206
$listener->onKernelResponse($event);
206207

207-
$this->assertEquals('/_profiler/xxxxxxxx', $response->headers->get('X-Debug-Token-Link'));
208+
$this->assertEquals('http://mydomain.com/_profiler/xxxxxxxx', $response->headers->get('X-Debug-Token-Link'));
208209
}
209210

210211
public function testThrowingUrlGenerator()

‎src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php
+20-7Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,32 @@ class AutowirePass implements CompilerPassInterface
3434
*/
3535
public function process(ContainerBuilder $container)
3636
{
37-
$this->container = $container;
38-
foreach ($container->getDefinitions() as $id => $definition) {
39-
if ($definition->isAutowired()) {
40-
$this->completeDefinition($id, $definition);
37+
$throwingAutoloader = function ($class) { throw new \ReflectionException(sprintf('Class %s does not exist', $class)); };
38+
spl_autoload_register($throwingAutoloader);
39+
40+
try {
41+
$this->container = $container;
42+
foreach ($container->getDefinitions() as $id => $definition) {
43+
if ($definition->isAutowired()) {
44+
$this->completeDefinition($id, $definition);
45+
}
4146
}
47+
} catch (\Error $e) {
48+
} catch (\Exception $e) {
4249
}
4350

51+
spl_autoload_unregister($throwingAutoloader);
52+
4453
// Free memory and remove circular reference to container
4554
$this->container = null;
4655
$this->reflectionClasses = array();
4756
$this->definedTypes = array();
4857
$this->types = null;
4958
$this->notGuessableTypes = array();
59+
60+
if (isset($e)) {
61+
throw $e;
62+
}
5063
}
5164

5265
/**
@@ -107,11 +120,11 @@ private function completeDefinition($id, Definition $definition)
107120
}
108121
}
109122
}
110-
} catch (\ReflectionException $reflectionException) {
123+
} catch (\ReflectionException $e) {
111124
// Typehint against a non-existing class
112125

113126
if (!$parameter->isDefaultValueAvailable()) {
114-
throw new RuntimeException(sprintf('Cannot autowire argument %s for %s because the type-hinted class does not exist (%s).', $index + 1, $definition->getClass(), $reflectionException->getMessage()), 0, $reflectionException);
127+
throw new RuntimeException(sprintf('Cannot autowire argument %s for %s because the type-hinted class does not exist (%s).', $index + 1, $definition->getClass(), $e->getMessage()), 0, $e);
115128
}
116129

117130
$value = $parameter->getDefaultValue();
@@ -245,7 +258,7 @@ private function getReflectionClass($id, Definition $definition)
245258

246259
try {
247260
$reflector = new \ReflectionClass($class);
248-
} catch (\ReflectionException $reflectionException) {
261+
} catch (\ReflectionException $e) {
249262
$reflector = false;
250263
}
251264

‎src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php
+36Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,21 @@ public function testClassNotFoundThrowsException()
268268
$pass->process($container);
269269
}
270270

271+
/**
272+
* @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
273+
* @expectedExceptionMessage Cannot autowire argument 2 for Symfony\Component\DependencyInjection\Tests\Compiler\BadParentTypeHintedArgument because the type-hinted class does not exist (Class Symfony\Component\DependencyInjection\Tests\Compiler\OptionalServiceClass does not exist).
274+
*/
275+
public function testParentClassNotFoundThrowsException()
276+
{
277+
$container = new ContainerBuilder();
278+
279+
$aDefinition = $container->register('a', __NAMESPACE__.'\BadParentTypeHintedArgument');
280+
$aDefinition->setAutowired(true);
281+
282+
$pass = new AutowirePass();
283+
$pass->process($container);
284+
}
285+
271286
public function testDontUseAbstractServices()
272287
{
273288
$container = new ContainerBuilder();
@@ -397,6 +412,21 @@ public function testOptionalScalarArgsNotPassedIfLast()
397412
$definition->getArguments()
398413
);
399414
}
415+
416+
public function testIgnoreServiceWithClassNotExisting()
417+
{
418+
$container = new ContainerBuilder();
419+
420+
$container->register('class_not_exist', __NAMESPACE__.'\OptionalServiceClass');
421+
422+
$barDefinition = $container->register('bar', __NAMESPACE__.'\Bar');
423+
$barDefinition->setAutowired(true);
424+
425+
$pass = new AutowirePass();
426+
$pass->process($container);
427+
428+
$this->assertTrue($container->hasDefinition('bar'));
429+
}
400430
}
401431

402432
class Foo
@@ -509,6 +539,12 @@ public function __construct(Dunglas $k, NotARealClass $r)
509539
{
510540
}
511541
}
542+
class BadParentTypeHintedArgument
543+
{
544+
public function __construct(Dunglas $k, OptionalServiceClass $r)
545+
{
546+
}
547+
}
512548
class NotGuessableArgument
513549
{
514550
public function __construct(Foo $k)
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\DependencyInjection\Tests\Compiler;
13+
14+
use Symfony\Bug\NotExistClass;
15+
16+
class OptionalServiceClass extends NotExistClass
17+
{
18+
}

‎src/Symfony/Component/VarDumper/README.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/README.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ VarDumper Component
22
===================
33

44
The VarDumper component provides mechanisms for walking through any arbitrary
5-
PHP variable. Built on top, it provides a better `dump()`` function that you
5+
PHP variable. Built on top, it provides a better `dump()` function that you
66
can use instead of `var_dump`.
77

88
Resources

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.