Skip to content

Commit e12386a

Browse files
Merge branch '2.8' into 3.2
* 2.8: move provider after test update dataProvider function name cast substr result to string and remove empty function use rename dataset provider Add a test to prevent future regressions Switch to `empty` native function to check emptiness remove non relevant test case Switch to `is_string` native method Remove unnecessary parentheses Add a test case to prevent future regressions Move empty condition in return statement Use LF line separator fix coding standard to comply with fabbot Remove malformed EmailValidatorTest + Update UrlValidator test Add empty check on host in other methods + add unit tests [Validator] Allow checkMX() to return false when $host is empty [DI] Prevent AutowirePass from triggering irrelevant deprecations [DI] Fix the xml schema [Translation] avoid creating cache files for fallback locales.
2 parents 694c1a6 + 4ffd028 commit e12386a

File tree

4 files changed

+56
-9
lines changed

4 files changed

+56
-9
lines changed

Compiler/AutowirePass.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,9 +325,28 @@ private function getReflectionClass($id, Definition $definition)
325325

326326
$class = $this->container->getParameterBag()->resolveValue($class);
327327

328+
if ($deprecated = $definition->isDeprecated()) {
329+
$prevErrorHandler = set_error_handler(function ($level, $message, $file, $line) use (&$prevErrorHandler) {
330+
return (E_USER_DEPRECATED === $level || !$prevErrorHandler) ? false : $prevErrorHandler($level, $message, $file, $line);
331+
});
332+
}
333+
334+
$e = null;
335+
328336
try {
329337
$reflector = new \ReflectionClass($class);
330-
} catch (\ReflectionException $e) {
338+
} catch (\Exception $e) {
339+
} catch (\Throwable $e) {
340+
}
341+
342+
if ($deprecated) {
343+
restore_error_handler();
344+
}
345+
346+
if (null !== $e) {
347+
if (!$e instanceof \ReflectionException) {
348+
throw $e;
349+
}
331350
$reflector = false;
332351
}
333352

Loader/schema/dic/services/services-1.0.xsd

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@
140140
</xsd:complexType>
141141

142142
<xsd:complexType name="property" mixed="true">
143-
<xsd:choice minOccurs="0" maxOccurs="1">
144-
<xsd:element name="property" type="property" minOccurs="0" maxOccurs="unbounded" />
143+
<xsd:choice minOccurs="0">
144+
<xsd:element name="property" type="property" maxOccurs="unbounded" />
145145
<xsd:element name="service" type="service" />
146146
</xsd:choice>
147147
<xsd:attribute name="type" type="argument_type" />
@@ -153,8 +153,8 @@
153153
</xsd:complexType>
154154

155155
<xsd:complexType name="argument" mixed="true">
156-
<xsd:choice maxOccurs="unbounded">
157-
<xsd:element name="argument" type="argument" minOccurs="0" maxOccurs="unbounded" />
156+
<xsd:choice minOccurs="0">
157+
<xsd:element name="argument" type="argument" maxOccurs="unbounded" />
158158
<xsd:element name="service" type="service" />
159159
</xsd:choice>
160160
<xsd:attribute name="type" type="argument_type" />
@@ -165,10 +165,9 @@
165165
<xsd:attribute name="strict" type="boolean" />
166166
</xsd:complexType>
167167

168-
<xsd:complexType name="call" mixed="true">
169-
<xsd:choice maxOccurs="unbounded">
170-
<xsd:element name="argument" type="argument" minOccurs="0" maxOccurs="unbounded" />
171-
<xsd:element name="service" type="service" />
168+
<xsd:complexType name="call">
169+
<xsd:choice minOccurs="0">
170+
<xsd:element name="argument" type="argument" maxOccurs="unbounded" />
172171
</xsd:choice>
173172
<xsd:attribute name="method" type="xsd:string" />
174173
</xsd:complexType>

Tests/Compiler/AutowirePassTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,17 @@ public function testIgnoreServiceWithClassNotExisting()
493493
$this->assertTrue($container->hasDefinition('bar'));
494494
}
495495

496+
public function testProcessDoesNotTriggerDeprecations()
497+
{
498+
$container = new ContainerBuilder();
499+
$container->register('deprecated', 'Symfony\Component\DependencyInjection\Tests\Fixtures\DeprecatedClass')->setDeprecated(true);
500+
$container->register('foo', __NAMESPACE__.'\Foo');
501+
$container->register('bar', __NAMESPACE__.'\Bar')->setAutowired(true);
502+
503+
$pass = new AutowirePass();
504+
$pass->process($container);
505+
}
506+
496507
public function testEmptyStringIsKept()
497508
{
498509
$container = new ContainerBuilder();

Tests/Fixtures/DeprecatedClass.php

Lines 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 <[email protected]>
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\Fixtures;
13+
14+
@trigger_error('deprecated', E_USER_DEPRECATED);
15+
16+
class DeprecatedClass
17+
{
18+
}

0 commit comments

Comments
 (0)