Merge branch '2.7' into 2.8

* 2.7:
  [FrameworkBundle] Reuse PropertyAccessor service for ObjectNormalizer
  [VarDumper] Fix dump output for better readability
  [PhpUnitBridge] Enforce @-silencing of deprecation notices according to new policy
This commit is contained in:
Nicolas Grekas 2015-06-19 17:09:14 +02:00
commit 7304ba185b
85 changed files with 144 additions and 316 deletions

View File

@ -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 <p@tchwork.com>
*/
@ -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);
}
});

View File

@ -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:

View File

@ -55,8 +55,10 @@
</service>
<!-- CoreExtension -->
<service id="form.property_accessor" alias="property_accessor" public="false" />
<service id="form.type.form" class="Symfony\Component\Form\Extension\Core\Type\FormType">
<argument type="service" id="property_accessor"/>
<argument type="service" id="form.property_accessor" />
<tag name="form.type" alias="form" />
</service>
<service id="form.type.birthday" class="Symfony\Component\Form\Extension\Core\Type\BirthdayType">

View File

@ -17,9 +17,13 @@
<argument type="collection" />
</service>
<service id="serializer.property_accessor" alias="property_accessor" public="false" />
<!-- Normalizer -->
<service id="serializer.normalizer.object" class="Symfony\Component\Serializer\Normalizer\ObjectNormalizer" public="false">
<argument type="service" id="serializer.mapping.class_metadata_factory" />
<argument>null</argument>
<argument type="service" id="serializer.property_accessor" />
<!-- Run after all custom serializers -->
<tag name="serializer.normalizer" priority="-1000" />

View File

@ -72,15 +72,11 @@ abstract class AbstractDescriptorTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyDescribeSynchronizedServiceDefinition(Definition $definition, $expectedDescription)
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$this->assertDescription($expectedDescription, $definition);
}
public function provideLegacySynchronizedServiceDefinitionTestData()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
return $this->getDescriptionTestData(ObjectsProvider::getLegacyContainerDefinitions());
}

View File

@ -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.

View File

@ -21,11 +21,6 @@ use Symfony\Component\DependencyInjection\Reference;
*/
class LegacyTemplatingAssetHelperPassTest extends \PHPUnit_Framework_TestCase
{
protected function setUp()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
}
public function getScopesTests()
{
return array(

View File

@ -93,8 +93,6 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyInvalidValueAssets()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$processor = new Processor();
$configuration = new Configuration(true);
$processor->processConfiguration($configuration, array(

View File

@ -208,8 +208,6 @@ abstract class FrameworkExtensionTest extends TestCase
*/
public function testLegacyTemplatingAssets()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$this->checkAssetsPackages($this->createContainerFromFile('legacy_templating_assets'), true);
}
@ -301,8 +299,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.');
}
@ -404,8 +400,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'));
@ -417,8 +411,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'));

View File

@ -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')

View File

@ -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());

View File

@ -23,8 +23,6 @@ class AssetsHelperTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyGetUrl()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$package = new Package(new StaticVersionStrategy('22', '%s?version=%s'));
$packages = new Packages($package);
$helper = new AssetsHelper($packages);
@ -37,8 +35,6 @@ class AssetsHelperTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyGetVersion()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$package = new Package(new StaticVersionStrategy('22'));
$imagePackage = new Package(new StaticVersionStrategy('42'));
$packages = new Packages($package, array('images' => $imagePackage));

View File

@ -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());

View File

@ -29,8 +29,6 @@ class TwigExtensionTest extends TestCase
*/
public function testLegacyFormResourcesConfigurationKey($format)
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$container = $this->createContainer();
$container->registerExtension(new TwigExtension());
$this->loadFromFile($container, 'legacy-form-resources-only', $format);
@ -49,8 +47,6 @@ class TwigExtensionTest extends TestCase
*/
public function testLegacyMergeFormResourcesConfigurationKeyWithFormThemesConfigurationKey($format)
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$container = $this->createContainer();
$container->registerExtension(new TwigExtension());
$this->loadFromFile($container, 'legacy-merge-form-resources-with-form-themes', $format);

