GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Test Setup Failed
Push — feature/respect-port ( e2dffb )
by Alexander
09:09
created

CoreModule::getBaseUrl()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace app\modules\core;
4
5
use app;
6
use app\components\BaseModule;
7
use app\modules\core\models\ContentDecorator;
8
use Yii;
9
use yii\base\Application;
10
use yii\base\BootstrapInterface;
11
12
/**
13
 * Core module handles base DotPlant2 functions
14
 * @package app\modules\user
15
 */
16
class CoreModule extends BaseModule implements BootstrapInterface
17
{
18
    // To be implemented!
19
    public $themeExtensionId = 0;
20
21
    public $themeModuleName = '';
22
23
    public $themeModuleLocation = '';
24
25
    public $controllerMap = [
26
        'backend-extensions' => 'app\modules\core\backend\ExtensionsController',
27
        'backend-routing' => 'app\modules\core\backend\RoutingController',
28
        'backend-wysiwyg' => 'app\modules\core\backend\WysiwygController',
29
    ];
30
31
    public $autoCompleteResultsCount = 5;
32
33
    public $fileUploadPath = '@webroot/upload/files/';
34
    public $visitorsFileUploadPath = '@app/visitors-uploaded/';
35
    public $removeUploadedFiles = true;
36
    public $overwriteUploadedFiles = false;
37
38
    public $spamCheckerApiKey;
39
40
    public $serverName = 'localhost';
41
    public $serverPort = 80;
42
43
    public $daysToStoreSubmissions = 28;
44
45
    /**
46
     * @var string Internal encoding. It's used for mbstring functions.
47
     */
48
    public $internalEncoding = 'UTF-8';
49
50
    public $errorMonitorEnabled = false;
51
    public $emailNotifyEnabled = false;
52
    public $devmail = '';
53
    public $notifyOnlyHttpCodes = '';
54
    public $numberElementsToStore = 5;
55
    public $immediateNotice = false;
56
    public $immediateNoticeLimitPerUrl = 10;
57
    public $httpCodesForImmediateNotify = '404,500';
58
59
    public $searchHandlers = [
60
        'query_search_products_by_description' => [
61
            'app\components\search\SearchProductsByDescriptionHandler'
62
        ],
63
        'query_search_products_by_property' => [
64
            'app\components\search\SearchProductsByPropertyHandler'
65
        ],
66
        'query_search_pages_by_description' => [
67
            'app\components\search\SearchPagesByDescriptionHandler'
68
        ]
69
    ];
70
71
    public $emailConfig = [
72
        'transport' => 'Swift_MailTransport',
73
        'host' => 'localhost',
74
        'username' => 'login',
75
        'password' => 'password',
76
        'port' => '25',
77
        'encryption' => '',
78
        'mailFrom' => 'login',
79
        'sendMail' => '',
80
    ];
81
82
    public $wysiwyg_id = 1;
83
84
    /** @var string|null Active WYSIWYG editor class name for use in backend forms */
85
    private $wysiwyg_class_name = '';
86
87
    /** @var array|null Active WYSIWYG editor params for use in backend forms */
88
    private $wysiwyg_params = null;
89
90
    /** @var bool Attach file properties to form email message */
91
    public $attachFilePropertiesToFormEmail = false;
0 ignored issues
show
Comprehensibility Naming introduced by
The variable name $attachFilePropertiesToFormEmail exceeds the maximum configured length of 30.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
92
93
    /**
94
     * @inheritdoc
95
     */
96
    public function behaviors()
97
    {
98
        return [
99
            'configurableModule' => [
100
                'class' => 'app\modules\config\behaviors\ConfigurableModuleBehavior',
101
                'configurationView' => '@app/modules/core/views/configurable/_config',
102
                'configurableModel' => 'app\modules\core\models\ConfigConfigurationModel',
103
            ]
104
        ];
105
    }
106
107
    /**
108
     * Bootstrap method to be called during application bootstrap stage.
109
     * @param Application $app the application currently running
110
     */
111
    public function bootstrap($app)
112
    {
113
        mb_internal_encoding($this->internalEncoding);
114
        if ($app instanceof \yii\web\Application === true) {
0 ignored issues
show
Bug introduced by
The class yii\web\Application does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
115
            $app->on(
116
                Application::EVENT_BEFORE_ACTION,
117
                function () use ($app) {
118
                    $controller = Yii::$app->requestedAction->controller;
119
120
                    $decorators = ContentDecorator::getAllDecorators();
121
                    foreach ($decorators as $decorator) {
122
                        $decorator->subscribe($app, $controller);
123
                    }
124
125
126
                }
127
            );
128
        }
129
    }
130
131
    /**
132
     * @inheritdoc
133
     */
134
    public function init()
135
    {
136
        parent::init();
137
        if (Yii::$app instanceof \yii\console\Application) {
0 ignored issues
show
Bug introduced by
The class yii\console\Application does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
138
            $this->controllerMap = [];
139
        }
140
141
    }
142
143
    /**
144
     * @return string Active WYSIWYG widget class name for use in backend forms
0 ignored issues
show
Documentation introduced by
Should the return type not be string|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
145
     */
146
    public function wysiwyg_class_name()
147
    {
148
        if (empty($this->wysiwyg_class_name)) {
149
            $this->fetchWYSIWYG();
150
            if (class_exists($this->wysiwyg_class_name) === false) {
151
                $this->wysiwyg_id = 1;
152
                $this->fetchWYSIWYG();
153
            }
154
        }
155
        return $this->wysiwyg_class_name;
156
    }
157
158
    /**
159
     * @return array WYSIWYG params for widget
0 ignored issues
show
Documentation introduced by
Should the return type not be null|array? Also, consider making the array more specific, something like array<String>, or String[].

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

If the return type contains the type array, this check recommends the use of a more specific type like String[] or array<String>.

Loading history...
160
     */
161
    public function wysiwyg_params()
162
    {
163
        if ($this->wysiwyg_params === null) {
164
            $this->fetchWYSIWYG();
165
        }
166
        return $this->wysiwyg_params;
167
    }
168
169
    private function fetchWYSIWYG()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
170
    {
171
        $data = app\modules\core\models\Wysiwyg::getClassNameAndParamsById($this->wysiwyg_id);
172
        if (!isset($data['class_name'])) {
173
            if ($this->wysiwyg_id > 1) {
174
                $this->wysiwyg_id = 1;
175
            } else {
176
                Yii::$app->cache->delete('WysiwygClassName:' . $this->wysiwyg_id);
177
            }
178
            return $this->fetchWYSIWYG();
179
        }
180
        $this->wysiwyg_class_name = $data['class_name'];
181
        $this->wysiwyg_params = $data['params'];
182
    }
183
184
    /**
185
     * @return string
186
     */
187
    public function getServerPort()
188
    {
189
        return $this->serverPort == 80 ? "" : ":{$this->serverPort}";
190
    }
191
192
    /**
193
     * Returns compiled baseUrl without schema servername:port
194
     *
195
     * @return string
196
     */
197
    public function getBaseUrl()
198
    {
199
        return $this->serverName . $this->getServerPort();
200
    }
201
}
202