This commit is contained in:
Fabien Potencier 2018-05-11 17:58:37 +02:00 committed by Nicolas Grekas
parent 10a2d39365
commit ba5cb1a245
25 changed files with 96 additions and 88 deletions

View File

@ -11,7 +11,6 @@
namespace Symfony\Bridge\PhpUnit\Legacy; namespace Symfony\Bridge\PhpUnit\Legacy;
use PHPUnit\Framework\Test;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Warning; use PHPUnit\Framework\Warning;

View File

@ -15,7 +15,7 @@ while (!file_exists($vendor.'/vendor')) {
define('PHPUNIT_COMPOSER_INSTALL', $vendor.'/vendor/autoload.php'); define('PHPUNIT_COMPOSER_INSTALL', $vendor.'/vendor/autoload.php');
require PHPUNIT_COMPOSER_INSTALL; require PHPUNIT_COMPOSER_INSTALL;
require_once __DIR__.'/../../bootstrap.php'; require_once __DIR__.'/../../bootstrap.php';
eval("@trigger_error('who knows where I come from?', E_USER_DEPRECATED);") eval("@trigger_error('who knows where I come from?', E_USER_DEPRECATED);");
?> ?>
--EXPECTF-- --EXPECTF--

View File

@ -20,7 +20,7 @@ class Scope
private $data = array(); private $data = array();
private $left = false; private $left = false;
public function __construct(Scope $parent = null) public function __construct(self $parent = null)
{ {
$this->parent = $parent; $this->parent = $parent;
} }

View File

@ -12,7 +12,6 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\Controller; namespace Symfony\Bundle\FrameworkBundle\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\File\File;
class ControllerTest extends ControllerTraitTest class ControllerTest extends ControllerTraitTest
{ {

View File

@ -122,30 +122,30 @@ class CacheDataCollector extends DataCollector implements LateDataCollectorInter
); );
/** @var TraceableAdapterEvent $call */ /** @var TraceableAdapterEvent $call */
foreach ($calls as $call) { foreach ($calls as $call) {
$statistics[$name]['calls'] += 1; ++$statistics[$name]['calls'];
$statistics[$name]['time'] += $call->end - $call->start; $statistics[$name]['time'] += $call->end - $call->start;
if ('getItem' === $call->name) { if ('getItem' === $call->name) {
$statistics[$name]['reads'] += 1; ++$statistics[$name]['reads'];
if ($call->hits) { if ($call->hits) {
$statistics[$name]['hits'] += 1; ++$statistics[$name]['hits'];
} else { } else {
$statistics[$name]['misses'] += 1; ++$statistics[$name]['misses'];
} }
} elseif ('getItems' === $call->name) { } elseif ('getItems' === $call->name) {
$statistics[$name]['reads'] += $call->hits + $call->misses; $statistics[$name]['reads'] += $call->hits + $call->misses;
$statistics[$name]['hits'] += $call->hits; $statistics[$name]['hits'] += $call->hits;
$statistics[$name]['misses'] += $call->misses; $statistics[$name]['misses'] += $call->misses;
} elseif ('hasItem' === $call->name) { } elseif ('hasItem' === $call->name) {
$statistics[$name]['reads'] += 1; ++$statistics[$name]['reads'];
if (false === $call->result) { if (false === $call->result) {
$statistics[$name]['misses'] += 1; ++$statistics[$name]['misses'];
} else { } else {
$statistics[$name]['hits'] += 1; ++$statistics[$name]['hits'];
} }
} elseif ('save' === $call->name) { } elseif ('save' === $call->name) {
$statistics[$name]['writes'] += 1; ++$statistics[$name]['writes'];
} elseif ('deleteItem' === $call->name) { } elseif ('deleteItem' === $call->name) {
$statistics[$name]['deletes'] += 1; ++$statistics[$name]['deletes'];
} }
} }
if ($statistics[$name]['reads']) { if ($statistics[$name]['reads']) {

View File

@ -48,7 +48,7 @@ class Specificity
/** /**
* @return self * @return self
*/ */
public function plus(Specificity $specificity) public function plus(self $specificity)
{ {
return new self($this->a + $specificity->a, $this->b + $specificity->b, $this->c + $specificity->c); return new self($this->a + $specificity->a, $this->b + $specificity->b, $this->c + $specificity->c);
} }
@ -69,7 +69,7 @@ class Specificity
* *
* @return int * @return int
*/ */
public function compareTo(Specificity $specificity) public function compareTo(self $specificity)
{ {
if ($this->a !== $specificity->a) { if ($this->a !== $specificity->a) {
return $this->a > $specificity->a ? 1 : -1; return $this->a > $specificity->a ? 1 : -1;

View File

@ -53,8 +53,6 @@ class XPathExpr
} }
/** /**
* @param $condition
*
* @return $this * @return $this
*/ */
public function addCondition($condition) public function addCondition($condition)

View File

@ -157,7 +157,7 @@ class FlattenException
return $this->previous; return $this->previous;
} }
public function setPrevious(FlattenException $previous) public function setPrevious(self $previous)
{ {
$this->previous = $previous; $this->previous = $previous;
} }

View File

@ -34,7 +34,7 @@ class InstanceofConfigurator extends AbstractServiceConfigurator
* *
* @param string $fqcn * @param string $fqcn
* *
* @return InstanceofConfigurator * @return self
*/ */
final protected function setInstanceof($fqcn) final protected function setInstanceof($fqcn)
{ {

View File

@ -51,7 +51,7 @@ class FormView implements \ArrayAccess, \IteratorAggregate, \Countable
private $methodRendered = false; private $methodRendered = false;
public function __construct(FormView $parent = null) public function __construct(self $parent = null)
{ {
$this->parent = $parent; $this->parent = $parent;
} }

View File

@ -11,6 +11,15 @@
namespace Symfony\Component\Form\Tests; namespace Symfony\Component\Form\Tests;
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
use Symfony\Component\Form\Extension\Core\Type\PercentType;
use Symfony\Component\Form\Extension\Core\Type\RadioType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormError; use Symfony\Component\Form\FormError;
/** /**
@ -22,7 +31,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
{ {
public function testRow() public function testRow()
{ {
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType'); $form = $this->factory->createNamed('name', TextType::class);
$form->addError(new FormError('[trans]Error![/trans]')); $form->addError(new FormError('[trans]Error![/trans]'));
$view = $form->createView(); $view = $form->createView();
$html = $this->renderRow($view); $html = $this->renderRow($view);
@ -47,7 +56,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
public function testLabelOnForm() public function testLabelOnForm()
{ {
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType'); $form = $this->factory->createNamed('name', DateType::class);
$view = $form->createView(); $view = $form->createView();
$this->renderWidget($view, array('label' => 'foo')); $this->renderWidget($view, array('label' => 'foo'));
$html = $this->renderLabel($view); $html = $this->renderLabel($view);
@ -62,7 +71,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
public function testLabelDoesNotRenderFieldAttributes() public function testLabelDoesNotRenderFieldAttributes()
{ {
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType'); $form = $this->factory->createNamed('name', TextType::class);
$html = $this->renderLabel($form->createView(), null, array( $html = $this->renderLabel($form->createView(), null, array(
'attr' => array( 'attr' => array(
'class' => 'my&class', 'class' => 'my&class',
@ -79,7 +88,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
public function testLabelWithCustomAttributesPassedDirectly() public function testLabelWithCustomAttributesPassedDirectly()
{ {
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType'); $form = $this->factory->createNamed('name', TextType::class);
$html = $this->renderLabel($form->createView(), null, array( $html = $this->renderLabel($form->createView(), null, array(
'label_attr' => array( 'label_attr' => array(
'class' => 'my&class', 'class' => 'my&class',
@ -96,7 +105,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
public function testLabelWithCustomTextAndCustomAttributesPassedDirectly() public function testLabelWithCustomTextAndCustomAttributesPassedDirectly()
{ {
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType'); $form = $this->factory->createNamed('name', TextType::class);
$html = $this->renderLabel($form->createView(), 'Custom label', array( $html = $this->renderLabel($form->createView(), 'Custom label', array(
'label_attr' => array( 'label_attr' => array(
'class' => 'my&class', 'class' => 'my&class',
@ -114,7 +123,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
public function testLabelWithCustomTextAsOptionAndCustomAttributesPassedDirectly() public function testLabelWithCustomTextAsOptionAndCustomAttributesPassedDirectly()
{ {
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array( $form = $this->factory->createNamed('name', TextType::class, null, array(
'label' => 'Custom label', 'label' => 'Custom label',
)); ));
$html = $this->renderLabel($form->createView(), null, array( $html = $this->renderLabel($form->createView(), null, array(
@ -134,7 +143,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
public function testLegendOnExpandedType() public function testLegendOnExpandedType()
{ {
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', null, array( $form = $this->factory->createNamed('name', ChoiceType::class, null, array(
'label' => 'Custom label', 'label' => 'Custom label',
'expanded' => true, 'expanded' => true,
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
@ -153,7 +162,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
public function testErrors() public function testErrors()
{ {
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType'); $form = $this->factory->createNamed('name', TextType::class);
$form->addError(new FormError('[trans]Error 1[/trans]')); $form->addError(new FormError('[trans]Error 1[/trans]'));
$form->addError(new FormError('[trans]Error 2[/trans]')); $form->addError(new FormError('[trans]Error 2[/trans]'));
$view = $form->createView(); $view = $form->createView();
@ -178,7 +187,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
public function testErrorWithNoLabel() public function testErrorWithNoLabel()
{ {
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', array('label'=>false)); $form = $this->factory->createNamed('name', TextType::class, array('label' => false));
$form->addError(new FormError('[trans]Error 1[/trans]')); $form->addError(new FormError('[trans]Error 1[/trans]'));
$view = $form->createView(); $view = $form->createView();
$html = $this->renderLabel($view); $html = $this->renderLabel($view);
@ -188,7 +197,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
public function testCheckedCheckbox() public function testCheckedCheckbox()
{ {
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CheckboxType', true); $form = $this->factory->createNamed('name', CheckboxType::class, true);
$this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')), $this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')),
'/div '/div
@ -205,7 +214,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
public function testSingleChoiceAttributesWithMainAttributes() public function testSingleChoiceAttributesWithMainAttributes()
{ {
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( $form = $this->factory->createNamed('name', ChoiceType::class, '&a', array(
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
'multiple' => false, 'multiple' => false,
'expanded' => false, 'expanded' => false,
@ -228,7 +237,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
public function testSingleExpandedChoiceAttributesWithMainAttributes() public function testSingleExpandedChoiceAttributesWithMainAttributes()
{ {
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( $form = $this->factory->createNamed('name', ChoiceType::class, '&a', array(
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
'multiple' => false, 'multiple' => false,
'expanded' => true, 'expanded' => true,
@ -261,7 +270,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
public function testUncheckedCheckbox() public function testUncheckedCheckbox()
{ {
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CheckboxType', false); $form = $this->factory->createNamed('name', CheckboxType::class, false);
$this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')), $this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')),
'/div '/div
@ -277,7 +286,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
public function testCheckboxWithValue() public function testCheckboxWithValue()
{ {
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CheckboxType', false, array( $form = $this->factory->createNamed('name', CheckboxType::class, false, array(
'value' => 'foo&bar', 'value' => 'foo&bar',
)); ));
@ -295,7 +304,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
public function testSingleChoiceExpanded() public function testSingleChoiceExpanded()
{ {
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( $form = $this->factory->createNamed('name', ChoiceType::class, '&a', array(
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
'multiple' => false, 'multiple' => false,
'expanded' => true, 'expanded' => true,
@ -326,7 +335,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
public function testSingleChoiceExpandedWithLabelsAsFalse() public function testSingleChoiceExpandedWithLabelsAsFalse()
{ {
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( $form = $this->factory->createNamed('name', ChoiceType::class, '&a', array(
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
'choice_label' => false, 'choice_label' => false,
'multiple' => false, 'multiple' => false,
@ -356,7 +365,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
public function testSingleChoiceExpandedWithLabelsSetByCallable() public function testSingleChoiceExpandedWithLabelsSetByCallable()
{ {
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( $form = $this->factory->createNamed('name', ChoiceType::class, '&a', array(
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b', 'Choice&C' => '&c'), 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b', 'Choice&C' => '&c'),
'choice_label' => function ($choice, $label, $value) { 'choice_label' => function ($choice, $label, $value) {
if ('&b' === $choice) { if ('&b' === $choice) {
@ -400,7 +409,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
public function testSingleChoiceExpandedWithLabelsSetFalseByCallable() public function testSingleChoiceExpandedWithLabelsSetFalseByCallable()
{ {
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( $form = $this->factory->createNamed('name', ChoiceType::class, '&a', array(
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
'choice_label' => function () { 'choice_label' => function () {
return false; return false;
@ -432,7 +441,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
public function testSingleChoiceExpandedWithoutTranslation() public function testSingleChoiceExpandedWithoutTranslation()
{ {
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( $form = $this->factory->createNamed('name', ChoiceType::class, '&a', array(
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
'multiple' => false, 'multiple' => false,
'expanded' => true, 'expanded' => true,
@ -464,7 +473,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
public function testSingleChoiceExpandedAttributes() public function testSingleChoiceExpandedAttributes()
{ {
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( $form = $this->factory->createNamed('name', ChoiceType::class, '&a', array(
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')), 'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')),
'multiple' => false, 'multiple' => false,
@ -496,7 +505,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
public function testSingleChoiceExpandedWithPlaceholder() public function testSingleChoiceExpandedWithPlaceholder()
{ {
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( $form = $this->factory->createNamed('name', ChoiceType::class, '&a', array(
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
'multiple' => false, 'multiple' => false,
'expanded' => true, 'expanded' => true,
@ -536,7 +545,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
public function testSingleChoiceExpandedWithPlaceholderWithoutTranslation() public function testSingleChoiceExpandedWithPlaceholderWithoutTranslation()
{ {
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', array( $form = $this->factory->createNamed('name', ChoiceType::class, '&a', array(
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
'multiple' => false, 'multiple' => false,
'expanded' => true, 'expanded' => true,
@ -577,7 +586,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
public function testSingleChoiceExpandedWithBooleanValue() public function testSingleChoiceExpandedWithBooleanValue()
{ {
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', true, array( $form = $this->factory->createNamed('name', ChoiceType::class, true, array(
'choices' => array('Choice&A' => '1', 'Choice&B' => '0'), 'choices' => array('Choice&A' => '1', 'Choice&B' => '0'),
'multiple' => false, 'multiple' => false,
'expanded' => true, 'expanded' => true,
@ -608,7 +617,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
public function testMultipleChoiceExpanded() public function testMultipleChoiceExpanded()
{ {
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a', '&c'), array( $form = $this->factory->createNamed('name', ChoiceType::class, array('&a', '&c'), array(
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b', 'Choice&C' => '&c'), 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b', 'Choice&C' => '&c'),
'multiple' => true, 'multiple' => true,
'expanded' => true, 'expanded' => true,
@ -647,7 +656,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
public function testMultipleChoiceExpandedWithLabelsAsFalse() public function testMultipleChoiceExpandedWithLabelsAsFalse()
{ {
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a'), array( $form = $this->factory->createNamed('name', ChoiceType::class, array('&a'), array(
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
'choice_label' => false, 'choice_label' => false,
'multiple' => true, 'multiple' => true,
@ -677,7 +686,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
public function testMultipleChoiceExpandedWithLabelsSetByCallable() public function testMultipleChoiceExpandedWithLabelsSetByCallable()
{ {
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a'), array( $form = $this->factory->createNamed('name', ChoiceType::class, array('&a'), array(
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b', 'Choice&C' => '&c'), 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b', 'Choice&C' => '&c'),
'choice_label' => function ($choice, $label, $value) { 'choice_label' => function ($choice, $label, $value) {
if ('&b' === $choice) { if ('&b' === $choice) {
@ -721,7 +730,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
public function testMultipleChoiceExpandedWithLabelsSetFalseByCallable() public function testMultipleChoiceExpandedWithLabelsSetFalseByCallable()
{ {
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a'), array( $form = $this->factory->createNamed('name', ChoiceType::class, array('&a'), array(
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'), 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
'choice_label' => function () { 'choice_label' => function () {
return false; return false;
@ -753,7 +762,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
public function testMultipleChoiceExpandedWithoutTranslation() public function testMultipleChoiceExpandedWithoutTranslation()
{ {
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a', '&c'), array( $form = $this->factory->createNamed('name', ChoiceType::class, array('&a', '&c'), array(
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b', 'Choice&C' => '&c'), 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b', 'Choice&C' => '&c'),
'multiple' => true, 'multiple' => true,
'expanded' => true, 'expanded' => true,
@ -793,7 +802,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
public function testMultipleChoiceExpandedAttributes() public function testMultipleChoiceExpandedAttributes()
{ {
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('&a', '&c'), array( $form = $this->factory->createNamed('name', ChoiceType::class, array('&a', '&c'), array(
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b', 'Choice&C' => '&c'), 'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b', 'Choice&C' => '&c'),
'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')), 'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')),
'multiple' => true, 'multiple' => true,
@ -833,7 +842,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
public function testCheckedRadio() public function testCheckedRadio()
{ {
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RadioType', true); $form = $this->factory->createNamed('name', RadioType::class, true);
$this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')), $this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')),
'/div '/div
@ -855,7 +864,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
public function testUncheckedRadio() public function testUncheckedRadio()
{ {
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RadioType', false); $form = $this->factory->createNamed('name', RadioType::class, false);
$this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')), $this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')),
'/div '/div
@ -876,7 +885,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
public function testRadioWithValue() public function testRadioWithValue()
{ {
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RadioType', false, array( $form = $this->factory->createNamed('name', RadioType::class, false, array(
'value' => 'foo&bar', 'value' => 'foo&bar',
)); ));
@ -900,7 +909,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
public function testButtonAttributeNameRepeatedIfTrue() public function testButtonAttributeNameRepeatedIfTrue()
{ {
$form = $this->factory->createNamed('button', 'Symfony\Component\Form\Extension\Core\Type\ButtonType', null, array( $form = $this->factory->createNamed('button', ButtonType::class, null, array(
'attr' => array('foo' => true), 'attr' => array('foo' => true),
)); ));
@ -912,7 +921,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
public function testFile() public function testFile()
{ {
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\FileType'); $form = $this->factory->createNamed('name', FileType::class);
$this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class form-control-file')), $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class form-control-file')),
'/input '/input
@ -923,7 +932,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
public function testMoney() public function testMoney()
{ {
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\MoneyType', 1234.56, array( $form = $this->factory->createNamed('name', MoneyType::class, 1234.56, array(
'currency' => 'EUR', 'currency' => 'EUR',
)); ));
@ -951,7 +960,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
public function testPercent() public function testPercent()
{ {
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\PercentType', 0.1); $form = $this->factory->createNamed('name', PercentType::class, 0.1);
$this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')), $this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')),
'/div '/div

View File

@ -58,7 +58,7 @@ final class ArgumentMetadataFactory implements ArgumentMetadataFactoryInterface
} }
foreach ($reflection->getParameters() as $param) { foreach ($reflection->getParameters() as $param) {
$arguments[] = new ArgumentMetadata($param->getName(), $this->getType($param), $this->isVariadic($param), $this->hasDefaultValue($param), $this->getDefaultValue($param), $param->allowsNull()); $arguments[] = new ArgumentMetadata($param->getName(), $this->getType($param, $reflection), $this->isVariadic($param), $this->hasDefaultValue($param), $this->getDefaultValue($param), $param->allowsNull());
} }
return $arguments; return $arguments;
@ -107,23 +107,35 @@ final class ArgumentMetadataFactory implements ArgumentMetadataFactoryInterface
* *
* @return null|string * @return null|string
*/ */
private function getType(\ReflectionParameter $parameter) private function getType(\ReflectionParameter $parameter, \ReflectionFunctionAbstract $function)
{ {
if ($this->supportsParameterType) { if ($this->supportsParameterType) {
if (!$type = $parameter->getType()) { if (!$type = $parameter->getType()) {
return; return;
} }
$typeName = $type instanceof \ReflectionNamedType ? $type->getName() : $type->__toString(); $name = $type instanceof \ReflectionNamedType ? $type->getName() : $type->__toString();
if ('array' === $typeName && !$type->isBuiltin()) { if ('array' === $name && !$type->isBuiltin()) {
// Special case for HHVM with variadics // Special case for HHVM with variadics
return; return;
} }
} elseif (preg_match('/^(?:[^ ]++ ){4}([a-zA-Z_\x7F-\xFF][^ ]++)/', $parameter, $name)) {
return $typeName; $name = $name[1];
} else {
return;
} }
$lcName = strtolower($name);
if (preg_match('/^(?:[^ ]++ ){4}([a-zA-Z_\x7F-\xFF][^ ]++)/', $parameter, $info)) { if ('self' !== $lcName && 'parent' !== $lcName) {
return $info[1]; return $name;
}
if (!$function instanceof \ReflectionMethod) {
return;
}
if ('self' === $lcName) {
return $function->getDeclaringClass()->name;
}
if ($parent = $function->getDeclaringClass()->getParentClass()) {
return $parent->name;
} }
} }
} }

View File

@ -126,11 +126,11 @@ class ArgumentMetadataFactoryTest extends TestCase
), $arguments); ), $arguments);
} }
private function signature1(ArgumentMetadataFactoryTest $foo, array $bar, callable $baz) private function signature1(self $foo, array $bar, callable $baz)
{ {
} }
private function signature2(ArgumentMetadataFactoryTest $foo = null, FakeClassThatDoesNotExist $bar = null, ImportedAndFake $baz = null) private function signature2(self $foo = null, FakeClassThatDoesNotExist $bar = null, ImportedAndFake $baz = null)
{ {
} }

