Fork me on GitHub
a Sensio Labs Product

Jump & Run (v3.28.0) edition

Rule phpdoc_to_param_type

EXPERIMENTAL: Takes @param annotations of non-mixed types and adjusts accordingly the function signature. Requires PHP >= 7.0.


Using this rule is risky

This rule is EXPERIMENTAL and [1] is not covered with backward compatibility promise. [2] @param annotation is mandatory for the fixer to make changes, signatures of methods without it (no docblock, inheritdocs) will not be fixed. [3] Manual actions are required if inherited signatures are not properly documented.



Fix also scalar types; may have unexpected behaviour due to PHP bad type coercion system.

Allowed types: bool

Default value: true


Example #1

Default configuration.

--- Original
+++ New

  * @param string $foo
  * @param string|null $bar
-function f($foo, $bar)
+function f(string $foo, ?string $bar)

Example #2

With configuration: ['scalar_types' => false].

--- Original
+++ New

 /** @param Foo $foo */
-function foo($foo) {}
+function foo(Foo $foo) {}
 /** @param string $foo */
 function bar($foo) {}
The logo is © 2010-2022 Sensio Labs