Fix packet password on exports, move __unserialize() to EncodeUTF8::decode

This commit is contained in:
Deon George
2021-09-08 22:07:00 +10:00
parent dbbfe46cb9
commit 03c4b87cdd
3 changed files with 42 additions and 42 deletions

View File

@@ -7,6 +7,38 @@ namespace App\Traits;
trait EncodeUTF8
{
private function decode(array $values): void
{
$properties = (new \ReflectionClass($this))->getProperties();
$class = get_class($this);
foreach ($properties as $property) {
if ($property->isStatic()) {
continue;
}
$name = $property->getName();
$decode = in_array($name,self::cast_utf8);
if ($property->isPrivate()) {
$name = "\0{$class}\0{$name}";
} elseif ($property->isProtected()) {
$name = "\0*\0{$name}";
}
if (! array_key_exists($name,$values)) {
continue;
}
$property->setAccessible(true);
$property->setValue(
$this,$decode ? utf8_decode($values[$name]) : $values[$name]
);
}
}
private function encode(): array
{
$values = [];