1 | <?php |
||||
2 | |||||
3 | namespace Apps\Controller\Admin\Main; |
||||
4 | |||||
5 | |||||
6 | use Apps\Model\Admin\Main\FormYandexCounter; |
||||
7 | use Ffcms\Core\App; |
||||
8 | use Ffcms\Core\Arch\View; |
||||
9 | use Ffcms\Core\Exception\ForbiddenException; |
||||
10 | use Ffcms\Core\Helper\Type\Any; |
||||
11 | use Ffcms\Core\Network\Request; |
||||
12 | use Ffcms\Core\Network\Response; |
||||
13 | use Ffcms\Yandex\Metrika\Client; |
||||
14 | |||||
15 | /** |
||||
16 | * Trait ActionYandexCounter |
||||
17 | * @package Apps\Controller\Admin\Main |
||||
18 | * @property Request $request |
||||
19 | * @property Response $response |
||||
20 | * @property View $view |
||||
21 | */ |
||||
22 | trait ActionYandexCounter |
||||
23 | { |
||||
24 | /** |
||||
25 | * Select counter from api ids |
||||
26 | * @return string|null |
||||
27 | * @throws ForbiddenException |
||||
28 | * @throws \Ffcms\Core\Exception\SyntaxException |
||||
29 | */ |
||||
30 | public function yandexCounter(): ?string |
||||
31 | { |
||||
32 | $configs = App::$Properties->get('oauth', 'Yandex'); |
||||
33 | |||||
34 | $client = new Client($configs['token'], 0); |
||||
35 | $counters = $client->getCountersList(); |
||||
0 ignored issues
–
show
|
|||||
36 | |||||
37 | // check if counters exist |
||||
38 | if (!$counters || !Any::isArray($counters) || count($counters) < 1) { |
||||
0 ignored issues
–
show
$counters of type void is incompatible with the type Countable|array expected by parameter $var of count() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
39 | throw new ForbiddenException(__('No active counters found')); |
||||
40 | } |
||||
41 | |||||
42 | // initialize select model |
||||
43 | $model = new FormYandexCounter($counters); |
||||
44 | if ($model->send() && $model->validate()) { |
||||
45 | $model->make(); |
||||
46 | App::$Session->getFlashBag()->add('success', __('Yandex.metrika connected successful')); |
||||
47 | $this->response->redirect('main/index'); |
||||
48 | } |
||||
49 | |||||
50 | return $this->view->render('main/yandex_counter', [ |
||||
51 | 'model' => $model |
||||
52 | ]); |
||||
53 | } |
||||
54 | } |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.