Skip to content

Commit c48af7c

Browse files
minor #26739 [FrameworkBundle] add PHP errors options to XML schema definition (xabbuh)
This PR was merged into the 3.4 branch. Discussion ---------- [FrameworkBundle] add PHP errors options to XML schema definition | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | Commits ------- 7d39bac add PHP errors options to XML schema definition
2 parents 10ba44c + 7d39bac commit c48af7c

File tree

8 files changed

+68
-0
lines changed

8 files changed

+68
-0
lines changed

src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
<xsd:element name="property-info" type="property_info" minOccurs="0" maxOccurs="1" />
3030
<xsd:element name="cache" type="cache" minOccurs="0" maxOccurs="1" />
3131
<xsd:element name="workflow" type="workflow" minOccurs="0" maxOccurs="unbounded" />
32+
<xsd:element name="php-errors" type="php-errors" minOccurs="0" maxOccurs="1" />
3233
<xsd:element name="lock" type="lock" minOccurs="0" maxOccurs="1" />
3334
</xsd:choice>
3435

@@ -273,6 +274,11 @@
273274
<xsd:attribute name="enabled" type="xsd:boolean" />
274275
</xsd:complexType>
275276

277+
<xsd:complexType name="php-errors">
278+
<xsd:attribute name="log" type="xsd:boolean" />
279+
<xsd:attribute name="throw" type="xsd:boolean" />
280+
</xsd:complexType>
281+
276282
<xsd:complexType name="marking_store">
277283
<xsd:sequence>
278284
<xsd:element name="argument" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
$container->loadFromExtension('framework', array(
4+
'php_errors' => array(
5+
'log' => false,
6+
'throw' => false,
7+
),
8+
));
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
$container->loadFromExtension('framework', array(
4+
'php_errors' => array(
5+
'log' => true,
6+
'throw' => true,
7+
),
8+
));
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" ?>
2+
<container xmlns="http://symfony.com/schema/dic/services"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:framework="http://symfony.com/schema/dic/symfony"
5+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
6+
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
7+
8+
<framework:config>
9+
<framework:php-errors log="false" throw="false" />
10+
</framework:config>
11+
</container>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" ?>
2+
<container xmlns="http://symfony.com/schema/dic/services"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:framework="http://symfony.com/schema/dic/symfony"
5+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
6+
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
7+
8+
<framework:config>
9+
<framework:php-errors log="true" throw="true" />
10+
</framework:config>
11+
</container>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
framework:
2+
php_errors:
3+
throw: false
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
framework:
2+
php_errors:
3+
log: true
4+
throw: true

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use Symfony\Component\DependencyInjection\ChildDefinition;
2828
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
2929
use Symfony\Component\DependencyInjection\ContainerBuilder;
30+
use Symfony\Component\DependencyInjection\ContainerInterface;
3031
use Symfony\Component\DependencyInjection\Definition;
3132
use Symfony\Component\DependencyInjection\Loader\ClosureLoader;
3233
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
@@ -319,6 +320,22 @@ public function testWorkflowServicesCanBeEnabled()
319320
$this->assertTrue($container->hasDefinition('console.command.workflow_dump'));
320321
}
321322

323+
public function testEnabledPhpErrorsConfig()
324+
{
325+
$container = $this->createContainerFromFile('php_errors_enabled');
326+
327+
$this->assertEquals(new Reference('logger', ContainerInterface::NULL_ON_INVALID_REFERENCE), $container->getDefinition('debug.debug_handlers_listener')->getArgument(1));
328+
$this->assertSame(-1, $container->getParameter('debug.error_handler.throw_at'));
329+
}
330+
331+
public function testDisabledPhpErrorsConfig()
332+
{
333+
$container = $this->createContainerFromFile('php_errors_disabled');
334+
335+
$this->assertNull($container->getDefinition('debug.debug_handlers_listener')->getArgument(1));
336+
$this->assertSame(0, $container->getParameter('debug.error_handler.throw_at'));
337+
}
338+
322339
public function testRouter()
323340
{
324341
$container = $this->createContainerFromFile('full');

0 commit comments

Comments
 (0)