Completed
Push — master ( 1a43b9...76063f )
by Gino
07:55 queued 03:52
created

AdminPages::getAdminPagesList()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 41
Code Lines 33

Duplication

Lines 4
Ratio 9.76 %
Metric Value
dl 4
loc 41
rs 8.8571
cc 2
eloc 33
nc 2
nop 7
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 28 and the first side effect is on line 24.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
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
defined('XOOPS_ROOT_PATH') || die('Restricted access');
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 $adminxoopscode;
34
35
    /*
36
    * @var string
37
    */
38
    private $t2 = "\t\t";
39
40
    /*
41
    *  @public function constructor
42
    *  @param null
43
    */
44
    /**
45
     *
46
     */
47
    public function __construct()
48
    {
49
        parent::__construct();
50
        $this->tdmcfile = 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 $tdmcfile.

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...
51
        $this->phpcode = TDMCreatePhpCode::getInstance();
0 ignored issues
show
Bug introduced by
The property phpcode does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
52
        $this->xoopscode = TDMCreateXoopsCode::getInstance();
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
53
        $this->adminxoopscode = 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 $adminxoopscode.

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...
54
    }
55
56
    /*
57
    *  @static function &getInstance
58
    *  @param null
59
    */
60
    /**
61
     * @return AdminPages
62
     */
63
    public static function &getInstance()
64
    {
65
        static $instance = false;
66
        if (!$instance) {
67
            $instance = new self();
68
        }
69
70
        return $instance;
71
    }
72
73
    /*
74
    *  @public function write
75
    *  @param string $module
76
    *  @param string $table
77
    */
78
    public function write($module, $table)
79
    {
80
        $this->setModule($module);
81
        $this->setTable($table);
82
    }
83
84
    /*
85
    *  @private function getAdminPagesHeader
86
    *  @param string $moduleDirname
87
    *  @param string $tableName
88
    *  @param $fieldId
89
    *  @return string
90
    */
91
    private function getAdminPagesHeader($moduleDirname, $tableName, $fieldId)
92
    {
93
        $ucfModuleDirname = ucfirst($moduleDirname);
0 ignored issues
show
Unused Code introduced by
$ucfModuleDirname 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...
94
        $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...
95
        $ccFieldId = $this->getCamelCase($fieldId, false, true);
96
        $ret = $this->getInclude();
97
        $ret .= $this->getCommentLine('It recovered the value of argument op in URL$');
98
        $ret .= $this->xoopscode->getXoopsCodeXoopsRequest('op', 'op', 'list');
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
99
        $ret .= $this->getCommentLine("Request {$fieldId}");
100
        $ret .= $this->xoopscode->getXoopsCodeXoopsRequest($ccFieldId, $fieldId, '', 'Int');
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
101
102
        return $ret;
103
    }
104
105
    /*
106
     *  @private function getAdminPagesSwitch
107
     *  @param $cases
108
     *
109
     * @return string
110
     */
111
    private function getAdminPagesSwitch($cases = array())
112
    {
113
        $contentSwitch = $this->phpcode->getPhpCodeCaseSwitch($cases, true);
114
115
        return $this->phpcode->getPhpCodeSwitch('op', $contentSwitch);
116
    }
117
118
    /*
119
    *  @private function getAdminPagesList
120
    *  @param $moduleDirname
121
    *  @param $table
122
    *  @param $tableFieldname
123
    *  @param $language
124
    *  @param $fields
125
    *  @param $fieldId
126
    *  @param $fieldInForm
127
    *  @param $fieldMain
128
    *  @return string
129
    */
130
    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...
