Remove deprecated create_function and use ReflectionClass instead.

This commit is contained in:
kj 2020-04-09 18:22:47 -04:00
parent a2503adba2
commit 5d2612214d
1 changed files with 10 additions and 3 deletions

View File

@ -175,9 +175,16 @@ class ModelMySQL {
* @return array
* Contiene los atributos indexados del objeto actual.
*/
private function getVars() { // Source: https://stackoverflow.com/questions/10009015/show-all-public-attributes-name-and-value-of-an-object
$get_vars_proxy = create_function('$obj', 'return get_object_vars($obj);');
$result = $get_vars_proxy($this);
private function getVars() {
$reflection = new \ReflectionClass($this);
$properties = $reflection->getProperties(\ReflectionProperty::IS_PUBLIC);
$result = [];
foreach($properties as $property) {
$att = $property->name;
$result[$att] = $this->$att;
}
foreach ($this->ignoreSave as $del) {
unset($result[$del]);
}