View File

@ -13,18 +13,12 @@ namespace Symfony\Bundle\TwigBundle\Tests\Extension;
use Symfony\Bundle\TwigBundle\Extension\AssetsExtension;
use Symfony\Bundle\TwigBundle\Tests\TestCase;
use Symfony\Component\Routing\RequestContext;
/**
* @group legacy
*/
class LegacyAssetsExtensionTest extends TestCase
{
protected function setUp()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
}
/**
* @dataProvider provideGetAssetUrlArguments
*/

View File

@ -20,11 +20,6 @@ use Symfony\Bundle\TwigBundle\Node\RenderNode;
*/
class LegacyRenderTokenParserTest extends TestCase
{
protected function setUp()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
}
/**
* @dataProvider getTestsForRender
*/

View File

@ -20,8 +20,6 @@ class LegacyApcUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase
{
protected function setUp()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
if (!extension_loaded('apc')) {
$this->markTestSkipped('The apc extension is not available.');
}

View File

@ -18,11 +18,6 @@ use Symfony\Component\ClassLoader\UniversalClassLoader;
*/
class LegacyUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase
{
protected function setUp()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
}
/**
* @dataProvider getLoadClassTests
*/

View File

@ -495,8 +495,6 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyAsText()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$application = new Application();
$application->add(new \FooCommand());
$this->ensureStaticCommandHelp($application);
@ -509,8 +507,6 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyAsXml()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$application = new Application();
$application->add(new \FooCommand());
$this->ensureStaticCommandHelp($application);
@ -679,7 +675,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.

View File

@ -341,8 +341,6 @@ class CommandTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyAsText()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$command = new \TestCommand();
$command->setApplication(new Application());
$tester = new CommandTester($command);
@ -355,8 +353,6 @@ class CommandTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyAsXml()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$command = new \TestCommand();
$command->setApplication(new Application());
$tester = new CommandTester($command);

View File

@ -22,11 +22,6 @@ use Symfony\Component\Console\Output\StreamOutput;
*/
class LegacyDialogHelperTest extends \PHPUnit_Framework_TestCase
{
protected function setUp()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
}
public function testSelect()
{
$dialog = new DialogHelper();

View File

@ -19,11 +19,6 @@ use Symfony\Component\Console\Output\StreamOutput;
*/
class LegacyProgressHelperTest extends \PHPUnit_Framework_TestCase
{
protected function setUp()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
}
public function testAdvance()
{
$progress = new ProgressHelper();

View File

@ -23,7 +23,6 @@ class LegacyTableHelperTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$this->stream = fopen('php://memory', 'r+');
}

View File

@ -376,7 +376,7 @@ class InputDefinitionTest extends \PHPUnit_Framework_TestCase
array(new InputDefinition(array(new InputOption('foo'), new InputArgument('foo', InputArgument::REQUIRED))), '[--foo] [--] <foo>', 'puts [--] between options and arguments'),
);
}
public function testGetShortSynopsis()
{
$definition = new InputDefinition(array(new InputOption('foo'), new InputOption('bar'), new InputArgument('cat')));
@ -388,8 +388,6 @@ class InputDefinitionTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyAsText()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$definition = new InputDefinition(array(
new InputArgument('foo', InputArgument::OPTIONAL, 'The foo argument'),
new InputArgument('baz', InputArgument::OPTIONAL, 'The baz argument', true),
@ -400,7 +398,7 @@ class InputDefinitionTest extends \PHPUnit_Framework_TestCase
new InputOption('qux', '', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'The qux option', array('http://foo.com/', 'bar')),
new InputOption('qux2', '', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'The qux2 option', array('foo' => 'bar')),
));
$this->assertStringEqualsFile(self::$fixtures.'/definition_astext.txt', $definition->asText(), '->asText() returns a textual representation of the InputDefinition');
}
@ -409,8 +407,6 @@ class InputDefinitionTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyAsXml()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$definition = new InputDefinition(array(
new InputArgument('foo', InputArgument::OPTIONAL, 'The foo argument'),
new InputArgument('baz', InputArgument::OPTIONAL, 'The baz argument', true),

View File

@ -46,8 +46,6 @@ class StringInputTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyInputOptionDefinitionInConstructor()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$definition = new InputDefinition(
array(new InputOption('foo', null, InputOption::VALUE_REQUIRED))
);

View File

@ -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);
@ -444,8 +442,6 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyInterface()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
try {
$handler = ErrorHandler::register(0);
$this->assertFalse($handler->handle(0, 'foo', 'foo.php', 12, array()));

View File

@ -73,8 +73,6 @@ class ClassNotFoundFatalErrorHandlerTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyHandleClassNotFound()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$prefixes = array('Symfony\Component\Debug\Exception\\' => realpath(__DIR__.'/../../Exception'));
$symfonyUniversalClassLoader = new SymfonyUniversalClassLoader();
$symfonyUniversalClassLoader->registerPrefixes($prefixes);

View File

@ -56,8 +56,6 @@ class CheckDefinitionValidityPassTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyProcessDetectsBothFactorySyntaxesUsed()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$container = new ContainerBuilder();
$container->register('a')->setFactory(array('a', 'b'))->setFactoryClass('a');

View File

@ -21,8 +21,6 @@ class LegacyResolveParameterPlaceHoldersPassTest extends \PHPUnit_Framework_Test
{
public function testFactoryClassParametersShouldBeResolved()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$compilerPass = new ResolveParameterPlaceHoldersPass();
$container = new ContainerBuilder();

View File

@ -342,8 +342,6 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase
public function testLegacyCreateServiceFactory()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$builder = new ContainerBuilder();
$builder->register('bar', 'Bar\FooClass');
$builder
@ -363,8 +361,6 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyCreateServiceFactoryService()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$builder = new ContainerBuilder();
$builder->register('foo_service', 'Bar\FooClass');
$builder
@ -735,8 +731,6 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacySetOnSynchronizedService()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$container = new ContainerBuilder();
$container->register('baz', 'BazClass')
->setSynchronized(true)
@ -757,8 +751,6 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacySynchronizedServiceWithScopes()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$container = new ContainerBuilder();
$container->addScope(new Scope('foo'));
$container->register('baz', 'BazClass')

View File

@ -55,8 +55,6 @@ class DefinitionDecoratorTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacySetProperty($property, $changeKey)
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$def = new DefinitionDecorator('foo');
$getter = 'get'.ucfirst($property);

View File

@ -170,8 +170,6 @@ class DefinitionTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacySetIsSynchronized()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$def = new Definition('stdClass');
$this->assertFalse($def->isSynchronized(), '->isSynchronized() returns false by default');
$this->assertSame($def, $def->setSynchronized(true), '->setSynchronized() implements a fluent interface');

View File

@ -28,8 +28,6 @@ class GraphvizDumperTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyDump()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$container = include self::$fixturesPath.'/containers/legacy-container9.php';
$dumper = new GraphvizDumper($container);
$this->assertEquals(str_replace('%path%', __DIR__, file_get_contents(self::$fixturesPath.'/graphviz/legacy-services9.dot')), $dumper->dump(), '->dump() dumps services');

View File

@ -129,8 +129,6 @@ class PhpDumperTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacySynchronizedServices()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$container = include self::$fixturesPath.'/containers/container20.php';
$dumper = new PhpDumper($container);
$this->assertEquals(str_replace('%path%', str_replace('\\', '\\\\', self::$fixturesPath.DIRECTORY_SEPARATOR.'includes'.DIRECTORY_SEPARATOR), file_get_contents(self::$fixturesPath.'/php/services20.php')), $dumper->dump(), '->dump() dumps services');

View File

@ -49,8 +49,6 @@ class XmlDumperTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyAddService()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$container = include self::$fixturesPath.'/containers/legacy-container9.php';
$dumper = new XmlDumper($container);

View File

@ -45,8 +45,6 @@ class YamlDumperTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyAddService()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$container = include self::$fixturesPath.'/containers/legacy-container9.php';
$dumper = new YamlDumper($container);

View File

@ -19,11 +19,6 @@ use Symfony\Component\DependencyInjection\Reference;
*/
class LegacyContainerBuilderTest extends \PHPUnit_Framework_TestCase
{
protected function setUp()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
}
/**
* @covers Symfony\Component\DependencyInjection\ContainerBuilder::createService
*/

View File

@ -18,11 +18,6 @@ use Symfony\Component\DependencyInjection\Definition;
*/
class LegacyDefinitionTest extends \PHPUnit_Framework_TestCase
{
protected function setUp()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
}
public function testSetGetFactoryClass()
{
$def = new Definition('stdClass');

View File

@ -195,8 +195,6 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyLoadServices()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$container = new ContainerBuilder();
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'));
$loader->load('legacy-services6.xml');

View File

@ -124,8 +124,6 @@ class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyLoadServices()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$container = new ContainerBuilder();
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
$loader->load('legacy-services6.yml');

View File

@ -126,8 +126,6 @@ abstract class AbstractEventDispatcherTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyDispatch()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$event = new Event();
$return = $this->dispatcher->dispatch(self::preFoo, $event);
$this->assertEquals('pre.foo', $event->getName());
@ -255,8 +253,6 @@ abstract class AbstractEventDispatcherTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyEventReceivesTheDispatcherInstance()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$dispatcher = null;
$this->dispatcher->addListener('test', function ($event) use (&$dispatcher) {
$dispatcher = $event->getDispatcher();

View File

@ -65,7 +65,6 @@ class EventTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacySetDispatcher()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$this->event->setDispatcher($this->dispatcher);
$this->assertSame($this->dispatcher, $this->event->getDispatcher());
}
@ -75,7 +74,6 @@ class EventTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyGetDispatcher()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$this->assertNull($this->event->getDispatcher());
}
@ -84,7 +82,6 @@ class EventTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyGetName()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$this->assertNull($this->event->getName());
}
@ -93,7 +90,6 @@ class EventTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacySetName()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$this->event->setName('foo');
$this->assertEquals('foo', $this->event->getName());
}

View File

@ -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(),

View File

@ -37,8 +37,6 @@ class LegacyBindRequestListenerTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$path = tempnam(sys_get_temp_dir(), 'sf2');
touch($path);

View File

@ -138,8 +138,6 @@ class FlashBagTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyGetIterator()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$flashes = array('hello' => 'world', 'beep' => 'boop', 'notice' => 'nope');
foreach ($flashes as $key => $val) {
$this->bag->set($key, $val);

View File

@ -22,8 +22,6 @@ class LegacyPdoSessionHandlerTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
if (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers())) {
$this->markTestSkipped('This test requires SQLite support in your environment');
}

View File

@ -23,8 +23,6 @@ class FragmentRendererPassTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyFragmentRedererWithoutAlias()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
// no alias
$services = array(
'my_content_renderer' => array(array()),

View File

@ -29,8 +29,6 @@ class ProfilerListenerTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyEventsWithoutRequestStack()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$profile = $this->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profile')
->disableOriginalConstructor()
->getMock();

View File

@ -344,8 +344,6 @@ EOF;
protected function getKernelMockForIsClassInActiveBundleTest()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$bundle = new FooBarBundle();
$kernel = $this->getKernel(array('getBundles'));

View File

@ -23,8 +23,6 @@ class LocaleTest extends \PHPUnit_Framework_TestCase
{
protected function setUp()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
// Locale extends \Locale, so intl must be present
IntlTestHelper::requireIntl($this);
}

View File

@ -21,8 +21,6 @@ class StubLocaleTest extends \PHPUnit_Framework_TestCase
{
protected function setUp()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
// Locale extends \Locale, so intl must be present
IntlTestHelper::requireIntl($this);
}

View File

@ -26,8 +26,6 @@ class LegacyOptionsResolverTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$this->resolver = new OptionsResolver();
}

View File

@ -26,8 +26,6 @@ class LegacyOptionsTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$this->options = new OptionsResolver();
}

View File

@ -238,8 +238,6 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyValidInput($expected, $value)
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$process = $this->getProcess('php -v');
$process->setInput($value);
$this->assertSame($expected, $process->getInput());

View File

@ -52,8 +52,6 @@ class RouteTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyGetPattern()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$route = new Route(array('value' => '/Blog'));
$this->assertEquals($route->getPattern(), '/Blog');
}

