Reputation: 3116
Is there a way in PhpStorm to transform PHPDoc to type-hint and return type-declaration?
E.g. transform...
/**
* @param float $coefficient
* @return $this
*/
public function setCoefficient($coefficient)
{
$this->coefficient = (float) $coefficient;
return $this;
}
/**
* @return float
*/
public function getCoefficient()
{
return $this->coefficient;
}
...to
public function setCoefficient(float $coefficient): self
{
$this->coefficient = (float) $coefficient;
return $this;
}
public function getCoefficient(): float
{
return $this->coefficient;
}
Filltext: It looks like your post is mostly code; please add some more details.
Upvotes: 1
Views: 722
Reputation: 881
Try https://github.com/dunglas/phpdoc-to-typehint
Before:
<?php
/**
* @param int|null $a
* @param string $b
*
* @return float
*/
function bar($a, $b, bool $c, callable $d = null)
{
return 0.0;
}
After:
<?php
/**
* @param int|null $a
* @param string $b
*
* @return float
*/
function bar(int $a = null, string $b, bool $c, callable $d = null) : float
{
return 0.0;
}
Upvotes: 1