131
    {
132
        $stuModuleDirname = strtoupper($moduleDirname);
133
        $tableName = $table->getVar('table_name');
134
        $tableSoleName = $table->getVar('table_solename');
135
        $tableFieldname = $table->getVar('table_fieldname');
136
        $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...
137
        $stuTableName = strtoupper($tableName);
138
        $stuTableSoleName = strtoupper($tableSoleName);
139
        $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...
140
        $tableAutoincrement = $table->getVar('table_autoincrement');
0 ignored issues
show
Unused Code introduced by
$tableAutoincrement 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...
141
142
        $ret = $this->xoopscode->getXoopsCodeXoopsRequest('start', 'start', '0', 'Int');
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
143
        $adminpager = $this->xoopscode->getXoopsCodeGetConfig($moduleDirname, 'adminpager');
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
144
        $ret .= $this->t2.$this->xoopscode->getXoopsCodeXoopsRequest('limit', 'limit', $adminpager, 'Int');
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
145
        $ret .= $this->t2.$this->adminxoopscode->getAdminTemplateMain($moduleDirname, $tableName);
0 ignored issues
show
Bug introduced by
The method getAdminTemplateMain cannot be called on $this->adminxoopscode (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
        $navigation = $this->adminxoopscode->getAdminAddNavigation($tableName);
0 ignored issues
show
Bug introduced by
The method getAdminAddNavigation cannot be called on $this->adminxoopscode (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->t2.$this->xoopscode->getXoopsCodeTplAssign('navigation', $navigation);
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
148
149 View Code Duplication
        if (1 == $fieldInForm) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
150
            $ret .= $this->t2.$this->adminxoopscode->getAdminItemButton($language, $tableName, $stuTableSoleName, '?op=new', 'add');
0 ignored issues
show
Bug introduced by
The method getAdminItemButton cannot be called on $this->adminxoopscode (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
            $ret .= $this->t2.$this->xoopscode->getXoopsCodeTplAssign('buttons', '$adminMenu->renderButton()');
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
152
        }
153
154
        $ret .= $this->t2.$this->xoopscode->getXoopsCodeObjHandlerCount($tableName);
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
155
        $ret .= $this->t2.$this->xoopscode->getXoopsCodeObjHandlerAll($tableName, '', '$start', '$limit');
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
156
        $ret .= $this->t2.$this->xoopscode->getXoopsCodeTplAssign("{$tableName}_count", "\${$tableName}Count");
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
157
        $ret .= $this->t2.$this->xoopscode->getXoopsCodeTplAssign("{$moduleDirname}_url", "{$stuModuleDirname}_URL");
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
158
        $ret .= $this->t2.$this->xoopscode->getXoopsCodeTplAssign("{$moduleDirname}_upload_url", "{$stuModuleDirname}_UPLOAD_URL");
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
159
160
        $ret .= $this->t2.$this->getCommentLine('Table view');
161
		$contentForeach = $this->xoopscode->getXoopsCodeGetValues($tableName, $tableSoleName);
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
162
		$contentForeach .= $this->xoopscode->getXoopsCodeXoopsTplAppend("{$tableName}_list", "\${$tableSoleName}");
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
163
		$contentForeach .= $this->phpcode->getPhpCodeUnset($tableSoleName);
164
		$condIf = $this->phpcode->getPhpCodeForeach("{$tableName}All", true, false, 'i', $contentForeach);
165
		$condIf .= $this->xoopscode->getXoopsCodePageNav($tableName);
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
166
		$condElse = $this->xoopscode->getXoopsCodeTplAssign('error', "{$language}THEREARENT_{$stuTableName}");
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
167
		$ret .= $this->phpcode->getPhpCodeConditions("\${$tableName}Count", ' > ', '0', $condIf, $condElse, "\t\t");
168
		
169
        return $ret;
170
    }
171
172
    /*
173
    *  @private function getAdminPagesNew
174
    *  @param string $moduleDirname
175
    *  @param string $tableName
176
    *  @param string $fieldInForm
177
    *  @param string $language
178
    *  @return string
179
    */
180
    private function getAdminPagesNew($moduleDirname, $tableName, $tableSoleName, $fieldInForm, $language)
181
    {
182
        $stuTableName = strtoupper($tableName);
0 ignored issues
show
Unused Code introduced by
$stuTableName 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...
183
        $stuTableSoleName = strtoupper($tableSoleName);
184
        $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...
185
186
        $ret = $this->t2.$this->adminxoopscode->getAdminTemplateMain($moduleDirname, $tableName);
0 ignored issues
show
Bug introduced by
The method getAdminTemplateMain cannot be called on $this->adminxoopscode (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->adminxoopscode->getAdminAddNavigation($tableName);
0 ignored issues
show
Bug introduced by
The method getAdminAddNavigation cannot be called on $this->adminxoopscode (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->t2.$this->xoopscode->getXoopsCodeTplAssign('navigation', $navigation);
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
189
190 View Code Duplication
        if (1 == $fieldInForm) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
191
            $ret .= $this->t2.$this->adminxoopscode->getAdminItemButton($language, $tableName, $stuTableSoleName, '', 'list');
0 ignored issues
show
Bug introduced by
The method getAdminItemButton cannot be called on $this->adminxoopscode (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->t2.$this->xoopscode->getXoopsCodeTplAssign('buttons', '$adminMenu->renderButton()');
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
193
        }
194
		$ret .= $this->t2.$this->getCommentLine('Get Form');
195
		$ret .= $this->t2.$this->xoopscode->getXoopsCodeObjHandlerCreate($tableName);
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
196
		$ret .= $this->t2.$this->xoopscode->getXoopsCodeGetForm('form', $tableName, 'Obj');
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
197
		$ret .= $this->t2.$this->xoopscode->getXoopsCodeTplAssign('form', '$form->render()');
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
198
        
199
        return $ret;
200
    }
201
202
    /*
203
    *  @private function getAdminPagesSave
204
    *  @param string $moduleDirname
205
    *  @param string $tableName
206
    *  @param string $language
207
    *  @param string $fields
208
    *  @param string $fieldId
209
    *  @param string $fieldMain
210
    *  @return string
211
    */
212
    private function getAdminPagesSave($moduleDirname, $tableName, $language, $fields, $fieldId, $fieldMain)
213
    {
214
        $ccFieldId = $this->getCamelCase($fieldId, false, true);
215
        $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...
216
217
        $ret = $this->phpcode->getPhpCodeCommentLine('Set Vars');
218
        $xoopsSecurityCheck = $this->xoopscode->getXoopsCodeSecurityCheck();
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
219
        $securityError = $this->xoopscode->getXoopsCodeSecurityErrors();
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
220
        $implode = $this->phpcode->getPhpCodeImplode(',', $securityError);
221
        $redirectError = $this->xoopscode->getXoopsCodeRedirectHeader($tableName, '', '3', $implode);
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
222
        $ret .= $this->phpcode->getPhpCodeConditions($xoopsSecurityCheck, '', '', $redirectError, false, "\t");
223
224
        $isset = $this->phpcode->getPhpCodeIsset($ccFieldId);
225
        $contentIf = $this->xoopscode->getXoopsCodeGet($tableName, $ccFieldId, 'Obj', true);
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
226
        $contentElse = $this->xoopscode->getXoopsCodeObjHandlerCreate($tableName);
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
227
        $ret .= $this->phpcode->getPhpCodeConditions($isset, '', '', $contentIf, $contentElse, "\t");
228
229
        foreach (array_keys($fields) as $f) {
230
            $fieldName = $fields[$f]->getVar('field_name');
0 ignored issues
show
Bug introduced by
The method getVar cannot be called on $fields[$f] (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...
231
            $fieldType = $fields[$f]->getVar('field_type');
0 ignored issues
show
Bug introduced by
The method getVar cannot be called on $fields[$f] (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...
232
            $fieldElement = $fields[$f]->getVar('field_element');
0 ignored issues
show
Bug introduced by
The method getVar cannot be called on $fields[$f] (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...
233
            if ($f > 0) { // If we want to hide field id
234
                switch ($fieldElement) {
235
                    case 5:
236
                    case 6:
237
                        $ret .= $this->xoopscode->getXoopsCodeCheckBoxOrRadioYNSetVar($tableName, $fieldName);
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
238
                        break;
239
                    case 10:
240
                        $ret .= $this->xoopscode->getXoopsCodeImageListSetVar($moduleDirname, $tableName, $fieldName);
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
241
                        break;
242
                    case 12:
243
                        $ret .= $this->xoopscode->getXoopsCodeUrlFileSetVar($moduleDirname, $tableName, $fieldName);
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
244
                        break;
245
                    case 13:
246
                        if (1 == $fields[$f]->getVar('field_main')) {
0 ignored issues
show
Bug introduced by
The method getVar cannot be called on $fields[$f] (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
                            $fieldMain = $fieldName;
248
                        }
249
                        $ret .= $this->xoopscode->getXoopsCodeUploadImageSetVar($moduleDirname, $tableName, $fieldName, $fieldMain);
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
250
                        break;
251
                    case 14:
252
                        $ret .= $this->xoopscode->getXoopsCodeUploadFileSetVar($moduleDirname, $tableName, $fieldName);
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
253
                        break;
254
                    case 15:
255
                        $ret .= $this->xoopscode->getXoopsCodeTextDateSelectSetVar($tableName, $fieldName);
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
256
                        break;
257
                    default:
258
                        if ($fieldType == 2 || $fieldType == 7 || $fieldType == 8) {
259
							
260
                            $ret .= $this->xoopscode->getXoopsCodeSetVar($tableName, $fieldName, "isset(\$_POST['{$fieldName}']) ? \$_POST['{$fieldName}'] : 0");
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
261
                        } else {
262
                            $ret .= $this->xoopscode->getXoopsCodeSetVar($tableName, $fieldName, "\$_POST['{$fieldName}']");
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
263
                        }
264
                        break;
265
                }
266
            }
267
        }
268
		$ret .= $this->t2.$this->getCommentLine('Insert Data');
269
		$insert = $this->xoopscode->getXoopsCodeInsert($tableName, $tableName);
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
270
        $confirmOk = $this->xoopscode->getXoopsCodeRedirectHeader($tableName, '?op=list', '2', "{$language}FORM_OK");
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
271
        $ret .= $this->phpcode->getPhpCodeConditions($insert, '', '', $confirmOk, false, "\t");
272
		$ret .= $this->t2.$this->getCommentLine('Get Form');
273
		$ret .= $this->t2.$this->xoopscode->getXoopsCodeTplAssign('error', "\${$tableName}Obj->getHtmlErrors()");
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
274
		$ret .= $this->t2.$this->xoopscode->getXoopsCodeGetForm('form', $tableName, 'Obj');
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
275
		$ret .= $this->t2.$this->xoopscode->getXoopsCodeTplAssign('form', '$form->render()');
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
276
		
277
        return $ret;
278
    }
279
280
    /*
281
    *  @private function getAdminPagesEdit
282
    *  @param string $moduleDirname
283
    *  @param string $tableName
0 ignored issues
show
Bug introduced by
There is no parameter named $tableName. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
284
    *  @param string $tableFieldname
0 ignored issues
show
Bug introduced by
There is no parameter named $tableFieldname. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
285
    *  @param string $language
286
    *  @param string $fieldId
287
    *  @param string $fieldInForm
288
    *  @return string
289
    */
290
    private function getAdminPagesEdit($moduleDirname, $table, $language, $fieldId, $fieldInForm)
291
    {
292
        $tableName = $table->getVar('table_name');
293
        $tableSoleName = $table->getVar('table_solename');
294
        $tableFieldname = $table->getVar('table_fieldname');
295
        $stuTableName = strtoupper($tableName);
0 ignored issues
show
Unused Code introduced by
$stuTableName 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...
296
        $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...
297
        $stuTableSoleName = strtoupper($tableSoleName);
298
        $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...
299
        $ccFieldId = $this->getCamelCase($fieldId, false, true);
300
301
        $ret = $this->t2.$this->adminxoopscode->getAdminTemplateMain($moduleDirname, $tableName);
0 ignored issues
show
Bug introduced by
The method getAdminTemplateMain cannot be called on $this->adminxoopscode (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
        $navigation = $this->adminxoopscode->getAdminAddNavigation($tableName);
0 ignored issues
show
Bug introduced by
The method getAdminAddNavigation cannot be called on $this->adminxoopscode (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->t2.$this->xoopscode->getXoopsCodeTplAssign('navigation', $navigation);
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
304
305
        if (1 == $fieldInForm) {
306
            $ret .= $this->t2.$this->adminxoopscode->getAdminItemButton($language, $tableName, $stuTableSoleName, '?op=new', 'add');
0 ignored issues
show
Bug introduced by
The method getAdminItemButton cannot be called on $this->adminxoopscode (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...
307
            $ret .= $this->t2.$this->adminxoopscode->getAdminItemButton($language, $tableName, $stuTableSoleName, '', 'list');
0 ignored issues
show
Bug introduced by
The method getAdminItemButton cannot be called on $this->adminxoopscode (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...
308
            $ret .= $this->t2.$this->xoopscode->getXoopsCodeTplAssign('buttons', '$adminMenu->renderButton()');
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
309
        }
310
		$ret .= $this->t2.$this->getCommentLine('Get Form');
311
		$ret .= $this->t2.$this->xoopscode->getXoopsCodeGet($tableName, $ccFieldId, 'Obj', true);
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
312
		$ret .= $this->t2.$this->xoopscode->getXoopsCodeGetForm('form', $tableName, 'Obj');
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
313
		$ret .= $this->t2.$this->xoopscode->getXoopsCodeTplAssign('form', '$form->render()');
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
314
        
315
        return $ret;
316
    }
317
318
    /*
319
    *  @private function getAdminPagesDelete
320
    *  @param string $tableName
321
    *  @param string $language
322
    *  @param string $fieldId
323
    *  @param string $fieldMain
324
    *  @return string
325
    */
326
    private function getAdminPagesDelete($tableName, $language, $fieldId, $fieldMain)
327
    {
328
        return $this->xoopscode->getXoopsCodeCaseDelete($language, $tableName, $fieldId, $fieldMain);
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
329
    }
330
331
    /*
332
    *  @private function getAdminPagesUpdate
333
    *  @param string $language
334
    *  @param string $tableName
335
    *  @param string $fieldId
336
    *  @param string $fieldName
337
    *  @return string
338
    */
339
    private function getAdminPagesUpdate($language, $tableName, $fieldId, $fieldName)
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
340
    {
341
		return $this->xoopscode->getXoopsCodeUpdate($language, $tableName, $fieldId, $fieldName);
0 ignored issues
show
Bug introduced by
The property xoopscode does not seem to exist. Did you mean adminxoopscode?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
342
    }
343
344
    /*
345
    *  @public function render
346
    *  @param null
347
    */
348
    /**
349
     * @param $filename
350
     *
351
     * @return bool|string
352
     */
353
    public function renderFile($filename)
354
    {
355
        $module = $this->getModule();
356
        $table = $this->getTable();
357
        $moduleDirname = $module->getVar('mod_dirname');
358
        $tableName = $table->getVar('table_name');
359
        $tableSoleName = $table->getVar('table_solename');
360
        $language = $this->getLanguage($moduleDirname, 'AM');
361
        $fields = $this->tdmcfile->getTableFields($table->getVar('table_mid'), $table->getVar('table_id'));
0 ignored issues
show
Bug introduced by
The method getTableFields cannot be called on $this->tdmcfile (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...
362 View Code Duplication
        foreach (array_keys($fields) as $f) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
363
            $fieldName = $fields[$f]->getVar('field_name');
364
            $fieldInForm = $fields[$f]->getVar('field_inform');
365
            if (0 == $f) {
366
                $fieldId = $fieldName;
367
            }
368
            if (1 == $fields[$f]->getVar('field_main')) {
369
                $fieldMain = $fieldName;
370
            }
371
        }
372
        $content = $this->getHeaderFilesComments($module, $filename);
373
        $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...
374
        $list = $this->getAdminPagesList($moduleDirname, $table, $language, $fields, $fieldId, $fieldInForm, $fieldMain);
0 ignored issues
show
Bug introduced by
The variable $fieldInForm 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...
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...
375
        if (1 == $fieldInForm) {
376
            $new = $this->getAdminPagesNew($moduleDirname, $tableName, $tableSoleName, $fieldInForm, $language);
377
            $save = $this->getAdminPagesSave($moduleDirname, $tableName, $language, $fields, $fieldId, $fieldMain);
378
            $edit = $this->getAdminPagesEdit($moduleDirname, $table, $language, $fieldId, $fieldInForm);
379
        }
380
        $delete = $this->getAdminPagesDelete($tableName, $language, $fieldId, $fieldMain);
381
382
        $cases = array('list' => array($list),
383
                        '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...
384
                        '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...
385
                        '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...
386
                        'delete' => array($delete) );
387
        $content .= $this->getAdminPagesSwitch($cases);
388
        $content .= $this->getInclude('footer');
389
        //
390
        $this->tdmcfile->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->tdmcfile (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...
391
392
        return $this->tdmcfile->renderFile();
0 ignored issues
show
Bug introduced by
The method renderFile cannot be called on $this->tdmcfile (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...
393
    }
394
}
395