These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * HiSite Yii2 base project |
||
4 | * |
||
5 | * @link https://github.com/hiqdev/hisite |
||
6 | * @package hisite |
||
7 | * @license BSD-3-Clause |
||
8 | * @copyright Copyright (c) 2016-2017, HiQDev (http://hiqdev.com/) |
||
9 | */ |
||
10 | |||
11 | namespace hisite\actions; |
||
12 | |||
13 | use hisite\models\ContactForm; |
||
14 | use Yii; |
||
15 | |||
16 | class ContactAction extends \yii\base\Action |
||
17 | { |
||
18 | public $redirect = true; |
||
19 | |||
20 | public $redirectUrl = '/'; |
||
21 | |||
22 | public $anchor = 'contact'; |
||
23 | |||
24 | public function run() |
||
25 | { |
||
26 | if (Yii::$app->request->isPost) { |
||
27 | $model = new ContactForm(); |
||
28 | if ($model->load(Yii::$app->request->post()) && $model->contact(Yii::$app->params['adminEmail'])) { |
||
29 | Yii::$app->session->setFlash('contactFormSubmitted'); |
||
30 | |||
31 | if ($this->redirect) { |
||
32 | return $this->controller->redirect(['/', '#' => $this->anchor]); |
||
0 ignored issues
–
show
|
|||
33 | } else { |
||
34 | return $this->controller->refresh('#' . $this->anchor); |
||
0 ignored issues
–
show
The method
refresh does only exist in yii\web\Controller , but not in yii\base\Controller .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
35 | } |
||
36 | } |
||
37 | } |
||
38 | } |
||
39 | } |
||
40 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: