Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions includes/entities/class-fs-user.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 : '' ) ) );
}
Expand Down
5 changes: 4 additions & 1 deletion phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@
<!-- <rule ref="PHPCompatibilityWP"/> -->

<config name="testVersion" value="5.6-"/>
<rule ref="PHPCompatibility"/>
<rule ref="PHPCompatibility">
<exclude name="PHPCompatibility.FunctionNameRestrictions.NewMagicMethods.__serializeFound"/>
<exclude name="PHPCompatibility.FunctionNameRestrictions.NewMagicMethods.__unserializeFound"/>
</rule>

<!--
#############################################################################
Expand Down
2 changes: 1 addition & 1 deletion start.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
* @var string
*/
$this_sdk_version = '2.12.2.1';
$this_sdk_version = '2.12.2.2';

#region SDK Selection Logic --------------------------------------------------------------------

Expand Down
Loading