Skip to content

Fix and improve overall PHPDocs #54489

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/Symfony/Bridge/Doctrine/Test/TestRepositoryFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ public function setRepository(EntityManagerInterface $entityManager, string $ent

private function createRepository(EntityManagerInterface $entityManager, string $entityName): ObjectRepository
{
/* @var $metadata ClassMetadata */
$metadata = $entityManager->getClassMetadata($entityName);
$repositoryClassName = $metadata->customRepositoryClassName ?: $entityManager->getConfiguration()->getDefaultRepositoryClassName();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function testCreateProxyServiceWithRuntimeInstantiator()

$builder->compile();

/* @var $foo1 \ProxyManager\Proxy\LazyLoadingInterface|\ProxyManager\Proxy\ValueHolderInterface */
/* @var \ProxyManager\Proxy\LazyLoadingInterface|\ProxyManager\Proxy\ValueHolderInterface $foo1 */
$foo1 = $builder->get('foo1');

$foo1->__destruct();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function testInstantiateProxy()
return $instance;
};

/* @var $proxy LazyLoadingInterface|ValueHolderInterface */
/* @var LazyLoadingInterface|ValueHolderInterface $proxy */
$proxy = $this->instantiator->instantiateProxy($container, $definition, 'foo', $instantiator);

$this->assertInstanceOf(LazyLoadingInterface::class, $proxy);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$copyUsed = false;
$exitCode = 0;
$validAssetDirs = [];
/** @var BundleInterface $bundle */
foreach ($kernel->getBundles() as $bundle) {
if (!is_dir($originDir = $bundle->getPath().'/Resources/public') && !is_dir($originDir = $bundle->getPath().'/public')) {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ public function testFile()
$controller = $this->createController();
$controller->setContainer($container);

/* @var BinaryFileResponse $response */
$response = $controller->file(new File(__FILE__));
$this->assertInstanceOf(BinaryFileResponse::class, $response);
$this->assertSame(200, $response->getStatusCode());
Expand All @@ -270,7 +269,6 @@ public function testFileAsInline()
{
$controller = $this->createController();

/* @var BinaryFileResponse $response */
$response = $controller->file(new File(__FILE__), null, ResponseHeaderBag::DISPOSITION_INLINE);

$this->assertInstanceOf(BinaryFileResponse::class, $response);
Expand Down Expand Up @@ -320,7 +318,6 @@ public function testFileFromPath()
{
$controller = $this->createController();

/* @var BinaryFileResponse $response */
$response = $controller->file(__FILE__);

$this->assertInstanceOf(BinaryFileResponse::class, $response);
Expand All @@ -336,7 +333,6 @@ public function testFileFromPathWithCustomizedFileName()
{
$controller = $this->createController();

/* @var BinaryFileResponse $response */
$response = $controller->file(__FILE__, 'test.php');

$this->assertInstanceOf(BinaryFileResponse::class, $response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function build(ContainerBuilder $container)
{
parent::build($container);

/** @var $extension DependencyInjection\TestExtension */
/** @var DependencyInjection\TestExtension $extension */
$extension = $container->getExtension('test');

if (!$container->getParameterBag() instanceof FrozenParameterBag) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ class AssetNotFoundException extends RuntimeException
private $alternatives;

/**
* @param string $message Exception message to throw
* @param array $alternatives List of similar defined names
* @param int $code Exception code
* @param \Throwable $previous Previous exception used for the exception chaining
* @param string $message Exception message to throw
* @param array $alternatives List of similar defined names
* @param int $code Exception code
* @param ?\Throwable $previous Previous exception used for the exception chaining
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for consistency with other similar changes:

Suggested change
* @param ?\Throwable $previous Previous exception used for the exception chaining
* @param \Throwable|null $previous Previous exception used for the exception chaining

*/
public function __construct(string $message, array $alternatives = [], int $code = 0, ?\Throwable $previous = null)
{
Expand Down
10 changes: 5 additions & 5 deletions src/Symfony/Component/Asset/Packages.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function addPackage(string $name, PackageInterface $package)
/**
* Returns an asset package.
*
* @param string $name The name of the package or null for the default package
* @param string|null $name The name of the package or null for the default package
*
* @return PackageInterface
*
Expand All @@ -77,8 +77,8 @@ public function getPackage(?string $name = null)
/**
* Gets the version to add to public URL.
*
* @param string $path A public path
* @param string $packageName A package name
* @param string $path A public path
* @param string|null $packageName A package name
*
* @return string
*/
Expand All @@ -92,8 +92,8 @@ public function getVersion(string $path, ?string $packageName = null)
*
* Absolute paths (i.e. http://...) are returned unmodified.
*
* @param string $path A public path
* @param string $packageName The name of the asset package to use
* @param string $path A public path
* @param string|null $packageName The name of the asset package to use
*
* @return string A public path which takes into account the base path and URL path
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class StaticVersionStrategy implements VersionStrategyInterface
private $format;

/**
* @param string $version Version number
* @param string $format Url format
* @param string $version Version number
* @param string|null $format Url format
*/
public function __construct(string $version, ?string $format = null)
{
Expand Down
14 changes: 7 additions & 7 deletions src/Symfony/Component/BrowserKit/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ class Request
protected $content;

/**
* @param string $uri The request URI
* @param string $method The HTTP method request
* @param array $parameters The request parameters
* @param array $files An array of uploaded files
* @param array $cookies An array of cookies
* @param array $server An array of server parameters
* @param string $content The raw body data
* @param string $uri The request URI
* @param string $method The HTTP method request
* @param array $parameters The request parameters
* @param array $files An array of uploaded files
* @param array $cookies An array of cookies
* @param array $server An array of server parameters
* @param string|null $content The raw body data
*/
public function __construct(string $uri, string $method, array $parameters = [], array $files = [], array $cookies = [], array $server = [], ?string $content = null)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Cache/Adapter/PhpFilesAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class PhpFilesAdapter extends AbstractAdapter implements PruneableInterface
private static $valuesCache = [];

/**
* @param $appendOnly Set to `true` to gain extra performance when the items stored in this pool never expire.
* Doing so is encouraged because it fits perfectly OPcache's memory model.
* @param bool $appendOnly Set to `true` to gain extra performance when the items stored in this pool never expire.
* Doing so is encouraged because it fits perfectly OPcache's memory model.
*
* @throws CacheException if OPcache is not enabled
*/
Expand Down
6 changes: 3 additions & 3 deletions src/Symfony/Component/Config/Definition/BaseNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ public function setRequired(bool $boolean)
/**
* Sets this node as deprecated.
*
* @param string $package The name of the composer package that is triggering the deprecation
* @param string $version The version of the package that introduced the deprecation
* @param string $message the deprecation message to use
* @param string|null $package The name of the composer package that is triggering the deprecation
* @param string $version The version of the package that introduced the deprecation
* @param string $message the deprecation message to use
*
* You can use %node% and %path% placeholders in your message to display,
* respectively, the node name and its complete path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static function fromString(string $inputStr, int $currentIndex): self
* Create an input based on an COMP_WORDS token list.
*
* @param string[] $tokens the set of split tokens (e.g. COMP_WORDS or argv)
* @param $currentIndex the index of the cursor (e.g. COMP_CWORD)
* @param int $currentIndex the index of the cursor (e.g. COMP_CWORD)
Comment on lines 55 to +56
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intended.

I think we should rather remove all types everywhere if they duplicate the type defined in PHP (which is almost always the case, except for generic types). See #53363 (comment)

But if we do this, we should automate this using Rector or PHP CS Fixer.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an interesting point of view. Are we 100% we want to do this? Rector could definitely do the trick with this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we are :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, I might close this PR in favor of one that removes redundant types as explained by Wouter. Should such PR target 5.4 or 7.1?

*/
public static function fromTokens(array $tokens, int $currentIndex): self
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function __construct($stream, array &$sections, int $verbosity, bool $dec
/**
* Clears previous output for this section.
*
* @param int $lines Number of lines to clear. If null, then the entire output of this section is cleared
* @param int|null $lines Number of lines to clear. If null, then the entire output of this section is cleared
*/
public function clear(?int $lines = null)
{
Expand Down
1 change: 0 additions & 1 deletion src/Symfony/Component/CssSelector/XPath/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ public function cssToXPath(string $cssExpr, string $prefix = 'descendant-or-self
{
$selectors = $this->parseSelectors($cssExpr);

/** @var SelectorNode $selector */
foreach ($selectors as $index => $selector) {
if (null !== $selector->getPseudoElement()) {
throw new ExpressionErrorException('Pseudo-elements are not supported.');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1389,7 +1389,7 @@ public function getAutoconfiguredAttributes(): array
* @param string|true|null $format A sprintf() format returning the replacement for each env var name or
* null to resolve back to the original "%env(VAR)%" format or
* true to resolve to the actual values of the referenced env vars
* @param array &$usedEnvs Env vars found while resolving are added to this array
* @param array|null &$usedEnvs Env vars found while resolving are added to this array
*
* @return mixed The value with env parameters resolved if a string or an array is passed
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class EnvVarProcessor implements EnvVarProcessorInterface
private $loadedVars = [];

/**
* @param EnvVarLoaderInterface[] $loaders
* @param EnvVarLoaderInterface[]|null $loaders
*/
public function __construct(ContainerInterface $container, ?\Traversable $loaders = null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@ public function testAddObjectResource()

$this->assertCount(1, $resources);

/* @var $resource \Symfony\Component\Config\Resource\FileResource */
/* @var \Symfony\Component\Config\Resource\FileResource $resource */
$resource = end($resources);

$this->assertInstanceOf(FileResource::class, $resource);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,9 @@ private function getFileLink(string $file, int $line)
/**
* Formats a file path.
*
* @param string $file An absolute file path
* @param int $line The line number
* @param string $text Use this text for the link rather than the file path
* @param string $file An absolute file path
* @param int $line The line number
* @param string|null $text Use this text for the link rather than the file path
*/
private function formatFile(string $file, int $line, ?string $text = null): string
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ class SerializerErrorRenderer implements ErrorRendererInterface
private $debug;

/**
* @param string|callable(FlattenException) $format The format as a string or a callable that should return it
* formats not supported by Request::getMimeTypes() should be given as mime types
* @param bool|callable $debug The debugging mode as a boolean or a callable that should return it
* @param string|callable(FlattenException): string $format The format as a string or a callable that should return it
* formats not supported by Request::getMimeTypes() should be given as mime types
* @param bool|callable $debug The debugging mode as a boolean or a callable that should return it
*/
public function __construct(SerializerInterface $serializer, $format, ?ErrorRendererInterface $fallbackErrorRenderer = null, $debug = false)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ public function returnTypeGrandParent()
{
}

/**
* @return string
*/
abstract public function realReturnTypeMustBeThere(): string;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/ErrorHandler/ThrowableUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
class ThrowableUtils
{
/**
* @param SilencedErrorContext|\Throwable
* @param SilencedErrorContext|\Throwable $throwable
*/
public static function getSeverity($throwable): int
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ interface ChoiceListFactoryInterface
*
* @return ChoiceListInterface
*/
public function createListFromChoices(iterable $choices, ?callable $value = null/* , callable $filter = null */);
public function createListFromChoices(iterable $choices, ?callable $value = null/* , ?callable $filter = null */);

/**
* Creates a choice list that is loaded with the given loader.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public function validate($form, Constraint $formConstraint)
return;
}

/* @var FormInterface $form */
$config = $form->getConfig();

$validator = $this->context->getValidator()->inContext($this->context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct(ValidatorInterface $validator, bool $legacyErrorMess
// the DIC, where the XML file is loaded automatically. Thus the following
// code must be kept synchronized with validation.xml

/* @var $metadata ClassMetadata */
/* @var ClassMetadata $metadata */
$metadata->addConstraint(new Form());
$metadata->addConstraint(new Traverse(false));

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Form/FormBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public function count()
*/
public function getFormConfig()
{
/** @var $config self */
/** @var self $config */
$config = parent::getFormConfig();

$config->children = [];
Expand Down
1 change: 0 additions & 1 deletion src/Symfony/Component/Form/ResolvedFormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ public function finishView(FormView $view, FormInterface $form, array $options)
$this->innerType->finishView($view, $form, $options);

foreach ($this->typeExtensions as $extension) {
/* @var FormTypeExtensionInterface $extension */
$extension->finishView($view, $form, $options);
}
}
Expand Down
1 change: 0 additions & 1 deletion src/Symfony/Component/Form/Tests/SimpleFormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,6 @@ public function testInitializeSetsDefaultData()
$config = $this->getBuilder()->setData('DEFAULT')->getFormConfig();
$form = new Form($config);

/* @var Form $form */
$form->initialize();

$this->assertSame('DEFAULT', $form->getData());
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/HttpKernel/Event/KernelEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class KernelEvent extends Event
private $requestType;

/**
* @param int $requestType The request type the kernel is currently processing; one of
* HttpKernelInterface::MAIN_REQUEST or HttpKernelInterface::SUB_REQUEST
* @param int|null $requestType The request type the kernel is currently processing; one of
* HttpKernelInterface::MAIN_REQUEST or HttpKernelInterface::SUB_REQUEST
*/
public function __construct(HttpKernelInterface $kernel, Request $request, ?int $requestType)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,7 @@ public function format($timestamp)
/**
* Not supported. Formats an object.
*
* @param mixed $format
* @param string $locale
* @param mixed $format
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @param mixed $format
* @param mixed $format

*
* @return string The formatted value
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public function testExpiration()
$key = new Key(uniqid(__METHOD__, true));
$clockDelay = $this->getClockDelay();

/** @var PersistingStoreInterface $store */
$store = $this->getStore();

$store->save($key);
Expand All @@ -63,7 +62,6 @@ public function testAbortAfterExpiration()
$this->expectException(LockExpiredException::class);
$key = new Key(uniqid(__METHOD__, true));

/** @var PersistingStoreInterface $store */
$store = $this->getStore();

$store->save($key);
Expand All @@ -82,7 +80,6 @@ public function testRefreshLock()

$key = new Key(uniqid(__METHOD__, true));

/** @var PersistingStoreInterface $store */
$store = $this->getStore();

$store->save($key);
Expand All @@ -97,7 +94,6 @@ public function testSetExpiration()
{
$key = new Key(uniqid(__METHOD__, true));

/** @var PersistingStoreInterface $store */
$store = $this->getStore();

$store->save($key);
Expand All @@ -113,7 +109,6 @@ public function testExpiredLockCleaned()
$key1 = new Key($resource);
$key2 = new Key($resource);

/** @var PersistingStoreInterface $store */
$store = $this->getStore();
$key1->reduceLifetime(0);

Expand Down
Loading
Loading