bug #27281 [HttpKernel] Fix dealing with self/parent in ArgumentMetadataFactory (fabpot)

This PR was merged into the 3.4 branch.

Discussion
----------

[HttpKernel] Fix dealing with self/parent in ArgumentMetadataFactory

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Applies CS fixes that where merged on 4.0 to 3.4, embeds a fix in ArgumentMetadataFactory, which couldn't deal with self/parent type hints.

Commits
-------

ba5cb1a245 fixed CS
This commit is contained in:
Nicolas Grekas 2018-05-16 16:03:39 +02:00
commit 2a10cc6047
25 changed files with 96 additions and 88 deletions

View File

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

View File

@ -15,7 +15,7 @@ while (!file_exists($vendor.'/vendor')) {
define('PHPUNIT_COMPOSER_INSTALL', $vendor.'/vendor/autoload.php');
require PHPUNIT_COMPOSER_INSTALL;
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--

View File

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

View File

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

View File

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

View File

@ -48,7 +48,7 @@ class Specificity
/**
* @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);
}
@ -69,7 +69,7 @@ class Specificity
*
* @return int
*/
public function compareTo(Specificity $specificity)
public function compareTo(self $specificity)
{
if ($this->a !== $specificity->a) {
return $this->a > $specificity->a ? 1 : -1;

View File

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

View File

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

View File

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

View File

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

View File

@ -11,6 +11,15 @@
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;
/**
@ -22,7 +31,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
{
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]'));
$view = $form->createView();
$html = $this->renderRow($view);
@ -47,7 +56,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
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();
$this->renderWidget($view, array('label' => 'foo'));
$html = $this->renderLabel($view);
@ -62,7 +71,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
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(
'attr' => array(
'class' => 'my&class',
@ -79,7 +88,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
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(
'label_attr' => array(
'class' => 'my&class',
@ -96,7 +105,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
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(
'label_attr' => array(
'class' => 'my&class',
@ -114,7 +123,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
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',
));
$html = $this->renderLabel($form->createView(), null, array(
@ -134,7 +143,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
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',
'expanded' => true,
'choices' => array('Choice&A' => '&a', 'Choice&B' => '&b'),
@ -153,7 +162,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
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 2[/trans]'));
$view = $form->createView();
@ -178,7 +187,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
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]'));
$view = $form->createView();
$html = $this->renderLabel($view);
@ -188,7 +197,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
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')),
'/div
@ -205,7 +214,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
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'),
'multiple' => false,
'expanded' => false,
@ -228,7 +237,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
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'),
'multiple' => false,
'expanded' => true,
@ -261,7 +270,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
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')),
'/div
@ -277,7 +286,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
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',
));
@ -295,7 +304,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
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'),
'multiple' => false,
'expanded' => true,
@ -326,7 +335,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
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'),
'choice_label' => false,
'multiple' => false,
@ -356,7 +365,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
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'),
'choice_label' => function ($choice, $label, $value) {
if ('&b' === $choice) {
@ -400,7 +409,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
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'),
'choice_label' => function () {
return false;
@ -432,7 +441,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
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'),
'multiple' => false,
'expanded' => true,
@ -464,7 +473,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
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'),
'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')),
'multiple' => false,
@ -496,7 +505,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
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'),
'multiple' => false,
'expanded' => true,
@ -536,7 +545,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
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'),
'multiple' => false,
'expanded' => true,
@ -577,7 +586,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
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'),
'multiple' => false,
'expanded' => true,
@ -608,7 +617,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
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'),
'multiple' => true,
'expanded' => true,
@ -647,7 +656,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
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'),
'choice_label' => false,
'multiple' => true,
@ -677,7 +686,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
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'),
'choice_label' => function ($choice, $label, $value) {
if ('&b' === $choice) {
@ -721,7 +730,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
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'),
'choice_label' => function () {
return false;
@ -753,7 +762,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
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'),
'multiple' => true,
'expanded' => true,
@ -793,7 +802,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
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'),
'choice_attr' => array('Choice&B' => array('class' => 'foo&bar')),
'multiple' => true,
@ -833,7 +842,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
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')),
'/div
@ -855,7 +864,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
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')),
'/div
@ -876,7 +885,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
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',
));
@ -900,7 +909,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
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),
));
@ -912,7 +921,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
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')),
'/input
@ -923,7 +932,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
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',
));
@ -951,7 +960,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
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')),
'/div

View File

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

View File

@ -37,7 +37,7 @@ class Profiler
private $enabled = true;
/**
* @param bool $enable The initial enabled state
* @param bool $enable The initial enabled state
*/
public function __construct(ProfilerStorageInterface $storage, LoggerInterface $logger = null, $enable = true)
{

View File

@ -126,11 +126,11 @@ class ArgumentMetadataFactoryTest extends TestCase
), $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()
{
$collector = $this->getMockBuilder(DataCollectorInterface::class)
->setMethods(['collect', 'getName', 'reset'])
->setMethods(array('collect', 'getName', 'reset'))
->getMock();
$collector->expects($this->any())->method('getName')->willReturn('mock');
$collector->expects($this->once())->method('reset');

View File

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

View File

@ -61,12 +61,10 @@ class Type
* @param bool $nullable
* @param string|null $class
* @param bool $collection
* @param Type|null $collectionKeyType
* @param Type|null $collectionValueType
*
* @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)) {
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.
*/
protected function setParent(DumperCollection $parent)
protected function setParent(self $parent)
{
$this->parent = $parent;
}

View File

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

View File

@ -46,12 +46,8 @@ class ContextListener implements ListenerInterface
private $logoutOnUserChange = false;
/**
* @param TokenStorageInterface $tokenStorage
* @param iterable|UserProviderInterface[] $userProviders
* @param string $contextKey
* @param LoggerInterface|null $logger
* @param EventDispatcherInterface|null $dispatcher
* @param AuthenticationTrustResolverInterface|null $trustResolver
* @param iterable|UserProviderInterface[] $userProviders
* @param string $contextKey
*/
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.
*/
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.
*/
public function merge(ClassMetadataInterface $classMetadata);
public function merge(self $classMetadata);
/**
* 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.
*
* @param array $data
* @param string $attribute
* @param mixed $attributeValue
*

View File

@ -105,7 +105,7 @@ interface MessageCatalogueInterface
*
* 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
@ -113,7 +113,7 @@ interface MessageCatalogueInterface
*
* 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.

View File

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