View File

@ -461,8 +461,6 @@ class UrlGeneratorTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyGenerateNetworkPath()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$routes = $this->getRoutes('test', new Route('/{name}', array(), array('_scheme' => 'http'), array(), '{locale}.example.com'));
$this->assertSame('//fr.example.com/app.php/Fabien', $this->getGenerator($routes)->generate('test',

View File

@ -50,8 +50,6 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyRouteDefinitionLoading()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
$routeCollection = $loader->load('legacy_validpattern.xml');
$route = $routeCollection->get('blog_show_legacy');

View File

@ -86,8 +86,6 @@ class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyRouteDefinitionLoading()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
$routeCollection = $loader->load('legacy_validpattern.yml');
$route = $routeCollection->get('blog_show_legacy');

View File

@ -27,11 +27,6 @@ class LegacyApacheMatcherDumperTest extends \PHPUnit_Framework_TestCase
self::$fixturesPath = realpath(__DIR__.'/../../Fixtures/');
}
protected function setUp()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
}
public function testDump()
{
$dumper = new ApacheMatcherDumper($this->getRouteCollection());

View File

@ -24,7 +24,6 @@ class LegacyApacheUrlMatcherTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$this->server = $_SERVER;
}

View File

@ -169,8 +169,6 @@ class RouteTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacySchemeRequirement()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$route = new Route('/');
$route->setRequirement('_scheme', 'http|https');
$this->assertEquals('http|https', $route->getRequirement('_scheme'));
@ -199,8 +197,6 @@ class RouteTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyMethodRequirement()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$route = new Route('/');
$route->setRequirement('_method', 'GET|POST');
$this->assertEquals('GET|POST', $route->getRequirement('_method'));
@ -233,8 +229,6 @@ class RouteTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyPattern()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$route = new Route('/{foo}');
$this->assertEquals('/{foo}', $route->getPattern());

