Conditions | 11 |
Paths | 128 |
Total Lines | 73 |
Code Lines | 31 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 1 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
22 | public static function upgrade() |
||
23 | { |
||
24 | // [#702] Update to include Admin Path configuration |
||
25 | if (version_compare(self::$existing_version, '2.4beta2', '<=')) { |
||
26 | // Add missing config value for index view string length |
||
27 | Symphony::Configuration()->set('cell_truncation_length', '75', 'symphony'); |
||
28 | // Add admin-path to configuration |
||
29 | Symphony::Configuration()->set('admin-path', 'symphony', 'symphony'); |
||
30 | } |
||
31 | |||
32 | // [#1626] Update all tables to be UTF-8 encoding/collation |
||
33 | // @link https://gist.github.com/michael-e/5789168 |
||
34 | $tables = Symphony::Database()->fetch("SHOW TABLES"); |
||
35 | if (is_array($tables) && !empty($tables)) { |
||
36 | foreach ($tables as $table) { |
||
37 | $table = current($table); |
||
38 | |||
39 | // If it's not a Symphony table, ignore it |
||
40 | if (!preg_match('/^' . Symphony::Database()->getPrefix() . '/', $table)) { |
||
41 | continue; |
||
42 | } |
||
43 | |||
44 | Symphony::Database()->query(sprintf( |
||
45 | "ALTER TABLE `%s` CHARACTER SET utf8 COLLATE utf8_unicode_ci", |
||
46 | $table |
||
47 | )); |
||
48 | Symphony::Database()->query(sprintf( |
||
49 | "ALTER TABLE `%s` CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci", |
||
50 | $table |
||
51 | )); |
||
52 | } |
||
53 | } |
||
54 | |||
55 | // [#1420] Change date field to be a varchar instead of an ENUM to support prepopulation |
||
56 | try { |
||
57 | Symphony::Database()->query(' |
||
58 | ALTER TABLE `tbl_fields_date` |
||
59 | CHANGE `pre_populate` `pre_populate` VARCHAR(80) COLLATE utf8_unicode_ci DEFAULT NULL; |
||
60 | '); |
||
61 | } catch (Exception $ex) { |
||
62 | } |
||
63 | |||
64 | // [#1997] Add filtering column to the Sections table |
||
65 | if (!Symphony::Database()->tableContainsField('tbl_sections', 'filter')) { |
||
66 | Symphony::Database()->query(" |
||
67 | ALTER TABLE `tbl_sections` |
||
68 | ADD `filter` ENUM('yes','no') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'yes'; |
||
69 | "); |
||
70 | } |
||
71 | |||
72 | $installed_extensions = Symphony::ExtensionManager()->listInstalledHandles(); |
||
73 | if (in_array('publishfiltering', $installed_extensions)) { |
||
74 | Symphony::ExtensionManager()->uninstall('publishfiltering'); |
||
75 | self::$publish_filtering_disabled = true; |
||
76 | } |
||
77 | |||
78 | // [#1874] XSRF/CRSF options |
||
79 | if (version_compare(self::$existing_version, '2.4beta3', '<=')) { |
||
80 | // How long should a XSRF token be valid |
||
81 | Symphony::Configuration()->set('token_lifetime', '15 minutes', 'symphony'); |
||
82 | // Should the token be removed as soon as it has been used? |
||
83 | Symphony::Configuration()->set('invalidate_tokens_on_request', false, 'symphony'); |
||
|
|||
84 | } |
||
85 | |||
86 | // [#1874] XSRF/CRSF options |
||
87 | if (version_compare(self::$existing_version, '2.4RC1', '<=')) { |
||
88 | // On update, disable XSRF for compatibility purposes |
||
89 | Symphony::Configuration()->set('enable_xsrf', 'no', 'symphony'); |
||
90 | } |
||
91 | |||
92 | // Update the version information |
||
93 | return parent::upgrade(); |
||
94 | } |
||
95 | |||
129 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: