diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php
index fd2a1356a5..42d88b030d 100644
--- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php
+++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php
@@ -12,7 +12,7 @@
namespace Symfony\Bridge\PhpUnit;
/**
- * Catch deprecation notices and print a summary report at the end of the test suite
+ * Catch deprecation notices and print a summary report at the end of the test suite.
*
* @author Nicolas Grekas
*/
@@ -26,9 +26,11 @@ class DeprecationErrorHandler
return;
}
$deprecations = array(
+ 'unsilencedCount' => 0,
'remainingCount' => 0,
'legacyCount' => 0,
'otherCount' => 0,
+ 'unsilenced' => array(),
'remaining' => array(),
'legacy' => array(),
'other' => array(),
@@ -45,21 +47,25 @@ class DeprecationErrorHandler
// No-op
}
- if (isset($trace[$i]['object']) || isset($trace[$i]['class'])) {
+ if (0 !== error_reporting()) {
+ $group = 'unsilenced';
+ $ref = &$deprecations[$group][$msg]['count'];
+ ++$ref;
+ } elseif (isset($trace[$i]['object']) || isset($trace[$i]['class'])) {
$class = isset($trace[$i]['object']) ? get_class($trace[$i]['object']) : $trace[$i]['class'];
$method = $trace[$i]['function'];
$group = 0 === strpos($method, 'testLegacy') || 0 === strpos($method, 'provideLegacy') || 0 === strpos($method, 'getLegacy') || strpos($class, '\Legacy') || in_array('legacy', \PHPUnit_Util_Test::getGroups($class, $method), true) ? 'legacy' : 'remaining';
if ('legacy' !== $group && 'weak' !== $mode) {
- $ref =& $deprecations[$group][$msg]['count'];
+ $ref = &$deprecations[$group][$msg]['count'];
++$ref;
- $ref =& $deprecations[$group][$msg][$class.'::'.$method];
+ $ref = &$deprecations[$group][$msg][$class.'::'.$method];
++$ref;
}
} else {
$group = 'other';
- $ref =& $deprecations[$group][$msg]['count'];
+ $ref = &$deprecations[$group][$msg]['count'];
++$ref;
}
++$deprecations[$group.'Count'];
@@ -95,7 +101,7 @@ class DeprecationErrorHandler
return $b['count'] - $a['count'];
};
- foreach (array('remaining', 'legacy', 'other') as $group) {
+ foreach (array('unsilenced', 'remaining', 'legacy', 'other') as $group) {
if ($deprecations[$group.'Count']) {
echo "\n", $colorize(sprintf('%s deprecation notices (%d)', ucfirst($group), $deprecations[$group.'Count']), 'legacy' !== $group), "\n";
@@ -117,7 +123,7 @@ class DeprecationErrorHandler
if (!empty($notices)) {
echo "\n";
}
- if ('weak' !== $mode && ($deprecations['remaining'] || $deprecations['other'])) {
+ if ('weak' !== $mode && ($deprecations['unsilenced'] || $deprecations['remaining'] || $deprecations['other'])) {
exit(1);
}
});
diff --git a/src/Symfony/Bridge/PhpUnit/README.md b/src/Symfony/Bridge/PhpUnit/README.md
index 7d84a3138d..734df8baa0 100644
--- a/src/Symfony/Bridge/PhpUnit/README.md
+++ b/src/Symfony/Bridge/PhpUnit/README.md
@@ -9,7 +9,8 @@ It comes with the following features:
* auto-register `class_exists` to load Doctrine annotations;
* print a user deprecation notices summary at the end of the test suite.
-By default any non-legacy-tagged deprecation notice will make tests fail.
+By default any non-legacy-tagged or any non-@-silenced deprecation notices will
+make tests fail.
This can be changed by setting the SYMFONY_DEPRECATIONS_HELPER environment
variable to `weak`. This will make the bridge ignore deprecation notices and
is useful to projects that must use deprecated interfaces for backward
@@ -17,6 +18,8 @@ compatibility reasons.
A summary of deprecation notices is displayed at the end of the test suite:
+ * **Unsilenced** reports deprecation notices that were triggered without the
+ recommended @-silencing operator;
* **Legacy** deprecation notices denote tests that explicitly test some legacy
interfaces. There are four ways to mark a test as legacy:
- make its class start with the `Legacy` prefix;
@@ -35,6 +38,12 @@ Add this bridge to the `require-dev` section of your composer.json file
When running `phpunit`, you will see a summary of deprecation notices at the end
of the test suite.
+Deprecation notices in the **Unsilenced** section should just be @-silenced:
+`@trigger_error('...', E_USER_DEPRECATED);`. Without the @-silencing operator,
+users would need to opt-out from deprecation notices. Silencing by default swaps
+this behavior and allows users to opt-in when they are ready to cope with them
+(by adding a custom error handler like the one provided by this bridge.)
+
Deprecation notices in the **Remaining/Other** section need some thought.
You have to decide either to:
diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/form.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/form.xml
index cabe13dcf2..8672b640da 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/form.xml
+++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/form.xml
@@ -46,8 +46,10 @@
+
+
-
+
diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/serializer.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/serializer.xml
index 66e21d50fd..735dfdaf93 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/serializer.xml
+++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/serializer.xml
@@ -14,9 +14,13 @@
+
+
+ null
+
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/LegacyFragmentRendererPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/LegacyFragmentRendererPassTest.php
index a801b91f43..97c98d5d8f 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/LegacyFragmentRendererPassTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/LegacyFragmentRendererPassTest.php
@@ -20,11 +20,6 @@ use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\FragmentRenderer
*/
class LegacyFragmentRendererPassTest extends \PHPUnit_Framework_TestCase
{
- protected function setUp()
- {
- $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
- }
-
/**
* Tests that content rendering not implementing FragmentRendererInterface
* trigger an exception.
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
index ef3272249c..81f3a6c0ee 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
@@ -312,8 +312,6 @@ abstract class FrameworkExtensionTest extends TestCase
*/
public function testLegacyFullyConfiguredValidationService()
{
- $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
-
if (!extension_loaded('apc')) {
$this->markTestSkipped('The apc extension is not available.');
}
@@ -415,8 +413,6 @@ abstract class FrameworkExtensionTest extends TestCase
*/
public function testLegacyFormCsrfFieldNameCanBeSetUnderCsrfSettings()
{
- $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
-
$container = $this->createContainerFromFile('form_csrf_sets_field_name');
$this->assertTrue($container->getParameter('form.type_extension.csrf.enabled'));
@@ -428,8 +424,6 @@ abstract class FrameworkExtensionTest extends TestCase
*/
public function testLegacyFormCsrfFieldNameUnderFormSettingsTakesPrecedence()
{
- $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
-
$container = $this->createContainerFromFile('form_csrf_under_form_sets_field_name');
$this->assertTrue($container->getParameter('form.type_extension.csrf.enabled'));
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fragment/LegacyContainerAwareHIncludeFragmentRendererTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Fragment/LegacyContainerAwareHIncludeFragmentRendererTest.php
index e6fa0c4cee..2fe31ec0b9 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fragment/LegacyContainerAwareHIncludeFragmentRendererTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fragment/LegacyContainerAwareHIncludeFragmentRendererTest.php
@@ -22,8 +22,6 @@ class LegacyContainerAwareHIncludeFragmentRendererTest extends TestCase
{
public function testRender()
{
- $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
-
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
$container->expects($this->once())
->method('get')
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php
index 89882951d7..48a7737dd8 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php
@@ -31,8 +31,6 @@ class GlobalVariablesTest extends TestCase
*/
public function testLegacyGetSecurity()
{
- $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
-
$securityContext = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
$this->assertNull($this->globals->getSecurity());
diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php
index a588230455..72a41bc122 100644
--- a/src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php
+++ b/src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php
@@ -45,8 +45,6 @@ class SecurityDataCollectorTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyCollectWhenAuthenticationTokenIsNull()
{
- $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
-
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
$collector = new SecurityDataCollector($tokenStorage, $this->getRoleHierarchy());
$collector->collect($this->getRequest(), $this->getResponse());
diff --git a/src/Symfony/Component/Console/Tests/ApplicationTest.php b/src/Symfony/Component/Console/Tests/ApplicationTest.php
index 5c7ca8acad..b049d0e4a0 100644
--- a/src/Symfony/Component/Console/Tests/ApplicationTest.php
+++ b/src/Symfony/Component/Console/Tests/ApplicationTest.php
@@ -651,7 +651,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
}
/**
- * Issue #9285
+ * Issue #9285.
*
* If the "verbose" option is just before an argument in ArgvInput,
* an argument value should not be treated as verbosity value.
diff --git a/src/Symfony/Component/Console/Tests/Input/InputDefinitionTest.php b/src/Symfony/Component/Console/Tests/Input/InputDefinitionTest.php
index b36b9f3530..2b28014d87 100644
--- a/src/Symfony/Component/Console/Tests/Input/InputDefinitionTest.php
+++ b/src/Symfony/Component/Console/Tests/Input/InputDefinitionTest.php
@@ -376,7 +376,7 @@ class InputDefinitionTest extends \PHPUnit_Framework_TestCase
array(new InputDefinition(array(new InputOption('foo'), new InputArgument('foo', InputArgument::REQUIRED))), '[--foo] [--] ', 'puts [--] between options and arguments'),
);
}
-
+
public function testGetShortSynopsis()
{
$definition = new InputDefinition(array(new InputOption('foo'), new InputOption('bar'), new InputArgument('cat')));
diff --git a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php
index 3b2349395a..651e18badb 100644
--- a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php
+++ b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php
@@ -169,8 +169,6 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
public function testHandleError()
{
- $this->iniSet('error_reporting', -1);
-
try {
$handler = ErrorHandler::register();
$handler->throwAt(0, true);
diff --git a/src/Symfony/Component/Form/Extension/Core/Type/FormType.php b/src/Symfony/Component/Form/Extension/Core/Type/FormType.php
index 69e634e6ae..9d5be03bf6 100644
--- a/src/Symfony/Component/Form/Extension/Core/Type/FormType.php
+++ b/src/Symfony/Component/Form/Extension/Core/Type/FormType.php
@@ -195,7 +195,7 @@ class FormType extends BaseType
$readOnlyNormalizer = function (Options $options, $readOnly) {
if (null !== $readOnly) {
- trigger_error('The form option "read_only" is deprecated since version 2.8 and will be removed in 3.0. Use "attr[\'readonly\']" instead.', E_USER_DEPRECATED);
+ @trigger_error('The form option "read_only" is deprecated since version 2.8 and will be removed in 3.0. Use "attr[\'readonly\']" instead.', E_USER_DEPRECATED);
return $readOnly;
}
diff --git a/src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/LegacySessionCsrfProviderTest.php b/src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/LegacySessionCsrfProviderTest.php
index eb4f58c8b6..8618de1804 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/LegacySessionCsrfProviderTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/LegacySessionCsrfProviderTest.php
@@ -23,8 +23,6 @@ class LegacySessionCsrfProviderTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
-
$this->session = $this->getMock(
'Symfony\Component\HttpFoundation\Session\Session',
array(),
diff --git a/src/Symfony/Component/Security/Core/Tests/LegacySecurityContextTest.php b/src/Symfony/Component/Security/Core/Tests/LegacySecurityContextTest.php
index f1f7861e98..c5da22d315 100644
--- a/src/Symfony/Component/Security/Core/Tests/LegacySecurityContextTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/LegacySecurityContextTest.php
@@ -26,8 +26,6 @@ class LegacySecurityContextTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
-
$this->tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
$this->authorizationChecker = $this->getMock('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface');
$this->securityContext = new SecurityContext($this->tokenStorage, $this->authorizationChecker);
diff --git a/src/Symfony/Component/Security/Tests/Core/LegacySecurityContextInterfaceTest.php b/src/Symfony/Component/Security/Tests/Core/LegacySecurityContextInterfaceTest.php
index 3fad2b15aa..57517bf7f4 100644
--- a/src/Symfony/Component/Security/Tests/Core/LegacySecurityContextInterfaceTest.php
+++ b/src/Symfony/Component/Security/Tests/Core/LegacySecurityContextInterfaceTest.php
@@ -24,8 +24,6 @@ class LegacySecurityContextInterfaceTest extends \PHPUnit_Framework_TestCase
*/
public function testConstantSync()
{
- $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
-
$this->assertSame(Security::ACCESS_DENIED_ERROR, SecurityContextInterface::ACCESS_DENIED_ERROR);
$this->assertSame(Security::AUTHENTICATION_ERROR, SecurityContextInterface::AUTHENTICATION_ERROR);
$this->assertSame(Security::LAST_USERNAME, SecurityContextInterface::LAST_USERNAME);
diff --git a/src/Symfony/Component/Translation/Translator.php b/src/Symfony/Component/Translation/Translator.php
index e4c09f413e..3692733f3c 100644
--- a/src/Symfony/Component/Translation/Translator.php
+++ b/src/Symfony/Component/Translation/Translator.php
@@ -276,7 +276,7 @@ class Translator implements TranslatorInterface, TranslatorBagInterface
*/
public function getMessages($locale = null)
{
- trigger_error('The '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0. Use TranslatorBagInterface::getCatalogue() method instead.', E_USER_DEPRECATED);
+ @trigger_error('The '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0. Use TranslatorBagInterface::getCatalogue() method instead.', E_USER_DEPRECATED);
$catalogue = $this->getCatalogue($locale);
$messages = $catalogue->all();
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/AbstractConstraintValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/AbstractConstraintValidatorTest.php
index 20de505b58..2204fedcd7 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/AbstractConstraintValidatorTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/AbstractConstraintValidatorTest.php
@@ -51,10 +51,6 @@ abstract class AbstractConstraintValidatorTest extends \PHPUnit_Framework_TestCa
protected function setUp()
{
- if (Validation::API_VERSION_2_5 !== $this->getApiVersion()) {
- $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
- }
-
$this->group = 'MyGroup';
$this->metadata = null;
$this->object = null;
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CallbackValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CallbackValidatorTest.php
index b53f6c6995..b619291665 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/CallbackValidatorTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/CallbackValidatorTest.php
@@ -191,8 +191,6 @@ class CallbackValidatorTest extends AbstractConstraintValidatorTest
*/
public function testLegacySingleMethodBc()
{
- $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
-
$object = new CallbackValidatorTest_Object();
$constraint = new Callback(array('validate'));
@@ -209,8 +207,6 @@ class CallbackValidatorTest extends AbstractConstraintValidatorTest
*/
public function testLegacySingleMethodBcExplicitName()
{
- $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
-
$object = new CallbackValidatorTest_Object();
$constraint = new Callback(array('methods' => array('validate')));
@@ -227,8 +223,6 @@ class CallbackValidatorTest extends AbstractConstraintValidatorTest
*/
public function testLegacyMultipleMethodsBc()
{
- $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
-
$object = new CallbackValidatorTest_Object();
$constraint = new Callback(array('validate', 'validateStatic'));
@@ -247,8 +241,6 @@ class CallbackValidatorTest extends AbstractConstraintValidatorTest
*/
public function testLegacyMultipleMethodsBcExplicitName()
{
- $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
-
$object = new CallbackValidatorTest_Object();
$constraint = new Callback(array(
'methods' => array('validate', 'validateStatic'),
@@ -269,8 +261,6 @@ class CallbackValidatorTest extends AbstractConstraintValidatorTest
*/
public function testLegacySingleStaticMethodBc()
{
- $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
-
$object = new CallbackValidatorTest_Object();
$constraint = new Callback(array(
array(__CLASS__.'_Class', 'validateCallback'),
@@ -289,8 +279,6 @@ class CallbackValidatorTest extends AbstractConstraintValidatorTest
*/
public function testLegacySingleStaticMethodBcExplicitName()
{
- $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
-
$object = new CallbackValidatorTest_Object();
$constraint = new Callback(array(
'methods' => array(array(__CLASS__.'_Class', 'validateCallback')),
@@ -329,8 +317,6 @@ class CallbackValidatorTest extends AbstractConstraintValidatorTest
*/
public function testLegacyExpectEitherCallbackOrMethods()
{
- $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
-
$object = new CallbackValidatorTest_Object();
$this->validator->validate($object, new Callback(array(
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/GroupSequenceTest.php b/src/Symfony/Component/Validator/Tests/Constraints/GroupSequenceTest.php
index 30f0245372..aa2d601042 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/GroupSequenceTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/GroupSequenceTest.php
@@ -37,8 +37,6 @@ class GroupSequenceTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyIterate()
{
- $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
-
$sequence = new GroupSequence(array('Group 1', 'Group 2'));
$this->assertSame(array('Group 1', 'Group 2'), iterator_to_array($sequence));
@@ -49,8 +47,6 @@ class GroupSequenceTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyCount()
{
- $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
-
$sequence = new GroupSequence(array('Group 1', 'Group 2'));
$this->assertCount(2, $sequence);
@@ -61,8 +57,6 @@ class GroupSequenceTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyArrayAccess()
{
- $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
-
$sequence = new GroupSequence(array('Group 1', 'Group 2'));
$this->assertSame('Group 1', $sequence[0]);
@@ -85,8 +79,6 @@ class GroupSequenceTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyGetExpectsExistingKey()
{
- $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
-
$sequence = new GroupSequence(array('Group 1', 'Group 2'));
$sequence[2];
@@ -97,8 +89,6 @@ class GroupSequenceTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyUnsetIgnoresNonExistingKeys()
{
- $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
-
$sequence = new GroupSequence(array('Group 1', 'Group 2'));
// should not fail
diff --git a/src/Symfony/Component/Validator/Tests/LegacyExecutionContextTest.php b/src/Symfony/Component/Validator/Tests/LegacyExecutionContextTest.php
index 4fec2aacb5..f0139c0da5 100644
--- a/src/Symfony/Component/Validator/Tests/LegacyExecutionContextTest.php
+++ b/src/Symfony/Component/Validator/Tests/LegacyExecutionContextTest.php
@@ -41,8 +41,6 @@ class LegacyExecutionContextTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
-
$this->visitor = $this->getMockBuilder('Symfony\Component\Validator\ValidationVisitor')
->disableOriginalConstructor()
->getMock();
diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Cache/LegacyApcCacheTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Cache/LegacyApcCacheTest.php
index bb69cf5e74..9d39784280 100644
--- a/src/Symfony/Component/Validator/Tests/Mapping/Cache/LegacyApcCacheTest.php
+++ b/src/Symfony/Component/Validator/Tests/Mapping/Cache/LegacyApcCacheTest.php
@@ -20,8 +20,6 @@ class LegacyApcCacheTest extends \PHPUnit_Framework_TestCase
{
protected function setUp()
{
- $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
-
if (!extension_loaded('apc') || !ini_get('apc.enable_cli')) {
$this->markTestSkipped('APC is not loaded.');
}
diff --git a/src/Symfony/Component/Validator/Tests/Mapping/LegacyElementMetadataTest.php b/src/Symfony/Component/Validator/Tests/Mapping/LegacyElementMetadataTest.php
index c77e6fe9aa..b68c88293f 100644
--- a/src/Symfony/Component/Validator/Tests/Mapping/LegacyElementMetadataTest.php
+++ b/src/Symfony/Component/Validator/Tests/Mapping/LegacyElementMetadataTest.php
@@ -24,8 +24,6 @@ class LegacyElementMetadataTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
-
$this->metadata = new TestElementMetadata();
}
diff --git a/src/Symfony/Component/Validator/Tests/Mapping/MemberMetadataTest.php b/src/Symfony/Component/Validator/Tests/Mapping/MemberMetadataTest.php
index a4473bc68a..fafde341ac 100644
--- a/src/Symfony/Component/Validator/Tests/Mapping/MemberMetadataTest.php
+++ b/src/Symfony/Component/Validator/Tests/Mapping/MemberMetadataTest.php
@@ -40,8 +40,6 @@ class MemberMetadataTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyAddValidSetsMemberToCascaded()
{
- $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
-
$result = $this->metadata->addConstraint(new Valid());
$this->assertEquals(array(), $this->metadata->getConstraints());
@@ -54,8 +52,6 @@ class MemberMetadataTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyAddOtherConstraintDoesNotSetMemberToCascaded()
{
- $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
-
$result = $this->metadata->addConstraint($constraint = new ConstraintA());
$this->assertEquals(array($constraint), $this->metadata->getConstraints());
diff --git a/src/Symfony/Component/Validator/Tests/Validator/Abstract2Dot5ApiTest.php b/src/Symfony/Component/Validator/Tests/Validator/Abstract2Dot5ApiTest.php
index be1f6bed6e..2451a25a6b 100644
--- a/src/Symfony/Component/Validator/Tests/Validator/Abstract2Dot5ApiTest.php
+++ b/src/Symfony/Component/Validator/Tests/Validator/Abstract2Dot5ApiTest.php
@@ -570,8 +570,6 @@ abstract class Abstract2Dot5ApiTest extends AbstractValidatorTest
*/
public function testLegacyPropertyMetadataMustImplementPropertyMetadataInterface()
{
- $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
-
$entity = new Entity();
// Legacy interface
diff --git a/src/Symfony/Component/Validator/Tests/Validator/AbstractLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Validator/AbstractLegacyApiTest.php
index bc2de2b5dc..a3bbf3307f 100644
--- a/src/Symfony/Component/Validator/Tests/Validator/AbstractLegacyApiTest.php
+++ b/src/Symfony/Component/Validator/Tests/Validator/AbstractLegacyApiTest.php
@@ -42,8 +42,6 @@ abstract class AbstractLegacyApiTest extends AbstractValidatorTest
protected function setUp()
{
- $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
-
parent::setUp();
$this->validator = $this->createValidator($this->metadataFactory);
diff --git a/src/Symfony/Component/Validator/Tests/Validator/AbstractValidatorTest.php b/src/Symfony/Component/Validator/Tests/Validator/AbstractValidatorTest.php
index 1369fe3470..3694c9317a 100644
--- a/src/Symfony/Component/Validator/Tests/Validator/AbstractValidatorTest.php
+++ b/src/Symfony/Component/Validator/Tests/Validator/AbstractValidatorTest.php
@@ -827,8 +827,6 @@ abstract class AbstractValidatorTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyValidatePropertyFailsIfPropertiesNotSupported()
{
- $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
-
// $metadata does not implement PropertyMetadataContainerInterface
$metadata = $this->getMock('Symfony\Component\Validator\MetadataInterface');
@@ -957,8 +955,6 @@ abstract class AbstractValidatorTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyValidatePropertyValueFailsIfPropertiesNotSupported()
{
- $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
-
// $metadata does not implement PropertyMetadataContainerInterface
$metadata = $this->getMock('Symfony\Component\Validator\MetadataInterface');
diff --git a/src/Symfony/Component/VarDumper/Dumper/CliDumper.php b/src/Symfony/Component/VarDumper/Dumper/CliDumper.php
index ece7b38abd..1fcad90c87 100644
--- a/src/Symfony/Component/VarDumper/Dumper/CliDumper.php
+++ b/src/Symfony/Component/VarDumper/Dumper/CliDumper.php
@@ -31,7 +31,6 @@ class CliDumper extends AbstractDumper
'num' => '1;38;5;38',
'const' => '1;38;5;208',
'str' => '1;38;5;113',
- 'cchr' => '7',
'note' => '38;5;38',
'ref' => '38;5;247',
'public' => '',
@@ -42,7 +41,15 @@ class CliDumper extends AbstractDumper
'index' => '38;5;38',
);
- protected static $controlCharsRx = '/[\x00-\x1F\x7F]/';
+ protected static $controlCharsRx = '/[\x00-\x1F\x7F]+/';
+ protected static $controlCharsMap = array(
+ "\t" => '\t',
+ "\n" => '\n',
+ "\v" => '\v',
+ "\f" => '\f',
+ "\r" => '\r',
+ "\033" => '\e',
+ );
/**
* {@inheritdoc}
@@ -146,7 +153,7 @@ class CliDumper extends AbstractDumper
$this->line .= $this->style($style, $value, $attr);
- $this->dumpLine($cursor->depth);
+ $this->dumpLine($cursor->depth, true);
}
/**
@@ -161,13 +168,17 @@ class CliDumper extends AbstractDumper
}
if ('' === $str) {
$this->line .= '""';
- $this->dumpLine($cursor->depth);
+ $this->dumpLine($cursor->depth, true);
} else {
$attr = array(
- 'length' => function_exists('iconv_strlen') && 0 <= $cut ? iconv_strlen($str, 'UTF-8') + $cut : 0,
+ 'length' => 0 <= $cut && function_exists('iconv_strlen') ? iconv_strlen($str, 'UTF-8') + $cut : 0,
'binary' => $bin,
);
$str = explode("\n", $str);
+ if (isset($str[1]) && !isset($str[2]) && !isset($str[1][0])) {
+ unset($str[1]);
+ $str[0] .= "\n";
+ }
$m = count($str) - 1;
$i = $lineCut = 0;
@@ -183,20 +194,30 @@ class CliDumper extends AbstractDumper
}
foreach ($str as $str) {
+ if ($i < $m) {
+ $str .= "\n";
+ }
if (0 < $this->maxStringWidth && $this->maxStringWidth < $len = iconv_strlen($str, 'UTF-8')) {
$str = iconv_substr($str, 0, $this->maxStringWidth, 'UTF-8');
$lineCut = $len - $this->maxStringWidth;
}
-
- if ($m) {
+ if ($m && 0 < $cursor->depth) {
$this->line .= $this->indentPad;
}
- $this->line .= $this->style('str', $str, $attr);
-
+ if ('' !== $str) {
+ $this->line .= $this->style('str', $str, $attr);
+ }
if ($i++ == $m) {
- $this->line .= '"';
if ($m) {
- $this->line .= '""';
+ if ('' !== $str) {
+ $this->dumpLine($cursor->depth);
+ if (0 < $cursor->depth) {
+ $this->line .= $this->indentPad;
+ }
+ }
+ $this->line .= '"""';
+ } else {
+ $this->line .= '"';
}
if ($cut < 0) {
$this->line .= '…';
@@ -210,7 +231,7 @@ class CliDumper extends AbstractDumper
$lineCut = 0;
}
- $this->dumpLine($cursor->depth);
+ $this->dumpLine($cursor->depth, $i > $m);
}
}
}
@@ -228,7 +249,7 @@ class CliDumper extends AbstractDumper
if (Cursor::HASH_OBJECT === $type) {
$prefix = 'stdClass' !== $class ? $this->style('note', $class).' {' : '{';
} elseif (Cursor::HASH_RESOURCE === $type) {
- $prefix = $this->style('note', ':'.$class).' {';
+ $prefix = $this->style('note', $class.' resource').($hasChild ? ' {' : ' ');
} else {
$prefix = $class ? $this->style('note', 'array:'.$class).' [' : '[';
}
@@ -237,6 +258,8 @@ class CliDumper extends AbstractDumper
$prefix .= $this->style('ref', (Cursor::HASH_RESOURCE === $type ? '@' : '#').(0 < $cursor->softRefHandle ? $cursor->softRefHandle : $cursor->softRefTo), array('count' => $cursor->softRefCount));
} elseif ($cursor->hardRefTo && !$cursor->refIndex && $class) {
$prefix .= $this->style('ref', '&'.$cursor->hardRefTo, array('count' => $cursor->hardRefCount));
+ } elseif (!$hasChild && Cursor::HASH_RESOURCE === $type) {
+ $prefix = substr($prefix, 0, -1);
}
$this->line .= $prefix;
@@ -252,8 +275,8 @@ class CliDumper extends AbstractDumper
public function leaveHash(Cursor $cursor, $type, $class, $hasChild, $cut)
{
$this->dumpEllipsis($cursor, $hasChild, $cut);
- $this->line .= Cursor::HASH_OBJECT === $type || Cursor::HASH_RESOURCE === $type ? '}' : ']';
- $this->dumpLine($cursor->depth);
+ $this->line .= Cursor::HASH_OBJECT === $type ? '}' : (Cursor::HASH_RESOURCE !== $type ? ']' : ($hasChild ? '}' : ''));
+ $this->dumpLine($cursor->depth, true);
}
/**
@@ -360,12 +383,34 @@ class CliDumper extends AbstractDumper
}
$style = $this->styles[$style];
- $cchr = $this->colors ? "\033[m\033[{$style};{$this->styles['cchr']}m%s\033[m\033[{$style}m" : '%s';
- $value = preg_replace_callback(self::$controlCharsRx, function ($r) use ($cchr) {
- return sprintf($cchr, "\x7F" === $r[0] ? '?' : chr(64 + ord($r[0])));
- }, $value);
- return $this->colors ? sprintf("\033[%sm%s\033[m\033[%sm", $style, $value, $this->styles['default']) : $value;
+ $map = static::$controlCharsMap;
+ $startCchr = $this->colors ? "\033[m\033[{$this->styles['default']}m" : '';
+ $endCchr = $this->colors ? "\033[m\033[{$style}m" : '';
+ $value = preg_replace_callback(static::$controlCharsRx, function ($c) use ($map, $startCchr, $endCchr) {
+ $s = $startCchr;
+ $c = $c[$i = 0];
+ do {
+ $s .= isset($map[$c[$i]]) ? $map[$c[$i]] : sprintf('\x%02X', ord($c[$i]));
+ } while (isset($c[++$i]));
+
+ return $s.$endCchr;
+ }, $value, -1, $cchrCount);
+
+ if ($this->colors) {
+ if ($cchrCount && "\033" === $value[0]) {
+ $value = substr($value, strlen($startCchr));
+ } else {
+ $value = "\033[{$style}m".$value;
+ }
+ if ($cchrCount && $endCchr === substr($value, -strlen($endCchr))) {
+ $value = substr($value, 0, -strlen($endCchr));
+ } else {
+ $value .= "\033[{$this->styles['default']}m";
+ }
+ }
+
+ return $value;
}
/**
@@ -418,7 +463,7 @@ class CliDumper extends AbstractDumper
/**
* {@inheritdoc}
*/
- protected function dumpLine($depth)
+ protected function dumpLine($depth, $endOfValue = false)
{
if ($this->colors) {
$this->line = sprintf("\033[%sm%s\033[m", $this->styles['default'], $this->line);
diff --git a/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php b/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php
index 3b5b73a6c3..399465938c 100644
--- a/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php
+++ b/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php
@@ -35,7 +35,6 @@ class HtmlDumper extends CliDumper
'num' => 'font-weight:bold; color:#1299DA',
'const' => 'font-weight:bold',
'str' => 'font-weight:bold; color:#56DB3A',
- 'cchr' => 'color:#FF8400',
'note' => 'color:#1299DA',
'ref' => 'color:#A0A0A0',
'public' => 'color:#FFFFFF',
@@ -376,10 +375,6 @@ EOHTML;
}
$v = htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
- $v = preg_replace_callback(self::$controlCharsRx, function ($r) {
- // Use Unicode Control Pictures - see http://www.unicode.org/charts/PDF/U2400.pdf
- return sprintf('%d;', ord($r[0]), "\x7F" !== $r[0] ? 0x2400 + ord($r[0]) : 0x2421);
- }, $v);
if ('ref' === $style) {
if (empty($attr['count'])) {
@@ -396,25 +391,44 @@ EOHTML;
$style .= sprintf(' title="%s"', empty($attr['dynamic']) ? 'Public property' : 'Runtime added dynamic property');
} elseif ('str' === $style && 1 < $attr['length']) {
$style .= sprintf(' title="%s%s characters"', $attr['length'], $attr['binary'] ? ' binary or non-UTF-8' : '');
- } elseif ('note' === $style) {
- if (false !== $c = strrpos($v, '\\')) {
- return sprintf('%s', $v, $style, substr($v, $c + 1));
- } elseif (':' === $v[0]) {
- return sprintf('%s', substr($v, 1), $style, $v);
- }
+ } elseif ('note' === $style && false !== $c = strrpos($v, '\\')) {
+ return sprintf('%s', $v, $style, substr($v, $c + 1));
} elseif ('protected' === $style) {
$style .= ' title="Protected property"';
} elseif ('private' === $style) {
$style .= sprintf(' title="Private property defined in class:
`%s`"', $attr['class']);
}
- return "$v";
+ $map = static::$controlCharsMap;
+ $style = "";
+ $v = preg_replace_callback(static::$controlCharsRx, function ($c) use ($map, $style) {
+ $s = '';
+ $c = $c[$i = 0];
+ do {
+ $s .= isset($map[$c[$i]]) ? $map[$c[$i]] : sprintf('\x%02X', ord($c[$i]));
+ } while (isset($c[++$i]));
+
+ return $s.$style;
+ }, $v, -1, $cchrCount);
+
+ if ($cchrCount && '<' === $v[0]) {
+ $v = substr($v, 7);
+ } else {
+ $v = $style.$v;
+ }
+ if ($cchrCount && '>' === substr($v, -1)) {
+ $v = substr($v, 0, -strlen($style));
+ } else {
+ $v .= '';
+ }
+
+ return $v;
}
/**
* {@inheritdoc}
*/
- protected function dumpLine($depth)
+ protected function dumpLine($depth, $endOfValue = false)
{
if (-1 === $this->lastDepth) {
$this->line = sprintf($this->dumpPrefix, $this->dumpId, $this->indentPad).$this->line;
diff --git a/src/Symfony/Component/VarDumper/Tests/CliDumperTest.php b/src/Symfony/Component/VarDumper/Tests/CliDumperTest.php
index ceb417a632..05c16b37ba 100644
--- a/src/Symfony/Component/VarDumper/Tests/CliDumperTest.php
+++ b/src/Symfony/Component/VarDumper/Tests/CliDumperTest.php
@@ -56,10 +56,10 @@ array:25 [
4 => INF
5 => -INF
6 => {$intMax}
- "str" => "déjà"
- 7 => b"é@"
+ "str" => "déjà\\n"
+ 7 => b"é\\x00"
"[]" => []
- "res" => :stream {@{$res1}
+ "res" => stream resource {@{$res1}
wrapper_type: "plainfile"
stream_type: "STDIO"
mode: "r"
@@ -70,7 +70,7 @@ array:25 [
eof: false
options: []
}
- 8 => :Unknown {@{$res2}}
+ 8 => Unknown resource @{$res2}
"obj" => Symfony\Component\VarDumper\Tests\Fixture\DumbFoo {#%d
+foo: "foo"
+"bar": "bar"
@@ -119,7 +119,7 @@ EOTXT
$this->assertDumpEquals(
<<assertStringMatchesFormat(
<< 'foo');
- $var->bar =& $var->foo;
+ $var->bar = &$var->foo;
$dumper = new CliDumper();
$dumper->setColors(false);
@@ -336,7 +336,7 @@ EOTXT
$var = function &() {
$var = array();
- $var[] =& $var;
+ $var[] = &$var;
return $var;
};
diff --git a/src/Symfony/Component/VarDumper/Tests/Fixtures/dumb-var.php b/src/Symfony/Component/VarDumper/Tests/Fixtures/dumb-var.php
index 380369a3c8..2cd707d507 100644
--- a/src/Symfony/Component/VarDumper/Tests/Fixtures/dumb-var.php
+++ b/src/Symfony/Component/VarDumper/Tests/Fixtures/dumb-var.php
@@ -19,7 +19,7 @@ fclose($h);
$var = array(
'number' => 1, null,
'const' => 1.1, true, false, NAN, INF, -INF, PHP_INT_MAX,
- 'str' => "déjà", "\xE9\x00",
+ 'str' => "déjà\n", "\xE9\x00",
'[]' => array(),
'res' => $g,
$h,
@@ -30,14 +30,14 @@ $var = array(
);
$r = array();
-$r[] =& $r;
+$r[] = &$r;
-$var['recurs'] =& $r;
-$var[] =& $var[0];
+$var['recurs'] = &$r;
+$var[] = &$var[0];
$var['sobj'] = $var['obj'];
-$var['snobj'] =& $var['nobj'][0];
+$var['snobj'] = &$var['nobj'][0];
$var['snobj2'] = $var['nobj'][0];
$var['file'] = __FILE__;
-$var["bin-key-\xE9"] = "";
+$var["bin-key-\xE9"] = '';
unset($g, $h, $r);
diff --git a/src/Symfony/Component/VarDumper/Tests/HtmlDumperTest.php b/src/Symfony/Component/VarDumper/Tests/HtmlDumperTest.php
index 7a5af2627c..b7c373a0f6 100644
--- a/src/Symfony/Component/VarDumper/Tests/HtmlDumperTest.php
+++ b/src/Symfony/Component/VarDumper/Tests/HtmlDumperTest.php
@@ -59,10 +59,10 @@ class HtmlDumperTest extends \PHPUnit_Framework_TestCase
4 => INF
5 => -INF
6 => {$intMax}
- "str" => "déjà"
- 7 => b"é␀"
+ "str" => "déjà\\n"
+ 7 => b"é\\x00"
"[]" => []
- "res" => :stream {@{$res1}
+ "res" => stream resource @{$res1}
wrapper_type: "plainfile"
stream_type: "STDIO"
mode: "r"
@@ -73,7 +73,7 @@ class HtmlDumperTest extends \PHPUnit_Framework_TestCase
eof: false
options: []
}
- 8 => :Unknown {@{$res2}}
+ 8 => Unknown resource @{$res2}
"obj" => DumbFoo {#%d
+foo: "foo"
+"bar": "bar"