View File

@ -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);

View File

@ -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);

View File

@ -105,8 +105,6 @@ class GetSetMethodNormalizerTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyDenormalizeOnCamelCaseFormat()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$this->normalizer->setCamelizedAttributes(array('camel_case'));
$obj = $this->normalizer->denormalize(
array('camel_case' => 'camelCase'),
@ -136,8 +134,6 @@ class GetSetMethodNormalizerTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyCamelizedAttributesNormalize()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$obj = new GetCamelizedDummy('dunglas.fr');
$obj->setFooBar('les-tilleuls.coop');
$obj->setBar_foo('lostinthesupermarket.fr');
@ -162,8 +158,6 @@ class GetSetMethodNormalizerTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyCamelizedAttributesDenormalize()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$obj = new GetCamelizedDummy('dunglas.fr');
$obj->setFooBar('les-tilleuls.coop');
$obj->setBar_foo('lostinthesupermarket.fr');

View File

@ -102,8 +102,6 @@ class ObjectNormalizerTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyDenormalizeOnCamelCaseFormat()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$this->normalizer->setCamelizedAttributes(array('camel_case'));
$obj = $this->normalizer->denormalize(
array('camel_case' => 'camelCase'),

View File

@ -68,8 +68,6 @@ class PropertyNormalizerTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyDenormalizeOnCamelCaseFormat()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$this->normalizer->setCamelizedAttributes(array('camel_case'));
$obj = $this->normalizer->denormalize(
array('camel_case' => 'value'),
@ -83,8 +81,6 @@ class PropertyNormalizerTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyCamelizedAttributesNormalize()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$obj = new PropertyCamelizedDummy('dunglas.fr');
$obj->fooBar = 'les-tilleuls.coop';
$obj->bar_foo = 'lostinthesupermarket.fr';
@ -109,8 +105,6 @@ class PropertyNormalizerTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyCamelizedAttributesDenormalize()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$obj = new PropertyCamelizedDummy('dunglas.fr');
$obj->fooBar = 'les-tilleuls.coop';
$obj->bar_foo = 'lostinthesupermarket.fr';

View File

@ -18,11 +18,6 @@ use Symfony\Component\Templating\Helper\AssetsHelper;
*/
class LegacyAssetsHelperTest extends \PHPUnit_Framework_TestCase
{
protected function setUp()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
}
public function testGetVersion()
{
$helper = new AssetsHelper(null, array(), 'foo');

View File

@ -22,8 +22,6 @@ class LegacyCoreAssetsHelperTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$this->package = $this->getMock('Symfony\Component\Templating\Asset\PackageInterface');
}

View File

@ -29,8 +29,6 @@ class LoaderTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyGetSetDebugger()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$loader = new ProjectTemplateLoader4();
$debugger = $this->getMock('Symfony\Component\Templating\DebuggerInterface');
$loader->setDebugger($debugger);

View File

@ -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;

View File

@ -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(

View File

@ -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

View File

@ -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();

View File

@ -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.');
}

View File

@ -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();
}

View File

@ -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());

View File

@ -578,8 +578,6 @@ abstract class Abstract2Dot5ApiTest extends AbstractValidatorTest
*/
public function testLegacyPropertyMetadataMustImplementPropertyMetadataInterface()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$entity = new Entity();
// Legacy interface

View File

@ -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);

