Psalm config update, add JS object deep copy function

This commit is contained in:
Clemens Schwaighofer
2020-06-25 15:05:32 +09:00
parent 0fcbe91ea2
commit 9c242ed1b9
2 changed files with 28 additions and 1 deletions

View File

@@ -342,6 +342,31 @@ function valueInObject(object, value)
// }) ? true : false;
}
/**
* true deep copy for Javascript objects
* if Object.assign({}, obj) is not working (shallow)
* or if JSON.parse(JSON.stringify(obj)) is failing
* @param {Object} inObject Object to copy
* @return {Object} Copied Object
*/
function deepCopyFunction(inObject)
{
var outObject, value, key;
if (typeof inObject !== "object" || inObject === null) {
return inObject; // Return the value if inObject is not an object
}
// Create an array or object to hold the values
outObject = Array.isArray(inObject) ? [] : {};
// loop over ech entry in object
for (key in inObject) {
value = inObject[key];
// Recursively (deep) copy for nested objects, including arrays
outObject[key] = deepCopyFunction(value);
}
return outObject;
}
/**
* checks if a DOM element actually exists
* @param {String} id Element id to check for

View File

@@ -6,6 +6,7 @@
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
autoloader="lib/autoloader.php"
errorLevel="8"
>
<projectFiles>
<file name="admin/class_test.php" />
@@ -28,7 +29,8 @@
<directory name="tmp" />
<directory name="log" />
<directory name="media" />
<directory name="lib/pChart" />
<directory name="lib/FileUpload" />
<directory name="lib/pChart" />
<directory name="lib/pChart2.1.4" />
<directory name="lib/Smarty" />
<directory name="lib/smarty-3.1.30" />