Completed
Pull Request — master (#91)
by Gino
03:29
created

AdminPages::getAdminPagesUpdate()   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 5
1
<?php
2
3
/*
4
 You may not change or alter any portion of this comment or credits
5
 of supporting developers from this source code or any supporting source code
6
 which is considered copyrighted (c) material of the original comment or credit authors.
7
8
 This program is distributed in the hope that it will be useful,
9
 but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 */
12
/**
13
 * tdmcreate module.
14
 *
15
 * @copyright       The XOOPS Project http://sourceforge.net/projects/xoops/
16
 * @license         GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
17
 *
18
 * @since           2.5.0
19
 *
20
 * @author          Txmod Xoops http://www.txmodxoops.org
21
 *
22
 * @version         $Id: AdminPages.php 12258 2014-01-02 09:33:29Z timgno $
23
 */
24
25
/**
26
 * Class AdminPages.
27
 */
28
class AdminPages extends TDMCreateFile
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
29
{
30
    /*
31
     * @var string
32
     */
33
    private $tf = null;
34
35
    /*
36
     * @var string
37
     */
38
    private $cc = null;
39
40
    /*
41
     * @var string
42
     */
43
    private $xc = null;
44
45
    /*
46
     * @var string
47
     */
48
    private $axc = null;
49
50
    /*
51
     * @public function constructor
52
     * @param null    
53
     *
54
     */
55
    public function __construct()
56
    {
57
        parent::__construct();
58
        $this->tf = TDMCreateFile::getInstance();
0 ignored issues
show
Documentation Bug introduced by
It seems like \TDMCreateFile::getInstance() of type object<TDMCreateFile> is incompatible with the declared type string of property $tf.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
59
        $this->phpcode = TDMCreatePhpCode::getInstance();
0 ignored issues
show
Documentation Bug introduced by
It seems like \TDMCreatePhpCode::getInstance() of type object<TDMCreatePhpCode> is incompatible with the declared type string of property $phpcode.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
60
        $this->xc = TDMCreateXoopsCode::getInstance();
0 ignored issues
show
Documentation Bug introduced by
It seems like \TDMCreateXoopsCode::getInstance() of type object<TDMCreateXoopsCode> is incompatible with the declared type string of property $xc.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
61
        $this->cc = ClassXoopsCode::getInstance();
0 ignored issues
show
Documentation Bug introduced by
It seems like \ClassXoopsCode::getInstance() of type object<ClassXoopsCode> is incompatible with the declared type string of property $cc.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
62
        $this->axc = AdminXoopsCode::getInstance();
0 ignored issues
show
Documentation Bug introduced by
It seems like \AdminXoopsCode::getInstance() of type object<AdminXoopsCode> is incompatible with the declared type string of property $axc.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
63
    }
64
65
    /*
66
     * @static function &getInstance
67
     * @param null 
68
     *
69
     * @return AdminPages
70
     */
71
    public static function &getInstance()
72
    {
73
        static $instance = false;
74
        if (!$instance) {
75
            $instance = new self();
76
        }
77
78
        return $instance;
79
    }
80
81
    /*
82
    *  @public function write
83
    *  @param $module
84
    *  @param $table
85
    */
86
    public function write($module, $table, $filename)
87
    {
88
        $this->setModule($module);
89
        $this->setTable($table);
90
        $this->setFileName($filename);
91
    }
92
93
    /*
94
    *  @private function getAdminPagesHeader
95
    *  @param $moduleDirname
96
    *  @param $tableName
97
    *  @param $fieldId
98
    *  @return string
99
    */
100
    private function getAdminPagesHeader($moduleDirname, $tableName, $fieldId)
0 ignored issues
show
Unused Code introduced by
The parameter $moduleDirname is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $tableName is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
101
    {
102
        $ccFieldId = $this->getCamelCase($fieldId, false, true);
103
        $ret = $this->getInclude();
104
        $ret .= $this->phpcode->getPhpCodeCommentLine('It recovered the value of argument op in URL$');
0 ignored issues
show
Bug introduced by
The method getPhpCodeCommentLine cannot be called on $this->phpcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
105
        $ret .= $this->xc->getXoopsCodeXoopsRequest('op', 'op', 'list');
0 ignored issues
show
Bug introduced by
The method getXoopsCodeXoopsRequest cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
106
        $ret .= $this->phpcode->getPhpCodeCommentLine("Request {$fieldId}");
0 ignored issues
show
Bug introduced by
The method getPhpCodeCommentLine cannot be called on $this->phpcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
107
        $ret .= $this->xc->getXoopsCodeXoopsRequest($ccFieldId, $fieldId, '', 'Int');
0 ignored issues
show
Bug introduced by
The method getXoopsCodeXoopsRequest cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
108
109
        return $ret;
110
    }
111
112
    /*
113
     *  @private function getAdminPagesSwitch
114
     *  @param $cases
115
     *
116
     * @return string
117
     */
118
    private function getAdminPagesSwitch($cases = array())
119
    {
120
        $contentSwitch = $this->phpcode->getPhpCodeCaseSwitch($cases, true, false, "\t");
0 ignored issues
show
Bug introduced by
The method getPhpCodeCaseSwitch cannot be called on $this->phpcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
121
122
        return $this->phpcode->getPhpCodeSwitch('op', $contentSwitch);
0 ignored issues
show
Bug introduced by
The method getPhpCodeSwitch cannot be called on $this->phpcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
123
    }
124
125
    /*
126
    *  @private function getAdminPagesList
127
    *  @param $moduleDirname
128
    *  @param $table
129
    *  @param $tableFieldname
130
    *  @param $language
131
    *  @param $fields
132
    *  @param $fieldId
133
    *  @param $fieldInForm
134
    *  @param $fieldMain
135
    *  @return string
136
    */
137
    private function getAdminPagesList($moduleDirname, $table, $language, $fields, $fieldId, $fieldInForm, $fieldMain)
0 ignored issues
show
Unused Code introduced by
The parameter $fields is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $fieldId is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $fieldMain is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
138
    {
139
        $stuModuleDirname = strtoupper($moduleDirname);
140
        $tableName = $table->getVar('table_name');
141
        $tableSoleName = $table->getVar('table_solename');
142
        $stuTableName = strtoupper($tableName);
143
        $stuTableSoleName = strtoupper($tableSoleName);
144
145
        $ret = $this->xc->getXoopsCodeXoopsRequest('start', 'start', '0', 'Int');
0 ignored issues
show
Bug introduced by
The method getXoopsCodeXoopsRequest cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
146
        $adminpager = $this->xc->getXoopsCodeGetConfig($moduleDirname, 'adminpager');
0 ignored issues
show
Bug introduced by
The method getXoopsCodeGetConfig cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
147
        $ret .= $this->xc->getXoopsCodeXoopsRequest('limit', 'limit', $adminpager, 'Int', false, "\t\t");
0 ignored issues
show
Bug introduced by
The method getXoopsCodeXoopsRequest cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
148
        $ret .= $this->axc->getAdminTemplateMain($moduleDirname, $tableName, "\t\t");
0 ignored issues
show
Bug introduced by
The method getAdminTemplateMain cannot be called on $this->axc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
149
        $navigation = $this->axc->getAdminAddNavigation($tableName);
0 ignored issues
show
Bug introduced by
The method getAdminAddNavigation cannot be called on $this->axc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
150
        $ret .= $this->xc->getXoopsCodeTplAssign('navigation', $navigation, true, "\t\t");
0 ignored issues
show
Bug introduced by
The method getXoopsCodeTplAssign cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
151
152
        if (in_array(1, $fieldInForm)) {
153
            $ret .= $this->axc->getAdminItemButton($language, $tableName, $stuTableSoleName, '?op=new', 'add', "\t\t");
0 ignored issues
show
Bug introduced by
The method getAdminItemButton cannot be called on $this->axc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
154
            $ret .= $this->xc->getXoopsCodeTplAssign('buttons', '$adminMenu->renderButton()', true, "\t\t");
0 ignored issues
show
Bug introduced by
The method getXoopsCodeTplAssign cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
155
        }
156
157
        $ret .= $this->xc->getXoopsCodeObjHandlerCount($tableName, "\t\t");
0 ignored issues
show
Bug introduced by
The method getXoopsCodeObjHandlerCount cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
158
        $ret .= $this->xc->getXoopsCodeObjHandlerAll($tableName, '', '$start', '$limit', "\t\t");
0 ignored issues
show
Bug introduced by
The method getXoopsCodeObjHandlerAll cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
159
        $ret .= $this->xc->getXoopsCodeTplAssign("{$tableName}_count", "\${$tableName}Count", true, "\t\t");
0 ignored issues
show
Bug introduced by
The method getXoopsCodeTplAssign cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
160
        $ret .= $this->xc->getXoopsCodeTplAssign("{$moduleDirname}_url", "{$stuModuleDirname}_URL", true, "\t\t");
0 ignored issues
show
Bug introduced by
The method getXoopsCodeTplAssign cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
161
        $ret .= $this->xc->getXoopsCodeTplAssign("{$moduleDirname}_upload_url", "{$stuModuleDirname}_UPLOAD_URL", true, "\t\t");
0 ignored issues
show
Bug introduced by
The method getXoopsCodeTplAssign cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
162
163
        $ret .= $this->phpcode->getPhpCodeCommentLine('Table view', $tableName, "\t\t");
0 ignored issues
show
Bug introduced by
The method getPhpCodeCommentLine cannot be called on $this->phpcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
164
        $contentForeach = $this->xc->getXoopsCodeGetValues($tableName, $tableSoleName, 'i', false, "\t");
0 ignored issues
show
Bug introduced by
The method getXoopsCodeGetValues cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
165
        $contentForeach .= $this->xc->getXoopsCodeXoopsTplAppend("{$tableName}_list", "\${$tableSoleName}", "\t\t\t\t");
0 ignored issues
show
Bug introduced by
The method getXoopsCodeXoopsTplAppend cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
166
        $contentForeach .= $this->phpcode->getPhpCodeUnset($tableSoleName, "\t\t\t\t");
0 ignored issues
show
Bug introduced by
The method getPhpCodeUnset cannot be called on $this->phpcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
167
        $condIf = $this->phpcode->getPhpCodeForeach("{$tableName}All", true, false, 'i', $contentForeach, "\t\t\t");
0 ignored issues
show
Bug introduced by
The method getPhpCodeForeach cannot be called on $this->phpcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
168
        $condIf .= $this->xc->getXoopsCodePageNav($tableName, "\t\t\t");
0 ignored issues
show
Bug introduced by
The method getXoopsCodePageNav cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
169
        $condElse = $this->xc->getXoopsCodeTplAssign('error', "{$language}THEREARENT_{$stuTableName}", true, "\t\t\t");
0 ignored issues
show
Bug introduced by
The method getXoopsCodeTplAssign cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
170
        $ret .= $this->phpcode->getPhpCodeConditions("\${$tableName}Count", ' > ', '0', $condIf, $condElse, "\t\t");
0 ignored issues
show
Bug introduced by
The method getPhpCodeConditions cannot be called on $this->phpcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
171
172
        return $ret;
173
    }
174
175
    /*
176
    *  @private function getAdminPagesNew
177
    *  @param $moduleDirname
178
    *  @param $tableName
179
    *  @param $fieldInForm
180
    *  @param $language
181
    *  @return string
182
    */
183
    private function getAdminPagesNew($moduleDirname, $tableName, $fieldInForm, $language, $t = '')
184
    {
185
        $stuTableName = strtoupper($tableName);
186
        $ret = $this->axc->getAdminTemplateMain($moduleDirname, $tableName);
0 ignored issues
show
Bug introduced by
The method getAdminTemplateMain cannot be called on $this->axc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
187
        $navigation = $this->axc->getAdminAddNavigation($tableName);
0 ignored issues
show
Bug introduced by
The method getAdminAddNavigation cannot be called on $this->axc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
188
        $ret .= $this->xc->getXoopsCodeTplAssign('navigation', $navigation, true, $t);
0 ignored issues
show
Bug introduced by
The method getXoopsCodeTplAssign cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
189
190
        if (in_array(1, $fieldInForm)) {
191
            $ret .= $this->axc->getAdminItemButton($language, $tableName, $stuTableName, '', 'list', $t);
0 ignored issues
show
Bug introduced by
The method getAdminItemButton cannot be called on $this->axc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
192
            $ret .= $this->xc->getXoopsCodeTplAssign('buttons', '$adminMenu->renderButton()', true, $t);
0 ignored issues
show
Bug introduced by
The method getXoopsCodeTplAssign cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
193
        }
194
        $ret .= $this->phpcode->getPhpCodeCommentLine('Get Form', null, "\t\t");
0 ignored issues
show
Bug introduced by
The method getPhpCodeCommentLine cannot be called on $this->phpcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
195
        $ret .= $this->xc->getXoopsCodeObjHandlerCreate($tableName, $t);
0 ignored issues
show
Bug introduced by
The method getXoopsCodeObjHandlerCreate cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
196
        $ret .= $this->xc->getXoopsCodeGetForm('form', $tableName, 'Obj', $t);
0 ignored issues
show
Bug introduced by
The method getXoopsCodeGetForm cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
197
        $ret .= $this->xc->getXoopsCodeTplAssign('form', '$form->render()', true, $t);
0 ignored issues
show
Bug introduced by
The method getXoopsCodeTplAssign cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
198
199
        return $ret;
200
    }
201
202
    /*
203
    *  @private function getPermissionsSave
204
    *  @param $moduleDirname
205
    *  @param $fieldId
206
    *  @param $ccFieldId
207
    *  @param $newFieldId
208
    *  @param $perm
209
    *
210
    *  @return string
211
    */
212
    private function getPermissionsSave($moduleDirname, $fieldId, $ccFieldId, $newFieldId, $perm = 'view')
0 ignored issues
show
Unused Code introduced by
The parameter $fieldId is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $ccFieldId is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $newFieldId is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
213
    {
214
        $ret = $this->phpcode->getPhpCodeCommentLine('Permission to', $perm, "\t\t\t");
0 ignored issues
show
Bug introduced by
The method getPhpCodeCommentLine cannot be called on $this->phpcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
215
        $content = $this->xc->getXoopsCodeAddRight('gpermHandler', "{$moduleDirname}_{$perm}", '$permId', '$onegroupId', "\$GLOBALS['xoopsModule']->getVar('mid')", false, "\t");
0 ignored issues
show
Bug introduced by
The method getXoopsCodeAddRight cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
216
        $foreach = $this->phpcode->getPhpCodeForeach("_POST['groups_{$perm}']", false, false, 'onegroupId', $content, "\t\t\t\t");
0 ignored issues
show
Bug introduced by
The method getPhpCodeForeach cannot be called on $this->phpcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
217
        $ret .= $this->phpcode->getPhpCodeConditions("isset(\$_POST['groups_{$perm}'])", null, null, $foreach, false, "\t\t\t");
0 ignored issues
show
Bug introduced by
The method getPhpCodeConditions cannot be called on $this->phpcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
218
219
        return $ret;
220
    }
221
222
    /*
223
    *  @private function getAdminPagesSave
224
    *  @param $moduleDirname
225
    *  @param $tableName
226
    *  @param $tableCategory
227
    *  @param $language
228
    *  @param $fields
229
    *  @param $fieldId
230
    *  @param $fieldMain
231
    *  @return string
232
    */
233
    private function getAdminPagesSave($moduleDirname, $tableName, $tableCategory, $language, $fields, $fieldId, $fieldMain, $t = '')
234
    {
235
        $ccFieldId = $this->getCamelCase($fieldId, false, true);
236
        $ret = $this->phpcode->getPhpCodeCommentLine('Security Check');
0 ignored issues
show
Bug introduced by
The method getPhpCodeCommentLine cannot be called on $this->phpcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
237
        $xoopsSecurityCheck = $this->xc->getXoopsCodeSecurityCheck('!');
0 ignored issues
show
Bug introduced by
The method getXoopsCodeSecurityCheck cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
238
        $securityError = $this->xc->getXoopsCodeSecurityErrors();
0 ignored issues
show
Bug introduced by
The method getXoopsCodeSecurityErrors cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
239
        $implode = $this->phpcode->getPhpCodeImplode(',', $securityError);
0 ignored issues
show
Bug introduced by
The method getPhpCodeImplode cannot be called on $this->phpcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
240
        $redirectError = $this->xc->getXoopsCodeRedirectHeader($tableName, '.php', '3', $implode, true, $t."\t");
0 ignored issues
show
Bug introduced by
The method getXoopsCodeRedirectHeader cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
241
        $ret .= $this->phpcode->getPhpCodeConditions($xoopsSecurityCheck, '', '', $redirectError, false, $t);
0 ignored issues
show
Bug introduced by
The method getPhpCodeConditions cannot be called on $this->phpcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
242
243
        $isset = $this->phpcode->getPhpCodeIsset($ccFieldId);
0 ignored issues
show
Bug introduced by
The method getPhpCodeIsset cannot be called on $this->phpcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
244
        $contentIf = $this->xc->getXoopsCodeGet($tableName, $ccFieldId, 'Obj', $tableName.'Handler', false, $t."\t");
0 ignored issues
show
Bug introduced by
The method getXoopsCodeGet cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
245
        $contentElse = $this->xc->getXoopsCodeObjHandlerCreate($tableName, "\t\t\t");
0 ignored issues
show
Bug introduced by
The method getXoopsCodeObjHandlerCreate cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
246
        $ret .= $this->phpcode->getPhpCodeConditions($isset, '', '', $contentIf, $contentElse, $t);
0 ignored issues
show
Bug introduced by
The method getPhpCodeConditions cannot be called on $this->phpcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
247
        $ret .= $this->phpcode->getPhpCodeCommentLine('Set Vars', null, "\t\t");
0 ignored issues
show
Bug introduced by
The method getPhpCodeCommentLine cannot be called on $this->phpcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
248
        foreach (array_keys($fields) as $f) {
249
            $fieldName = $fields[$f]->getVar('field_name');
250
            $fieldType = $fields[$f]->getVar('field_type');
251
            $fieldElement = $fields[$f]->getVar('field_element');
252
            if ($f > 0) { // If we want to hide field id
253
                switch ($fieldElement) {
254
                    case 5:
255
                    case 6:
256
                        $ret .= $this->xc->getXoopsCodeCheckBoxOrRadioYNSetVar($tableName, $fieldName, $t);
0 ignored issues
show
Bug introduced by
The method getXoopsCodeCheckBoxOrRadioYNSetVar cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
257
                        break;
258
                    case 10:
259
                        $ret .= $this->xc->getXoopsCodeImageListSetVar($moduleDirname, $tableName, $fieldName, $t);
0 ignored issues
show
Bug introduced by
The method getXoopsCodeImageListSetVar cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
260
                        break;
261
                    case 12:
262
                        $ret .= $this->xc->getXoopsCodeUrlFileSetVar($moduleDirname, $tableName, $fieldName, $t);
0 ignored issues
show
Bug introduced by
The method getXoopsCodeUrlFileSetVar cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
263
                        break;
264
                    case 13:
265
                        if (1 == $fields[$f]->getVar('field_main')) {
266
                            $fieldMain = $fieldName;
267
                        }
268
                        $ret .= $this->xc->getXoopsCodeUploadImageSetVar($moduleDirname, $tableName, $fieldName, $fieldMain, $t);
0 ignored issues
show
Bug introduced by
The method getXoopsCodeUploadImageSetVar cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
269
                        break;
270
                    case 14:
271
                        $ret .= $this->xc->getXoopsCodeUploadFileSetVar($moduleDirname, $tableName, $fieldName, $t);
0 ignored issues
show
Bug introduced by
The method getXoopsCodeUploadFileSetVar cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
272
                        break;
273
                    case 15:
274
                        $ret .= $this->xc->getXoopsCodeTextDateSelectSetVar($tableName, $fieldName, $t);
0 ignored issues
show
Bug introduced by
The method getXoopsCodeTextDateSelectSetVar cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
275
                        break;
276
                    default:
277
                        if ($fieldType == 2 || $fieldType == 7 || $fieldType == 8) {
278
                            $ret .= $this->xc->getXoopsCodeSetVar($tableName, $fieldName, "isset(\$_POST['{$fieldName}']) ? \$_POST['{$fieldName}'] : 0", $t);
0 ignored issues
show
Bug introduced by
The method getXoopsCodeSetVar cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
279
                        } else {
280
                            $ret .= $this->xc->getXoopsCodeSetVar($tableName, $fieldName, "\$_POST['{$fieldName}']", $t);
0 ignored issues
show
Bug introduced by
The method getXoopsCodeSetVar cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
281
                        }
282
                        break;
283
                }
284
            }
285
        }
286
        $ret .= $this->phpcode->getPhpCodeCommentLine('Insert Data', null, "\t\t");
0 ignored issues
show
Bug introduced by
The method getPhpCodeCommentLine cannot be called on $this->phpcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
287
        $insert = $this->xc->getXoopsCodeInsert($tableName, $tableName, 'Obj', true);
0 ignored issues
show
Bug introduced by
The method getXoopsCodeInsert cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
288
        $contentInsert = '';
289
        if ($tableCategory == 1) {
290
            $ucfTableName = ucfirst($tableName);
291
            $contentInsert = $this->xc->getXoopsCodeEqualsOperator('$newCatId', "\${$tableName}Obj->getNewInsertedId{$ucfTableName}()", null, false, $t."\t");
0 ignored issues
show
Bug introduced by
The method getXoopsCodeEqualsOperator cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
292
            $ucfFieldId = $this->getCamelCase($fieldId, true);
293
            $contentInsert .= $this->phpcode->getPhpCodeTernaryOperator('permId', "isset(\$_REQUEST['{$fieldId}'])", "\${$ccFieldId}", "\$new{$ucfFieldId}", $t."\t");
0 ignored issues
show
Bug introduced by
The method getPhpCodeTernaryOperator cannot be called on $this->phpcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
294
            $contentInsert .= $this->xc->getXoopsCodeEqualsOperator('$gpermHandler', "xoops_gethandler('groupperm')", null, true, $t."\t");
0 ignored issues
show
Bug introduced by
The method getXoopsCodeEqualsOperator cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
295
            $contentInsert .= $this->getPermissionsSave($moduleDirname, $fieldId, $ccFieldId, 'new'.$ucfFieldId);
296
            $contentInsert .= $this->getPermissionsSave($moduleDirname, $fieldId, $ccFieldId, 'new'.$ucfFieldId, 'submit');
297
            $contentInsert .= $this->getPermissionsSave($moduleDirname, $fieldId, $ccFieldId, 'new'.$ucfFieldId, 'approve');
298
        }
299
        $contentInsert .= $this->xc->getXoopsCodeRedirectHeader($tableName.'.php', '?op=list', '2', "{$language}FORM_OK", true, $t."\t");
0 ignored issues
show
Bug introduced by
The method getXoopsCodeRedirectHeader cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
300
        $ret .= $this->phpcode->getPhpCodeConditions($insert, '', '', $contentInsert, false, $t);
0 ignored issues
show
Bug introduced by
The method getPhpCodeConditions cannot be called on $this->phpcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
301
        $ret .= $this->phpcode->getPhpCodeCommentLine('Get Form', null, "\t\t");
0 ignored issues
show
Bug introduced by
The method getPhpCodeCommentLine cannot be called on $this->phpcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
302
        $ret .= $this->xc->getXoopsCodeTplAssign('error', "\${$tableName}Obj->getHtmlErrors()", true, $t);
0 ignored issues
show
Bug introduced by
The method getXoopsCodeTplAssign cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
303
        $ret .= $this->xc->getXoopsCodeGetForm('form', $tableName, 'Obj', $t);
0 ignored issues
show
Bug introduced by
The method getXoopsCodeGetForm cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
304
        $ret .= $this->xc->getXoopsCodeTplAssign('form', '$form->render()', true, $t);
0 ignored issues
show
Bug introduced by
The method getXoopsCodeTplAssign cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
305
306
        return $ret;
307
    }
308
309
    /*
310
    *  @private function getAdminPagesEdit
311
    *  @param $moduleDirname
312
    *  @param $tableName
313
    *  @param $tableFieldname
314
    *  @param $language
315
    *  @param $fieldId
316
    *  @param $fieldInForm
317
    *  @return string
318
    */
319
    private function getAdminPagesEdit($moduleDirname, $table, $language, $fieldId, $fieldInForm, $t = '')
320
    {
321
        $tableName = $table->getVar('table_name');
322
        $tableSoleName = $table->getVar('table_solename');
323
        $tableFieldname = $table->getVar('table_fieldname');
324
        $stuTableName = strtoupper($tableName);
325
        $ucfTableName = ucfirst($tableName);
0 ignored issues
show
Unused Code introduced by
$ucfTableName is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
326
        $stuTableSoleName = strtoupper($tableSoleName);
327
        $stuTableFieldname = strtoupper($tableFieldname);
0 ignored issues
show
Unused Code introduced by
$stuTableFieldname is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
328
        $ccFieldId = $this->getCamelCase($fieldId, false, true);
329
330
        $ret = $this->axc->getAdminTemplateMain($moduleDirname, $tableName);
0 ignored issues
show
Bug introduced by
The method getAdminTemplateMain cannot be called on $this->axc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
331
        $navigation = $this->axc->getAdminAddNavigation($tableName);
0 ignored issues
show
Bug introduced by
The method getAdminAddNavigation cannot be called on $this->axc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
332
        $ret .= $this->xc->getXoopsCodeTplAssign('navigation', $navigation, true, $t);
0 ignored issues
show
Bug introduced by
The method getXoopsCodeTplAssign cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
333
334
        if (in_array(1, $fieldInForm)) {
335
            $ret .= $this->axc->getAdminItemButton($language, $tableName, $stuTableSoleName, '?op=new', 'add', $t);
0 ignored issues
show
Bug introduced by
The method getAdminItemButton cannot be called on $this->axc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
336
            $ret .= $this->axc->getAdminItemButton($language, $tableName, $stuTableName, '', 'list', $t);
0 ignored issues
show
Bug introduced by
The method getAdminItemButton cannot be called on $this->axc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
337
            $ret .= $this->xc->getXoopsCodeTplAssign('buttons', '$adminMenu->renderButton()', true, $t);
0 ignored issues
show
Bug introduced by
The method getXoopsCodeTplAssign cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
338
        }
339
        $ret .= $this->phpcode->getPhpCodeCommentLine('Get Form', null, "\t\t");
0 ignored issues
show
Bug introduced by
The method getPhpCodeCommentLine cannot be called on $this->phpcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
340
        $ret .= $this->xc->getXoopsCodeGet($tableName, $ccFieldId, 'Obj', $tableName.'Handler', false, $t);
0 ignored issues
show
Bug introduced by
The method getXoopsCodeGet cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
341
        $ret .= $this->xc->getXoopsCodeGetForm('form', $tableName, 'Obj', $t);
0 ignored issues
show
Bug introduced by
The method getXoopsCodeGetForm cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
342
        $ret .= $this->xc->getXoopsCodeTplAssign('form', '$form->render()', true, $t);
0 ignored issues
show
Bug introduced by
The method getXoopsCodeTplAssign cannot be called on $this->xc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
343
344
        return $ret;
345
    }
346
347
    /*
348
    *  @private function getAdminPagesDelete
349
    *  @param $tableName
350
    *  @param $language
351
    *  @param $fieldId
352
    *  @param $fieldMain
353
    *  @return string
354
    */
355
    private function getAdminPagesDelete($tableName, $language, $fieldId, $fieldMain, $t = '')
356
    {
357
        return $this->axc->getAdminCodeCaseDelete($language, $tableName, $fieldId, $fieldMain, $t);
0 ignored issues
show
Bug introduced by
The method getAdminCodeCaseDelete cannot be called on $this->axc (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
358
    }
359
360
    /*
361
     * @public function render    
362
     * @param null
363
     *
364
     * @return bool|string
365
     */
366
    public function render()
367
    {
368
        $module = $this->getModule();
369
        $table = $this->getTable();
370
        $filename = $this->getFileName();
371
        $moduleDirname = $module->getVar('mod_dirname');
372
        $tableName = $table->getVar('table_name');
373
        $tableCategory = $table->getVar('table_category');
374
        $language = $this->getLanguage($moduleDirname, 'AM');
375
        $fields = $this->tf->getTableFields($table->getVar('table_mid'), $table->getVar('table_id'));
0 ignored issues
show
Bug introduced by
The method getTableFields cannot be called on $this->tf (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
376
        $fieldInForm = null;
377
        foreach (array_keys($fields) as $f) {
378
            $fieldName = $fields[$f]->getVar('field_name');
379
            $fieldInForm[] = $fields[$f]->getVar('field_inform');
380
            if (0 == $f) {
381
                $fieldId = $fieldName;
382
            }
383
            if (1 == $fields[$f]->getVar('field_main')) {
384
                $fieldMain = $fieldName;
385
            }
386
        }
387
        $content = $this->getHeaderFilesComments($module, $filename);
388
        $content .= $this->getAdminPagesHeader($moduleDirname, $tableName, $fieldId);
0 ignored issues
show
Bug introduced by
The variable $fieldId does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
389
        $list = $this->getAdminPagesList($moduleDirname, $table, $language, $fields, $fieldId, $fieldInForm, $fieldMain);
0 ignored issues
show
Bug introduced by
The variable $fieldMain does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
390
        if (in_array(1, $fieldInForm)) {
391
            $new = $this->getAdminPagesNew($moduleDirname, $tableName, $fieldInForm, $language, "\t\t");
392
            $save = $this->getAdminPagesSave($moduleDirname, $tableName, $tableCategory, $language, $fields, $fieldId, $fieldMain, "\t\t");
393
            $edit = $this->getAdminPagesEdit($moduleDirname, $table, $language, $fieldId, $fieldInForm, "\t\t");
394
        }
395
        $delete = $this->getAdminPagesDelete($tableName, $language, $fieldId, $fieldMain, "\t\t");
396
397
        $cases = array('list' => array($list),
398
                        'new' => array($new),
0 ignored issues
show
Bug introduced by
The variable $new does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
399
                        'save' => array($save),
0 ignored issues
show
Bug introduced by
The variable $save does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
400
                        'edit' => array($edit),
0 ignored issues
show
Bug introduced by
The variable $edit does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
401
                        'delete' => array($delete), );
402
        $content .= $this->getAdminPagesSwitch($cases);
403
        $content .= $this->getInclude('footer');
404
        //
405
        $this->tf->create($moduleDirname, 'admin', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED);
0 ignored issues
show
Bug introduced by
The method create cannot be called on $this->tf (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
406
407
        return $this->tf->renderFile();
0 ignored issues
show
Bug introduced by
The method renderFile cannot be called on $this->tf (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
408
    }
409
}
410