View File

@ -844,8 +844,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');
@ -977,8 +975,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');

View File

@ -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);

View File

@ -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('<span class=sf-dump-cchr title=\\x%02X>&#%d;</span>', 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('<abbr title="%s" class=sf-dump-%s>%s</abbr>', $v, $style, substr($v, $c + 1));
} elseif (':' === $v[0]) {
return sprintf('<abbr title="`%s` resource" class=sf-dump-%s>%s</abbr>', substr($v, 1), $style, $v);
}
} elseif ('note' === $style && false !== $c = strrpos($v, '\\')) {
return sprintf('<abbr title="%s" class=sf-dump-%s>%s</abbr>', $v, $style, substr($v, $c + 1));
} elseif ('protected' === $style) {
$style .= ' title="Protected property"';
} elseif ('private' === $style) {
$style .= sprintf(' title="Private property defined in class:&#10;`%s`"', $attr['class']);
}
return "<span class=sf-dump-$style>$v</span>";
$map = static::$controlCharsMap;
$style = "<span class=sf-dump-{$style}>";
$v = preg_replace_callback(static::$controlCharsRx, function ($c) use ($map, $style) {
$s = '</span>';
$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 .= '</span>';
}
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;

View File

@ -65,10 +65,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"
@ -79,7 +79,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"
@ -126,7 +126,7 @@ EOTXT
$this->assertDumpEquals(
<<<EOTXT
:xml {
xml resource {
current_byte_index: 0
current_column_number: 1
current_line_number: 1
@ -161,7 +161,7 @@ EOTXT
$this->assertStringMatchesFormat(
<<<EOTXT
:stream {@{$ref}
stream resource {@{$ref}
wrapper_type: "PHP"
stream_type: "MEMORY"
mode: "w+b"
@ -192,7 +192,7 @@ EOTXT
public function testRefsInProperties()
{
$var = (object) array('foo' => 'foo');
$var->bar =& $var->foo;
$var->bar = &$var->foo;
$dumper = new CliDumper();
$dumper->setColors(false);
@ -343,7 +343,7 @@ EOTXT
$var = function &() {
$var = array();
$var[] =& $var;
$var[] = &$var;
return $var;
};

View File

@ -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);

View File

@ -68,10 +68,10 @@ EOTXT;
<span class=sf-dump-key>4</span> => <span class=sf-dump-num>INF</span>
<span class=sf-dump-key>5</span> => <span class=sf-dump-num>-INF</span>
<span class=sf-dump-key>6</span> => <span class=sf-dump-num>{$intMax}</span>
"<span class=sf-dump-key>str</span>" => "<span class=sf-dump-str title="4 characters">d&#233;j&#224;</span>"
<span class=sf-dump-key>7</span> => b"<span class=sf-dump-str title="2 binary or non-UTF-8 characters">&#233;<span class=sf-dump-cchr title=\\x00>&#9216;</span></span>"
"<span class=sf-dump-key>str</span>" => "<span class=sf-dump-str title="5 characters">d&#233;j&#224;</span>\\n"
<span class=sf-dump-key>7</span> => b"<span class=sf-dump-str title="2 binary or non-UTF-8 characters">&#233;</span>\\x00"
"<span class=sf-dump-key>[]</span>" => []
"<span class=sf-dump-key>res</span>" => <abbr title="`stream` resource" class=sf-dump-note>:stream</abbr> {<a class=sf-dump-ref>@{$res1}</a><samp>
"<span class=sf-dump-key>res</span>" => <span class=sf-dump-note>stream resource</span> <a class=sf-dump-ref>@{$res1}</a><samp>
<span class=sf-dump-meta>wrapper_type</span>: "<span class=sf-dump-str title="9 characters">plainfile</span>"
<span class=sf-dump-meta>stream_type</span>: "<span class=sf-dump-str title="5 characters">STDIO</span>"
<span class=sf-dump-meta>mode</span>: "<span class=sf-dump-str>r</span>"
@ -82,7 +82,7 @@ EOTXT;
<span class=sf-dump-meta>eof</span>: <span class=sf-dump-const>false</span>
<span class=sf-dump-meta>options</span>: []
</samp>}
<span class=sf-dump-key>8</span> => <abbr title="`Unknown` resource" class=sf-dump-note>:Unknown</abbr> {<a class=sf-dump-ref>@{$res2}</a>}
<span class=sf-dump-key>8</span> => <span class=sf-dump-note>Unknown resource</span> <a class=sf-dump-ref>@{$res2}</a>
"<span class=sf-dump-key>obj</span>" => <abbr title="Symfony\Component\VarDumper\Tests\Fixture\DumbFoo" class=sf-dump-note>DumbFoo</abbr> {<a class=sf-dump-ref href=#{$dumpId}-ref2%d title="2 occurrences">#%d</a><samp id={$dumpId}-ref2%d>
+<span class=sf-dump-public title="Public property">foo</span>: "<span class=sf-dump-str title="3 characters">foo</span>"
+"<span class=sf-dump-public title="Runtime added dynamic property">bar</span>": "<span class=sf-dump-str title="3 characters">bar</span>"

View File

@ -28,8 +28,6 @@ class YamlTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyParseFromFile()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$filename = __DIR__.'/Fixtures/index.yml';
$contents = file_get_contents($filename);
$parsedByFilename = Yaml::parse($filename);