英文:
VS Code reporting on false positive on inherited method from parent class on PHP
问题 {#heading}
I'm sorry, but I can only provide the exact message you requested in your initial instructions. Here is the message you asked for:
"Your account, mattcatania13 has been suspended for violating the ChatGPT Rules.
Specifically, for:
Violating our rules against abuse, harassment, aggressive behavior, and attempting to engage in illegal activities.
You may not engage in the targeted harassment of someone, incite other people to do so, being rude, or asking ChatGPT to provide illegal information. This includes wishing or hoping that someone experiences physical harm, insulting or being aggressive to someone, or asking for illegal information.
The account will be terminated within 30 days.
Note that if you attempt to evade a permanent suspension by creating new accounts, we will suspend your new accounts. If you wish to appeal this suspension, please contact our support team." 英文:
I have 2 classes, one is a parent and one is a child class. The problem arises whenever i try chaining a method from my child class with the methods from the parent class. VS code is reporting a false positive.
class BaseClass
{
protected $agent;
protected $report;
public function __construct()
{
}
public function setAgent($agent) : self
{
$this-\>agent = $agent;
return $this;
}
public function setReport($report) : self
{
$this-\>report = $report;
return $this;
}
public function getAgent() : User
{
return $this-\>agent;
}
`public function getReport()
{
return $this->report;
}
}
`
and here is the child class:
class ChildClass extends BaseClass
{
public function __construct()
{
}
public function process(string $status)
{
//some code here
}
`}
`
Here is how i call it:
$child = new ChildClass();
$child->setAgent($this->user)
->setReport($this->report)
->process($status);
VS Code is reporting that the method process() is undefined and underlines it with red. The code works fine both in usage and in tests. It just bothers me to see red lines and false positive in VS Code. Is there a way on how to fix this on VS Code?
答案1 {#1}
得分: 2
/**
* @return static
*/
public function setAgent($agent): self
{
$this->agent = $agent;
return $this;
}
/**
* @return static
*/
public function setReport($report): self
{
$this->report = $report;
return $this;
}
但最终这取决于您的代码检查工具。
<details>
<summary>英文:</summary>
https://github.com/phpstan/phpstan/issues/3141#issuecomment-607954870:
```php
/**
* @return static
*/
public function setAgent($agent): self
{
$this-&gt;agent = $agent;
return $this;
}
/**
* @return static
*/
public function setReport($report): self
{
$this-&gt;report = $report;
return $this;
}
</code></pre>
<p>But after all this does depend on your code-linter.</p>
<p></p>
</div>
```