PMCORE-3853 Using array_key_exists() on objects is deprecated. Instead either isset() or property_exists() should be used.

This commit is contained in:
Roly Gutierrez
2022-08-31 11:32:16 -04:00
parent 91638296ac
commit b8b9722374
10 changed files with 20 additions and 28 deletions

View File

@@ -339,7 +339,7 @@ class pagedTable
// Config attributes from XMLFORM file // Config attributes from XMLFORM file
$myAttributes = get_class_vars(get_class($this)); $myAttributes = get_class_vars(get_class($this));
foreach ($this->xmlForm->xmlform->tree->attribute as $atrib => $value) { foreach ($this->xmlForm->xmlform->tree->attribute as $atrib => $value) {
if (array_key_exists($atrib, $myAttributes)) { if (is_array($myAttributes) && array_key_exists($atrib, $myAttributes)) {
eval('settype($value,gettype($this->' . $atrib . '));'); eval('settype($value,gettype($this->' . $atrib . '));');
if ($value !== '') { if ($value !== '') {
eval('$this->' . $atrib . '=$value;'); eval('$this->' . $atrib . '=$value;');

View File

@@ -425,14 +425,7 @@ class XmlFormField
$fields = []; $fields = [];
if (isset($this->formula)) { if (isset($this->formula)) {
preg_match_all("/\b[a-zA-Z][a-zA-Z_0-9]*\b/", $this->formula, $matches, PREG_PATTERN_ORDER); preg_match_all("/\b[a-zA-Z][a-zA-Z_0-9]*\b/", $this->formula, $matches, PREG_PATTERN_ORDER);
/* if ($this->formula!=''){
var_dump($this->formula);
var_dump($matches);
var_dump(array_keys($this->owner->fields));
die;
}*/
foreach ($matches[0] as $field) { foreach ($matches[0] as $field) {
//if (array_key_exists( $this->owner->fields, $field ))
$fields[] = $field; $fields[] = $field;
} }
} }

View File

@@ -83,7 +83,7 @@ class DBArrayResultSet extends ResultSetCommon implements ResultSet
public function getString($column) public function getString($column)
{ {
$idx = (is_int($column) ? $column - 1 : $column); $idx = (is_int($column) ? $column - 1 : $column);
if (!array_key_exists($idx, $this->fields)) { if (is_array($this->fields) && !array_key_exists($idx, $this->fields)) {
throw new SQLException("Invalid resultset column: " . $column); throw new SQLException("Invalid resultset column: " . $column);
} }
if ($this->fields[$idx] === null) { if ($this->fields[$idx] === null) {

View File

@@ -95,7 +95,7 @@ class pakeSimpletestTask
{ {
$types = array('text', 'html', 'xml'); $types = array('text', 'html', 'xml');
$type = 'text'; $type = 'text';
if (array_key_exists(0, $args) && in_array($args[0], $types)) if (is_array($args) && array_key_exists(0, $args) && in_array($args[0], $types))
{ {
$type = $args[0]; $type = $args[0];
array_shift($args); array_shift($args);

View File

@@ -1348,7 +1348,7 @@ class DB_common extends PEAR
if (!is_array($row = $res->fetchRow($fetchmode))) { if (!is_array($row = $res->fetchRow($fetchmode))) {
$ret = array(); $ret = array();
} else { } else {
if (!array_key_exists($col, $row)) { if (is_array($row) && !array_key_exists($col, $row)) {
$ret =& $this->raiseError(DB_ERROR_NOSUCHFIELD); $ret =& $this->raiseError(DB_ERROR_NOSUCHFIELD);
} else { } else {
$ret = array($row[$col]); $ret = array($row[$col]);

View File

@@ -553,7 +553,7 @@ function upgradeContent($args, $opts)
* Verify if we need to execute an external program for each workspace * Verify if we need to execute an external program for each workspace
* If we apply the command for all workspaces, we will need to execute one by one by redefining the constants * If we apply the command for all workspaces, we will need to execute one by one by redefining the constants
* @param string $args, workspaceName that we need to apply the database-upgrade * @param string $args, workspaceName that we need to apply the database-upgrade
* @param string $opts * @param array $opts
* *
* @return void * @return void
*/ */

View File

@@ -68,7 +68,14 @@ class Configurations // extends Configuration
} }
foreach ($from as $k => $v) { foreach ($from as $k => $v) {
if (isset($v) && array_key_exists($k, $object)) { $existKeyInObject = false;
if (is_object($object)) {
$existKeyInObject = property_exists($object, $k);
}
if (is_array($object)) {
$existKeyInObject = array_key_exists($k, $object);
}
if (isset($v) && $existKeyInObject) {
if (is_object($v)) { if (is_object($v)) {
throw new Exception('Object is not permited inside configuration array.'); throw new Exception('Object is not permited inside configuration array.');
} }

View File

@@ -210,7 +210,7 @@ class PropelTable
// Config attributes from XMLFORM file // Config attributes from XMLFORM file
$myAttributes = get_class_vars(get_class($this)); $myAttributes = get_class_vars(get_class($this));
foreach ($this->xmlForm->xmlform->tree->attribute as $atrib => $value) { foreach ($this->xmlForm->xmlform->tree->attribute as $atrib => $value) {
if (array_key_exists($atrib, $myAttributes)) { if (is_array($myAttributes) && array_key_exists($atrib, $myAttributes)) {
eval('settype($value, gettype($this->' . $atrib . '));'); eval('settype($value, gettype($this->' . $atrib . '));');
if ($value !== '') { if ($value !== '') {
eval('$this->' . $atrib . '=$value;'); eval('$this->' . $atrib . '=$value;');

View File

@@ -722,14 +722,6 @@ class Bpmn extends Handler
public function updateEvent($evnUid, array $data) public function updateEvent($evnUid, array $data)
{ {
/*if (array_key_exists("EVN_CANCEL_ACTIVITY", $data)) {
$data["EVN_CANCEL_ACTIVITY"] = $data["EVN_CANCEL_ACTIVITY"] ? 1 : 0;
}
if (array_key_exists("EVN_WAIT_FOR_COMPLETION", $data)) {
$data["EVN_WAIT_FOR_COMPLETION"] = $data["EVN_WAIT_FOR_COMPLETION"] ? 1 : 0;
}*/
try { try {
self::log("Update Event: $evnUid", "With data: ", $data); self::log("Update Event: $evnUid", "With data: ", $data);

View File

@@ -47,13 +47,13 @@ class Test extends Api
'age' => '' 'age' => ''
); );
if (array_key_exists('name', $request_data)) { if (is_array($request_data) && array_key_exists('name', $request_data)) {
$this->data[$id]['name'] = $request_data['name']; $this->data[$id]['name'] = $request_data['name'];
} }
if (array_key_exists('lastname', $request_data)) { if (is_array($request_data) && array_key_exists('lastname', $request_data)) {
$this->data[$id]['lastname'] = $request_data['lastname']; $this->data[$id]['lastname'] = $request_data['lastname'];
} }
if (array_key_exists('age', $request_data)) { if (is_array($request_data) && array_key_exists('age', $request_data)) {
$this->data[$id]['age'] = $request_data['age']; $this->data[$id]['age'] = $request_data['age'];
} }
@@ -65,13 +65,13 @@ class Test extends Api
public function put($id, $request_data = null) public function put($id, $request_data = null)
{ {
if (array_key_exists($id, $this->data)) { if (array_key_exists($id, $this->data)) {
if (array_key_exists('name', $request_data)) { if (is_array($request_data) && array_key_exists('name', $request_data)) {
$this->data[$id]['name'] = $request_data['name']; $this->data[$id]['name'] = $request_data['name'];
} }
if (array_key_exists('lastname', $request_data)) { if (is_array($request_data) && array_key_exists('lastname', $request_data)) {
$this->data[$id]['lastname'] = $request_data['lastname']; $this->data[$id]['lastname'] = $request_data['lastname'];
} }
if (array_key_exists('age', $request_data)) { if (is_array($request_data) && array_key_exists('age', $request_data)) {
$this->data[$id]['age'] = $request_data['age']; $this->data[$id]['age'] = $request_data['age'];
} }
$this->saveData(); $this->saveData();