View File

@ -44,7 +44,7 @@ class ProfilerTest extends TestCase
public function testReset() public function testReset()
{ {
$collector = $this->getMockBuilder(DataCollectorInterface::class) $collector = $this->getMockBuilder(DataCollectorInterface::class)
->setMethods(['collect', 'getName', 'reset']) ->setMethods(array('collect', 'getName', 'reset'))
->getMock(); ->getMock();
$collector->expects($this->any())->method('getName')->willReturn('mock'); $collector->expects($this->any())->method('getName')->willReturn('mock');
$collector->expects($this->once())->method('reset'); $collector->expects($this->once())->method('reset');

View File

@ -29,7 +29,7 @@ class ParentDummy
public $foo2; public $foo2;
/** /**
* @var callback * @var callable
*/ */
public $foo3; public $foo3;

View File

@ -61,12 +61,10 @@ class Type
* @param bool $nullable * @param bool $nullable
* @param string|null $class * @param string|null $class
* @param bool $collection * @param bool $collection
* @param Type|null $collectionKeyType
* @param Type|null $collectionValueType
* *
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*/ */
public function __construct($builtinType, $nullable = false, $class = null, $collection = false, Type $collectionKeyType = null, Type $collectionValueType = null) public function __construct($builtinType, $nullable = false, $class = null, $collection = false, self $collectionKeyType = null, self $collectionValueType = null)
{ {
if (!in_array($builtinType, self::$builtinTypes)) { if (!in_array($builtinType, self::$builtinTypes)) {
throw new \InvalidArgumentException(sprintf('"%s" is not a valid PHP type.', $builtinType)); throw new \InvalidArgumentException(sprintf('"%s" is not a valid PHP type.', $builtinType));

View File

@ -106,7 +106,7 @@ class DumperCollection implements \IteratorAggregate
/** /**
* Sets the parent collection. * Sets the parent collection.
*/ */
protected function setParent(DumperCollection $parent) protected function setParent(self $parent)
{ {
$this->parent = $parent; $this->parent = $parent;
} }

View File

@ -118,7 +118,7 @@ class RouteCollectionBuilder
* @param string $prefix * @param string $prefix
* @param RouteCollectionBuilder $builder * @param RouteCollectionBuilder $builder
*/ */
public function mount($prefix, RouteCollectionBuilder $builder) public function mount($prefix, self $builder)
{ {
$builder->prefix = trim(trim($prefix), '/'); $builder->prefix = trim(trim($prefix), '/');
$this->routes[] = $builder; $this->routes[] = $builder;
@ -251,8 +251,6 @@ class RouteCollectionBuilder
/** /**
* Adds a resource for this collection. * Adds a resource for this collection.
* *
* @param ResourceInterface $resource
*
* @return $this * @return $this
*/ */
private function addResource(ResourceInterface $resource) private function addResource(ResourceInterface $resource)

View File

@ -46,12 +46,8 @@ class ContextListener implements ListenerInterface
private $logoutOnUserChange = false; private $logoutOnUserChange = false;
/** /**
* @param TokenStorageInterface $tokenStorage
* @param iterable|UserProviderInterface[] $userProviders * @param iterable|UserProviderInterface[] $userProviders
* @param string $contextKey * @param string $contextKey
* @param LoggerInterface|null $logger
* @param EventDispatcherInterface|null $dispatcher
* @param AuthenticationTrustResolverInterface|null $trustResolver
*/ */
public function __construct(TokenStorageInterface $tokenStorage, $userProviders, $contextKey, LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null, AuthenticationTrustResolverInterface $trustResolver = null) public function __construct(TokenStorageInterface $tokenStorage, $userProviders, $contextKey, LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null, AuthenticationTrustResolverInterface $trustResolver = null)
{ {

View File

@ -60,5 +60,5 @@ interface AttributeMetadataInterface
/** /**
* Merges an {@see AttributeMetadataInterface} with in the current one. * Merges an {@see AttributeMetadataInterface} with in the current one.
*/ */
public function merge(AttributeMetadataInterface $attributeMetadata); public function merge(self $attributeMetadata);
} }

View File

@ -46,7 +46,7 @@ interface ClassMetadataInterface
/** /**
* Merges a {@link ClassMetadataInterface} in the current one. * Merges a {@link ClassMetadataInterface} in the current one.
*/ */
public function merge(ClassMetadataInterface $classMetadata); public function merge(self $classMetadata);
/** /**
* Returns a {@link \ReflectionClass} instance for this class. * Returns a {@link \ReflectionClass} instance for this class.

View File

@ -301,7 +301,6 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
/** /**
* Sets an attribute and apply the name converter if necessary. * Sets an attribute and apply the name converter if necessary.
* *
* @param array $data
* @param string $attribute * @param string $attribute
* @param mixed $attributeValue * @param mixed $attributeValue
* *

View File

@ -105,7 +105,7 @@ interface MessageCatalogueInterface
* *
* The two catalogues must have the same locale. * The two catalogues must have the same locale.
*/ */
public function addCatalogue(MessageCatalogueInterface $catalogue); public function addCatalogue(self $catalogue);
/** /**
* Merges translations from the given Catalogue into the current one * Merges translations from the given Catalogue into the current one
@ -113,7 +113,7 @@ interface MessageCatalogueInterface
* *
* This is used to provide default translations when they do not exist for the current locale. * This is used to provide default translations when they do not exist for the current locale.
*/ */
public function addFallbackCatalogue(MessageCatalogueInterface $catalogue); public function addFallbackCatalogue(self $catalogue);
/** /**
* Gets the fallback catalogue. * Gets the fallback catalogue.

View File

@ -335,7 +335,7 @@ class ClassMetadata extends GenericMetadata implements ClassMetadataInterface
/** /**
* Merges the constraints of the given metadata into this object. * Merges the constraints of the given metadata into this object.
*/ */
public function mergeConstraints(ClassMetadata $source) public function mergeConstraints(self $source)
{ {
if ($source->isGroupSequenceProvider()) { if ($source->isGroupSequenceProvider()) {
$this->setGroupSequenceProvider(true); $this->setGroupSequenceProvider(true);