diff --git a/includes/entities/class-fs-user.php b/includes/entities/class-fs-user.php index 3aed0982..679acbda 100755 --- a/includes/entities/class-fs-user.php +++ b/includes/entities/class-fs-user.php @@ -61,6 +61,58 @@ function __wakeup() { } } + + /** + * Prepare object data for serialization. + * Only includes explicitly declared properties. + * + * @return array Serialized data + */ + public function __serialize() + { + // Only serialize properties declared in this class. + $props = array('email', 'first', 'last', 'is_verified', 'customer_id', 'gross'); + $out = array(); + foreach ($props as $p) + { + if (property_exists($this, $p)) + $out[$p] = $this->$p; + + } + + return $out; + } + + /** + * Restore object state from serialized data. + * Safely populates known properties only. + * + * @param array $data Serialized data + * + * @return void + */ + public function __unserialize(array $data) + { + // Populate only known properties for forward-compat and safety. + if (array_key_exists('email', $data)) + $this->email = $data['email']; + + if (array_key_exists('first', $data)) + $this->first = $data['first']; + + if (array_key_exists('last', $data)) + $this->last = $data['last']; + + if (array_key_exists('is_verified', $data)) + $this->is_verified = (bool) $data['is_verified']; + + if (array_key_exists('customer_id', $data)) + $this->customer_id = $data['customer_id']; + + if (array_key_exists('gross', $data)) + $this->gross = (float) $data['gross']; + } + function get_name() { return trim( ucfirst( trim( is_string( $this->first ) ? $this->first : '' ) ) . ' ' . ucfirst( trim( is_string( $this->last ) ? $this->last : '' ) ) ); } diff --git a/phpcs.xml b/phpcs.xml index 35f2ef84..ff6f7cd7 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -95,7 +95,10 @@ - + + + +