PhpStorm中是否可以将PHPDoc转换为类型提示并返回类型声明?
例如转换...
$a1=array("a"=>"red","b"=>"green","c"=>"blue","d"=>"yellow");
$a2=array("e"=>"red","f"=>"green","g"=>"blue");
$result=array_diff($a1,$a2);
print_r($result);
...到
/**
* @param float $coefficient
* @return $this
*/
public function setCoefficient($coefficient)
{
$this->coefficient = (float) $coefficient;
return $this;
}
/**
* @return float
*/
public function getCoefficient()
{
return $this->coefficient;
}
Filltext:您的帖子似乎大部分是代码;请添加更多详细信息。
答案 0 :(得分:1)
尝试https://github.com/dunglas/phpdoc-to-typehint
之前:
<?php
/**
* @param int|null $a
* @param string $b
*
* @return float
*/
function bar($a, $b, bool $c, callable $d = null)
{
return 0.0;
}
之后:
<?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;
}