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

View File

@ -175,9 +175,16 @@ class ModelMySQL {
* @return array * @return array
* Contiene los atributos indexados del objeto actual. * 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 private function getVars() {
$get_vars_proxy = create_function('$obj', 'return get_object_vars($obj);'); $reflection = new \ReflectionClass($this);
$result = $get_vars_proxy($this); $properties = $reflection->getProperties(\ReflectionProperty::IS_PUBLIC);
$result = [];
foreach($properties as $property) {
$att = $property->name;
$result[$att] = $this->$att;
}
foreach ($this->ignoreSave as $del) { foreach ($this->ignoreSave as $del) {
unset($result[$del]); unset($result[$del]);
} }