Issues (36)

controllers/InterfaceController.php (1 issue)

Labels
Severity
1
<?php
2
3
4
namespace carono\exchange1c\controllers;
5
6
7
use carono\exchange1c\helpers\ModuleHelper;
8
use carono\exchange1c\models\InterfaceTest;
9
use yii\helpers\Html;
10
use yii\web\HttpException;
11
12
class InterfaceController extends Controller
13
{
14
    /**
15
     * @param string $variable
16
     * @return string
17
     * @throws HttpException
18
     */
19
    public function actionCheck($variable)
20
    {
21
        $class = \Yii::$app->controller->module->{$variable};
22
        if (!$class) {
23
            throw new HttpException(401, "Значение '$variable' не установлено");
24
        }
25
        $interfaceTest = InterfaceTest::findByClass($class);
26
        $interfaceClass = ModuleHelper::getPhpDocInterfaceProperty($variable);
27
        if ($interfaceTest->load(\Yii::$app->request->post())) {
28
            if ($interfaceTest->save()) {
29
                $this->refresh();
30
            } else {
31
                \Yii::$app->session->setFlash('error', Html::errorSummary($interfaceTest));
0 ignored issues
show
The method setFlash() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

31
                \Yii::$app->session->/** @scrutinizer ignore-call */ 
32
                                     setFlash('error', Html::errorSummary($interfaceTest));

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
32
            }
33
        }
34
        return $this->render('check', [
35
            'variable' => $variable,
36
            'class' => $class,
37
            'interfaceTest' => $interfaceTest,
38
            'interfaceClass' => $interfaceClass
39
        ]);
40
    }
41
}