From 52c50e3b1e15d96d8c0be42eda890247b9a68a65 Mon Sep 17 00:00:00 2001 From: blanchonvincent Date: Fri, 28 Nov 2014 16:49:28 +0100 Subject: [PATCH 1/5] Remove abstract class and use Interface+Trait Conflicts: src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Controller/LocalizedController.php src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Controller/LoginController.php src/Symfony/Component/DependencyInjection/ContainerAware.php --- .../Bundle/FrameworkBundle/Controller/Controller.php | 7 +++++-- .../FrameworkBundle/Controller/RedirectController.php | 7 +++++-- .../FrameworkBundle/Controller/TemplateController.php | 7 +++++-- .../Bundle/TestBundle/Controller/FragmentController.php | 7 +++++-- .../Bundle/TestBundle/Controller/ProfilerController.php | 7 +++++-- .../Bundle/TestBundle/Controller/SessionController.php | 7 +++++-- .../Bundle/TestBundle/Controller/SubRequestController.php | 7 +++++-- .../CsrfFormLoginBundle/Controller/LoginController.php | 7 +++++-- .../FormLoginBundle/Controller/LocalizedController.php | 7 +++++-- .../Bundle/FormLoginBundle/Controller/LoginController.php | 7 +++++-- src/Symfony/Component/HttpKernel/Bundle/Bundle.php | 7 +++++-- 11 files changed, 55 insertions(+), 22 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php b/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php index d2a1685270f2c..01bf726ceec5a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php @@ -11,11 +11,12 @@ namespace Symfony\Bundle\FrameworkBundle\Controller; +use Symfony\Component\DependencyInjection\ContainerAwareInterface; +use Symfony\Component\DependencyInjection\ContainerAwareTrait; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\StreamedResponse; -use Symfony\Component\DependencyInjection\ContainerAware; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\Security\Core\Exception\AccessDeniedException; @@ -35,8 +36,10 @@ * * @author Fabien Potencier */ -abstract class Controller extends ContainerAware +abstract class Controller implements ContainerAwareInterface { + use ContainerAwareTrait; + /** * Generates a URL from the given parameters. * diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php b/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php index b8f4e6415a540..a1f1b0486bba8 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php @@ -11,7 +11,8 @@ namespace Symfony\Bundle\FrameworkBundle\Controller; -use Symfony\Component\DependencyInjection\ContainerAware; +use Symfony\Component\DependencyInjection\ContainerAwareInterface; +use Symfony\Component\DependencyInjection\ContainerAwareTrait; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -23,8 +24,10 @@ * * @author Fabien Potencier */ -class RedirectController extends ContainerAware +class RedirectController implements ContainerAwareInterface { + use ContainerAwareTrait; + /** * Redirects to another route with the given name. * diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php b/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php index 16d15f902340c..d222bc7ea37a2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php @@ -11,7 +11,8 @@ namespace Symfony\Bundle\FrameworkBundle\Controller; -use Symfony\Component\DependencyInjection\ContainerAware; +use Symfony\Component\DependencyInjection\ContainerAwareInterface; +use Symfony\Component\DependencyInjection\ContainerAwareTrait; use Symfony\Component\HttpFoundation\Response; /** @@ -19,8 +20,10 @@ * * @author Fabien Potencier */ -class TemplateController extends ContainerAware +class TemplateController implements ContainerAwareInterface { + use ContainerAwareTrait; + /** * Renders a template. * diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/FragmentController.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/FragmentController.php index 783014ee9e1a0..88bd102a5f4ce 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/FragmentController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/FragmentController.php @@ -11,12 +11,15 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller; +use Symfony\Component\DependencyInjection\ContainerAwareInterface; +use Symfony\Component\DependencyInjection\ContainerAwareTrait; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\DependencyInjection\ContainerAware; -class FragmentController extends ContainerAware +class FragmentController implements ContainerAwareInterface { + use ContainerAwareTrait; + public function indexAction(Request $request) { return $this->container->get('templating')->renderResponse('fragment.html.php', array('bar' => new Bar())); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/ProfilerController.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/ProfilerController.php index 0452e255eafe4..dd518a12a8d54 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/ProfilerController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/ProfilerController.php @@ -11,11 +11,14 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller; +use Symfony\Component\DependencyInjection\ContainerAwareInterface; +use Symfony\Component\DependencyInjection\ContainerAwareTrait; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\DependencyInjection\ContainerAware; -class ProfilerController extends ContainerAware +class ProfilerController implements ContainerAwareInterface { + use ContainerAwareTrait; + public function indexAction() { return new Response('Hello'); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/SessionController.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/SessionController.php index bf22e63370139..76146376d009f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/SessionController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/SessionController.php @@ -11,13 +11,16 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller; +use Symfony\Component\DependencyInjection\ContainerAwareInterface; +use Symfony\Component\DependencyInjection\ContainerAwareTrait; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\DependencyInjection\ContainerAware; -class SessionController extends ContainerAware +class SessionController implements ContainerAwareInterface { + use ContainerAwareTrait; + public function welcomeAction(Request $request, $name = null) { $session = $request->getSession(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/SubRequestController.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/SubRequestController.php index e1bd050ce0afe..5df6e29590a5b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/SubRequestController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/SubRequestController.php @@ -11,13 +11,16 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller; +use Symfony\Component\DependencyInjection\ContainerAwareInterface; +use Symfony\Component\DependencyInjection\ContainerAwareTrait; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\DependencyInjection\ContainerAware; use Symfony\Component\HttpKernel\Controller\ControllerReference; -class SubRequestController extends ContainerAware +class SubRequestController implements ContainerAwareInterface { + use ContainerAwareTrait; + public function indexAction() { $handler = $this->container->get('fragment.handler'); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle/Controller/LoginController.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle/Controller/LoginController.php index dd7c19e9c7f15..c232b4cfd9029 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle/Controller/LoginController.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle/Controller/LoginController.php @@ -11,12 +11,15 @@ namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\CsrfFormLoginBundle\Controller; -use Symfony\Component\DependencyInjection\ContainerAware; +use Symfony\Component\DependencyInjection\ContainerAwareInterface; +use Symfony\Component\DependencyInjection\ContainerAwareTrait; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Security\Core\Exception\AccessDeniedException; -class LoginController extends ContainerAware +class LoginController implements ContainerAwareInterface { + use ContainerAwareTrait; + public function loginAction() { $form = $this->container->get('form.factory')->create('Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\CsrfFormLoginBundle\Form\UserLoginType'); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Controller/LocalizedController.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Controller/LocalizedController.php index b9004d26a3e69..7a6faf4cc99d2 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Controller/LocalizedController.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Controller/LocalizedController.php @@ -11,13 +11,16 @@ namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FormLoginBundle\Controller; +use Symfony\Component\DependencyInjection\ContainerAwareInterface; +use Symfony\Component\DependencyInjection\ContainerAwareTrait; use Symfony\Component\Security\Core\Security; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\DependencyInjection\ContainerAware; -class LocalizedController extends ContainerAware +class LocalizedController implements ContainerAwareInterface { + use ContainerAwareTrait; + public function loginAction(Request $request) { // get the login error if there is one diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Controller/LoginController.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Controller/LoginController.php index 3d0794a9e112d..ad003158f5179 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Controller/LoginController.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Controller/LoginController.php @@ -11,14 +11,17 @@ namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FormLoginBundle\Controller; +use Symfony\Component\DependencyInjection\ContainerAwareInterface; +use Symfony\Component\DependencyInjection\ContainerAwareTrait; use Symfony\Component\Security\Core\Exception\AccessDeniedException; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Security\Core\Security; -use Symfony\Component\DependencyInjection\ContainerAware; -class LoginController extends ContainerAware +class LoginController implements ContainerAwareInterface { + use ContainerAwareTrait; + public function loginAction(Request $request) { // get the login error if there is one diff --git a/src/Symfony/Component/HttpKernel/Bundle/Bundle.php b/src/Symfony/Component/HttpKernel/Bundle/Bundle.php index b1abca5237303..41bf87f4b01d3 100644 --- a/src/Symfony/Component/HttpKernel/Bundle/Bundle.php +++ b/src/Symfony/Component/HttpKernel/Bundle/Bundle.php @@ -11,7 +11,8 @@ namespace Symfony\Component\HttpKernel\Bundle; -use Symfony\Component\DependencyInjection\ContainerAware; +use Symfony\Component\DependencyInjection\ContainerAwareInterface; +use Symfony\Component\DependencyInjection\ContainerAwareTrait; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Container; use Symfony\Component\Console\Application; @@ -24,8 +25,10 @@ * * @author Fabien Potencier */ -abstract class Bundle extends ContainerAware implements BundleInterface +abstract class Bundle implements BundleInterface { + use ContainerAwareTrait; + protected $name; protected $extension; protected $path; From e337ce6bf7090c061b97767025597adcb7350022 Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Sun, 1 Nov 2015 17:29:50 +0100 Subject: [PATCH 2/5] Remove deprecated ContainerAware class and make use of the trait in another class --- .../Bridge/Doctrine/ManagerRegistry.php | 15 +------- .../DependencyInjection/ContainerAware.php | 37 ------------------- .../Component/HttpKernel/Bundle/Bundle.php | 1 - 3 files changed, 2 insertions(+), 51 deletions(-) delete mode 100644 src/Symfony/Component/DependencyInjection/ContainerAware.php diff --git a/src/Symfony/Bridge/Doctrine/ManagerRegistry.php b/src/Symfony/Bridge/Doctrine/ManagerRegistry.php index 6efcefb63736c..ff2c598b0577a 100644 --- a/src/Symfony/Bridge/Doctrine/ManagerRegistry.php +++ b/src/Symfony/Bridge/Doctrine/ManagerRegistry.php @@ -12,7 +12,7 @@ namespace Symfony\Bridge\Doctrine; use Symfony\Component\DependencyInjection\ContainerAwareInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\DependencyInjection\ContainerAwareTrait; use Doctrine\Common\Persistence\AbstractManagerRegistry; /** @@ -22,10 +22,7 @@ */ abstract class ManagerRegistry extends AbstractManagerRegistry implements ContainerAwareInterface { - /** - * @var ContainerInterface - */ - protected $container; + use ContainerAwareTrait; /** * {@inheritdoc} @@ -42,12 +39,4 @@ protected function resetService($name) { $this->container->set($name, null); } - - /** - * {@inheritdoc} - */ - public function setContainer(ContainerInterface $container = null) - { - $this->container = $container; - } } diff --git a/src/Symfony/Component/DependencyInjection/ContainerAware.php b/src/Symfony/Component/DependencyInjection/ContainerAware.php deleted file mode 100644 index d85fab1843db1..0000000000000 --- a/src/Symfony/Component/DependencyInjection/ContainerAware.php +++ /dev/null @@ -1,37 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\DependencyInjection; - -/** - * A simple implementation of ContainerAwareInterface. - * - * @author Fabien Potencier - * - * @deprecated since version 2.8, to be removed in 3.0. Use the ContainerAwareTrait instead. - */ -abstract class ContainerAware implements ContainerAwareInterface -{ - /** - * @var ContainerInterface - */ - protected $container; - - /** - * Sets the Container associated with this Controller. - * - * @param ContainerInterface $container A ContainerInterface instance - */ - public function setContainer(ContainerInterface $container = null) - { - $this->container = $container; - } -} diff --git a/src/Symfony/Component/HttpKernel/Bundle/Bundle.php b/src/Symfony/Component/HttpKernel/Bundle/Bundle.php index 41bf87f4b01d3..ba791d20428fe 100644 --- a/src/Symfony/Component/HttpKernel/Bundle/Bundle.php +++ b/src/Symfony/Component/HttpKernel/Bundle/Bundle.php @@ -11,7 +11,6 @@ namespace Symfony\Component\HttpKernel\Bundle; -use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerAwareTrait; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Container; From 24ff77067962e809d0ca191d92384e8c8a5e2d2c Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Wed, 4 Nov 2015 18:31:30 +0100 Subject: [PATCH 3/5] [TwigBundle] use ContainerAwareTrait in commands I made the class final because it is not meant to be extended. By using the trait, which uses protected visibility for the container property, it would otherwise make the container property part of of BC promise --- .../Bundle/TwigBundle/Command/DebugCommand.php | 17 +++-------------- .../Bundle/TwigBundle/Command/LintCommand.php | 17 +++-------------- 2 files changed, 6 insertions(+), 28 deletions(-) diff --git a/src/Symfony/Bundle/TwigBundle/Command/DebugCommand.php b/src/Symfony/Bundle/TwigBundle/Command/DebugCommand.php index f1a3696da829a..e2f25cc22ed19 100644 --- a/src/Symfony/Bundle/TwigBundle/Command/DebugCommand.php +++ b/src/Symfony/Bundle/TwigBundle/Command/DebugCommand.php @@ -12,28 +12,17 @@ namespace Symfony\Bundle\TwigBundle\Command; use Symfony\Bridge\Twig\Command\DebugCommand as BaseDebugCommand; -use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerAwareInterface; +use Symfony\Component\DependencyInjection\ContainerAwareTrait; /** * Lists twig functions, filters, globals and tests present in the current project. * * @author Jordi Boggiano */ -class DebugCommand extends BaseDebugCommand implements ContainerAwareInterface +final class DebugCommand extends BaseDebugCommand implements ContainerAwareInterface { - /** - * @var ContainerInterface|null - */ - private $container; - - /** - * {@inheritdoc} - */ - public function setContainer(ContainerInterface $container = null) - { - $this->container = $container; - } + use ContainerAwareTrait; /** * {@inheritdoc} diff --git a/src/Symfony/Bundle/TwigBundle/Command/LintCommand.php b/src/Symfony/Bundle/TwigBundle/Command/LintCommand.php index 60afc27ea59d2..36e4f059ff812 100644 --- a/src/Symfony/Bundle/TwigBundle/Command/LintCommand.php +++ b/src/Symfony/Bundle/TwigBundle/Command/LintCommand.php @@ -12,8 +12,8 @@ namespace Symfony\Bundle\TwigBundle\Command; use Symfony\Bridge\Twig\Command\LintCommand as BaseLintCommand; -use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerAwareInterface; +use Symfony\Component\DependencyInjection\ContainerAwareTrait; use Symfony\Component\Finder\Finder; /** @@ -22,20 +22,9 @@ * @author Marc Weistroff * @author Jérôme Tamarelle */ -class LintCommand extends BaseLintCommand implements ContainerAwareInterface +final class LintCommand extends BaseLintCommand implements ContainerAwareInterface { - /** - * @var ContainerInterface|null - */ - private $container; - - /** - * {@inheritdoc} - */ - public function setContainer(ContainerInterface $container = null) - { - $this->container = $container; - } + use ContainerAwareTrait; /** * {@inheritdoc} From 230990188db46ee00a514db0049d279d8012b8f0 Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Wed, 4 Nov 2015 18:48:20 +0100 Subject: [PATCH 4/5] [VarDumper] replace VarDumperTestCase by trait --- .../VarDumper/Test/VarDumperTestCase.php | 46 ------------------- .../VarDumper/Tests/Caster/CasterTest.php | 6 ++- .../Tests/Caster/ReflectionCasterTest.php | 6 ++- .../VarDumper/Tests/Caster/SplCasterTest.php | 6 ++- .../VarDumper/Tests/CliDumperTest.php | 6 ++- .../Tests/Test/VarDumpTestTraitRequire54.php | 41 ----------------- .../Tests/Test/VarDumpTestTraitTest.php | 32 +++++++++++-- 7 files changed, 44 insertions(+), 99 deletions(-) delete mode 100644 src/Symfony/Component/VarDumper/Test/VarDumperTestCase.php delete mode 100644 src/Symfony/Component/VarDumper/Tests/Test/VarDumpTestTraitRequire54.php diff --git a/src/Symfony/Component/VarDumper/Test/VarDumperTestCase.php b/src/Symfony/Component/VarDumper/Test/VarDumperTestCase.php deleted file mode 100644 index e04805d436418..0000000000000 --- a/src/Symfony/Component/VarDumper/Test/VarDumperTestCase.php +++ /dev/null @@ -1,46 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Test; - -use Symfony\Component\VarDumper\Cloner\VarCloner; -use Symfony\Component\VarDumper\Dumper\CliDumper; - -/** - * @author Nicolas Grekas - * - * @deprecated since version 2.8, to be removed in 3.0. Use the VarDumperTestTrait instead. - */ -abstract class VarDumperTestCase extends \PHPUnit_Framework_TestCase -{ - public function assertDumpEquals($dump, $data, $message = '') - { - $this->assertSame(rtrim($dump), $this->getDump($data), $message); - } - - public function assertDumpMatchesFormat($dump, $data, $message = '') - { - $this->assertStringMatchesFormat(rtrim($dump), $this->getDump($data), $message); - } - - protected function getDump($data) - { - $h = fopen('php://memory', 'r+b'); - $cloner = new VarCloner(); - $dumper = new CliDumper($h); - $dumper->setColors(false); - $dumper->dump($cloner->cloneVar($data)->withRefHandles(false)); - $data = stream_get_contents($h, -1, 0); - fclose($h); - - return rtrim($data); - } -} diff --git a/src/Symfony/Component/VarDumper/Tests/Caster/CasterTest.php b/src/Symfony/Component/VarDumper/Tests/Caster/CasterTest.php index 2c42a906600dc..43d389ce1c009 100644 --- a/src/Symfony/Component/VarDumper/Tests/Caster/CasterTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Caster/CasterTest.php @@ -12,13 +12,15 @@ namespace Symfony\Component\VarDumper\Tests\Caster; use Symfony\Component\VarDumper\Caster\Caster; -use Symfony\Component\VarDumper\Test\VarDumperTestCase; +use Symfony\Component\VarDumper\Test\VarDumperTestTrait; /** * @author Nicolas Grekas */ -class CasterTest extends VarDumperTestCase +class CasterTest extends \PHPUnit_Framework_TestCase { + use VarDumperTestTrait; + private $referenceArray = array( 'null' => null, 'empty' => false, diff --git a/src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php b/src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php index dcbbb17898837..75333d892751c 100644 --- a/src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php @@ -11,14 +11,16 @@ namespace Symfony\Component\VarDumper\Tests\Caster; -use Symfony\Component\VarDumper\Test\VarDumperTestCase; +use Symfony\Component\VarDumper\Test\VarDumperTestTrait; use Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo; /** * @author Nicolas Grekas */ -class ReflectionCasterTest extends VarDumperTestCase +class ReflectionCasterTest extends \PHPUnit_Framework_TestCase { + use VarDumperTestTrait; + public function testReflectionCaster() { $var = new \ReflectionClass('ReflectionClass'); diff --git a/src/Symfony/Component/VarDumper/Tests/Caster/SplCasterTest.php b/src/Symfony/Component/VarDumper/Tests/Caster/SplCasterTest.php index e2a8c48fb6376..5d71e8d379dcf 100644 --- a/src/Symfony/Component/VarDumper/Tests/Caster/SplCasterTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Caster/SplCasterTest.php @@ -11,13 +11,15 @@ namespace Symfony\Component\VarDumper\Tests\Caster; -use Symfony\Component\VarDumper\Test\VarDumperTestCase; +use Symfony\Component\VarDumper\Test\VarDumperTestTrait; /** * @author Grégoire Pineau */ -class SplCasterTest extends VarDumperTestCase +class SplCasterTest extends \PHPUnit_Framework_TestCase { + use VarDumperTestTrait; + public function getCastFileInfoTests() { return array( diff --git a/src/Symfony/Component/VarDumper/Tests/CliDumperTest.php b/src/Symfony/Component/VarDumper/Tests/CliDumperTest.php index 5e70aea09fbe3..cd6d64d1c0368 100644 --- a/src/Symfony/Component/VarDumper/Tests/CliDumperTest.php +++ b/src/Symfony/Component/VarDumper/Tests/CliDumperTest.php @@ -13,13 +13,15 @@ use Symfony\Component\VarDumper\Cloner\VarCloner; use Symfony\Component\VarDumper\Dumper\CliDumper; -use Symfony\Component\VarDumper\Test\VarDumperTestCase; +use Symfony\Component\VarDumper\Test\VarDumperTestTrait; /** * @author Nicolas Grekas */ -class CliDumperTest extends VarDumperTestCase +class CliDumperTest extends \PHPUnit_Framework_TestCase { + use VarDumperTestTrait; + public function testGet() { require __DIR__.'/Fixtures/dumb-var.php'; diff --git a/src/Symfony/Component/VarDumper/Tests/Test/VarDumpTestTraitRequire54.php b/src/Symfony/Component/VarDumper/Tests/Test/VarDumpTestTraitRequire54.php deleted file mode 100644 index 240cc926aaccc..0000000000000 --- a/src/Symfony/Component/VarDumper/Tests/Test/VarDumpTestTraitRequire54.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Tests\Test; - -use Symfony\Component\VarDumper\Test\VarDumperTestCase; -use Symfony\Component\VarDumper\Test\VarDumperTestTrait; - -class VarDumperTestTraitTest extends VarDumperTestCase -{ - use VarDumperTestTrait; - - public function testItComparesLargeData() - { - $howMany = 700; - $data = array_fill_keys(range(0, $howMany), array('a', 'b', 'c', 'd')); - - $expected = sprintf("array:%d [\n", $howMany + 1); - for ($i = 0; $i <= $howMany; ++$i) { - $expected .= << array:4 [ - 0 => "a" - 1 => "b" - 2 => "c" - 3 => "d" - ]\n -EODUMP; - } - $expected .= "]\n"; - - $this->assertDumpEquals($expected, $data); - } -} diff --git a/src/Symfony/Component/VarDumper/Tests/Test/VarDumpTestTraitTest.php b/src/Symfony/Component/VarDumper/Tests/Test/VarDumpTestTraitTest.php index 21ef14d9ff4bc..3295797179c48 100644 --- a/src/Symfony/Component/VarDumper/Tests/Test/VarDumpTestTraitTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Test/VarDumpTestTraitTest.php @@ -9,8 +9,32 @@ * file that was distributed with this source code. */ -// Skipping trait tests for PHP < 5.4 -if (version_compare(PHP_VERSION, '5.4.0-dev', '>=')) { - require 'VarDumpTestTraitRequire54.php'; -} +namespace Symfony\Component\VarDumper\Tests\Test; + +use Symfony\Component\VarDumper\Test\VarDumperTestTrait; + +class VarDumperTestTraitTest extends \PHPUnit_Framework_TestCase +{ + use VarDumperTestTrait; + public function testItComparesLargeData() + { + $howMany = 700; + $data = array_fill_keys(range(0, $howMany), array('a', 'b', 'c', 'd')); + + $expected = sprintf("array:%d [\n", $howMany + 1); + for ($i = 0; $i <= $howMany; ++$i) { + $expected .= << array:4 [ + 0 => "a" + 1 => "b" + 2 => "c" + 3 => "d" + ]\n +EODUMP; + } + $expected .= "]\n"; + + $this->assertDumpEquals($expected, $data); + } +} From f75a940881c07bca98671cf45b527abe7b522aa9 Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Wed, 4 Nov 2015 19:13:46 +0100 Subject: [PATCH 5/5] [VarDumper] fix filename --- .../Component/VarDumper/Tests/Caster/ReflectionCasterTest.php | 4 ++-- .../{VarDumpTestTraitTest.php => VarDumperTestTraitTest.php} | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename src/Symfony/Component/VarDumper/Tests/Test/{VarDumpTestTraitTest.php => VarDumperTestTraitTest.php} (100%) diff --git a/src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php b/src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php index 75333d892751c..6525eaef2e885 100644 --- a/src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php @@ -75,7 +75,7 @@ public function testClosureCaster() \$b: & 123 } file: "%sReflectionCasterTest.php" - line: "63 to 63" + line: "65 to 65" } EOTXT , $var @@ -95,7 +95,7 @@ public function testReturnType() returnType: "int" class: "Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest" this: Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest { …} - file: "%sReflectionCasterTest.php(88) : eval()'d code" + file: "%sReflectionCasterTest.php(90) : eval()'d code" line: "1 to 1" } EOTXT diff --git a/src/Symfony/Component/VarDumper/Tests/Test/VarDumpTestTraitTest.php b/src/Symfony/Component/VarDumper/Tests/Test/VarDumperTestTraitTest.php similarity index 100% rename from src/Symfony/Component/VarDumper/Tests/Test/VarDumpTestTraitTest.php rename to src/Symfony/Component/VarDumper/Tests/Test/VarDumperTestTraitTest.php