Skip to content

Commit

Permalink
Merge pull request #895 from jeskew/fix/provide-helpful-error-message…
Browse files Browse the repository at this point in the history
…-on-serialization

Throw an exception when attempting to serialize an AwsClient
  • Loading branch information
jeskew committed Jan 29, 2016
2 parents 553e7ef + 8fc10ad commit b4f3127
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/AwsClient.php
Expand Up @@ -273,6 +273,12 @@ public function getWaiter($name, array $args = [])
return new Waiter($this, $name, $args, $config);
}

public function __sleep()
{
throw new \RuntimeException('Instances of ' . static::class
. ' cannot be serialized');
}

/**
* Get the signature_provider function of the client.
*
Expand Down
10 changes: 10 additions & 0 deletions tests/AwsClientTest.php
Expand Up @@ -322,4 +322,14 @@ private function createClient(array $service = [], array $config = [])
'version' => 'latest'
]);
}

/**
* @expectedException \RuntimeException
* @expectedExceptionMessage Instances of Aws\AwsClient cannot be serialized
*/
public function testDoesNotPermitSerialization()
{
$client = $this->createClient();
\serialize($client);
}
}

0 comments on commit b4f3127

Please sign in to comment.