1 | <?php |
||||||
2 | |||||||
3 | /* Divine CMS - Open source CMS for widespread use. |
||||||
4 | Copyright (c) 2019 Mykola Burakov ([email protected]) |
||||||
5 | |||||||
6 | See SOURCE.txt for other and additional information. |
||||||
7 | |||||||
8 | This file is part of Divine CMS. |
||||||
9 | |||||||
10 | This program is free software: you can redistribute it and/or modify |
||||||
11 | it under the terms of the GNU General Public License as published by |
||||||
12 | the Free Software Foundation, either version 3 of the License, or |
||||||
13 | (at your option) any later version. |
||||||
14 | |||||||
15 | This program is distributed in the hope that it will be useful, |
||||||
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
18 | GNU General Public License for more details. |
||||||
19 | |||||||
20 | You should have received a copy of the GNU General Public License |
||||||
21 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
||||||
22 | |||||||
23 | class ControllerStartupStartup extends \Divine\Engine\Core\Controller |
||||||
0 ignored issues
–
show
|
|||||||
24 | { |
||||||
25 | public function index() |
||||||
0 ignored issues
–
show
|
|||||||
26 | { |
||||||
27 | // Settings |
||||||
28 | $query = $this->db->query(" |
||||||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
\n SELECT * \... FROM setting\n does not require double quotes, as per coding-style, please use single quotes.
PHP provides two ways to mark string literals. Either with single quotes String literals in single quotes on the other hand are evaluated very literally and the only two
characters that needs escaping in the literal are the single quote itself ( Double quoted string literals may contain other variables or more complex escape sequences. <?php
$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";
print $doubleQuoted;
will print an indented: If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear. For more information on PHP string literals and available escape sequences see the PHP core documentation. ![]() |
|||||||
29 | SELECT * |
||||||
30 | FROM setting |
||||||
31 | "); |
||||||
32 | |||||||
33 | foreach ($query->rows as $setting) { |
||||||
34 | if (!$setting['serialized']) { |
||||||
35 | $this->config->set( |
||||||
36 | $setting['key'], |
||||||
37 | $setting['value'] |
||||||
38 | ); |
||||||
39 | } else { |
||||||
40 | $this->config->set( |
||||||
41 | $setting['key'], |
||||||
42 | json_decode($setting['value'], true) |
||||||
43 | ); |
||||||
44 | } |
||||||
45 | } |
||||||
46 | |||||||
47 | // Language |
||||||
48 | $query = $this->db->query(" |
||||||
49 | SELECT * |
||||||
50 | FROM `language` |
||||||
51 | WHERE code = '" . $this->db->escape($this->config->get('config_admin_language')) . "' |
||||||
52 | "); |
||||||
53 | |||||||
54 | if ($query->num_rows) { |
||||||
55 | $this->config->set( |
||||||
56 | 'config_language_id', |
||||||
57 | $query->row['language_id'] |
||||||
58 | ); |
||||||
59 | } |
||||||
60 | |||||||
61 | // Language |
||||||
62 | $language = new \Divine\Engine\Library\Language( |
||||||
63 | $this->config->get('config_admin_language') |
||||||
64 | ); |
||||||
65 | $language->load( |
||||||
66 | $this->config->get('config_admin_language') |
||||||
67 | ); |
||||||
68 | $this->registry->set( |
||||||
69 | 'language', |
||||||
70 | $language |
||||||
71 | ); |
||||||
72 | |||||||
73 | // Customer |
||||||
74 | $this->registry->set( |
||||||
75 | 'customer', |
||||||
76 | new \Divine\Engine\Library\Customer( |
||||||
77 | $this->registry |
||||||
78 | ) |
||||||
79 | ); |
||||||
80 | |||||||
81 | // Currency |
||||||
82 | $this->registry->set( |
||||||
83 | 'currency', |
||||||
84 | new \Divine\Engine\Library\Currency( |
||||||
85 | $this->registry |
||||||
86 | ) |
||||||
87 | ); |
||||||
88 | |||||||
89 | // Cart |
||||||
90 | $this->registry->set( |
||||||
91 | 'cart', |
||||||
92 | new \Divine\Engine\Library\Cart( |
||||||
93 | $this->registry |
||||||
94 | ) |
||||||
95 | ); |
||||||
96 | |||||||
97 | // Encryption |
||||||
98 | $this->registry->set( |
||||||
99 | 'encryption', |
||||||
100 | new \Divine\Engine\Library\Encryption( |
||||||
101 | $this->config->get('config_encryption') |
||||||
0 ignored issues
–
show
The call to
Divine\Engine\Library\Encryption::__construct() has too many arguments starting with $this->config->get('config_encryption') .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above. ![]() |
|||||||
102 | ) |
||||||
103 | ); |
||||||
104 | } |
||||||
105 | } |
||||||
106 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.