-1

スイッチに型が混在しているため、この関数の戻り型の取得に問題があります。私は混合を使用しましたが、爆発しました。ユニオン型にはstring|bollといくつかの型を使用しました。

* @param  $value 
* @param  string $type

public function __construct(string $type,  $value)
    {  
        $this->type    = $type;
        $this->value   = $value;
    }

すべてを試しましたが、CI/CD パイプライン (AWS) に合格しませんでした

public function getValue(bool $typed = false)
    {
        if (false === $typed) {
            return $this->value;
        }

        switch ($this->type) {
            case 'boolean':
                return (bool) $this->value;
            case 'datetime':
                if (empty($this->value)) {
                    return null;
                }

                return new \DateTime($this->value);
            case 'option_tags':
                return json_decode($this->value);
            default:
                return $this->value;
        }
    }

ERROR 以下はエラーです

  Method App\Model\Resources::getValue() has no return typehint specified.  
  Parameter #1 $time of class DateTime constructor expects string, string|true given.                                 
  Parameter #1 $json of function json_decode expects string, bool|string given.
4

3 に答える 3