This helps phan to detect unreachable code and also impossible types after the functions. It helps phan to avoid false positives for array keys when the keys are checked before Bug: T240141 Change-Id: I895f70e82b3053a46cd44135b15437e6f82a07b2
20 lines
375 B
PHP
20 lines
375 B
PHP
<?php
|
|
|
|
namespace Wikimedia\NonSerializable;
|
|
|
|
use LogicException;
|
|
|
|
/**
|
|
* A trait that prevents serialization via php's builtin serialize() function.
|
|
*/
|
|
trait NonSerializableTrait {
|
|
|
|
/**
|
|
* @throws LogicException always
|
|
* @return never
|
|
*/
|
|
public function __sleep() {
|
|
throw new LogicException( 'Instances of ' . get_class( $this ) . ' are not serializable!' );
|
|
}
|
|
|
|
}
|