Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
NonSerializableTrait | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
__sleep | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | namespace Wikimedia\NonSerializable; |
4 | |
5 | use LogicException; |
6 | |
7 | /** |
8 | * A trait that prevents serialization via php's builtin serialize() function. |
9 | */ |
10 | trait NonSerializableTrait { |
11 | |
12 | /** |
13 | * @throws LogicException always |
14 | * @return never |
15 | */ |
16 | public function __sleep() { |
17 | throw new LogicException( 'Instances of ' . get_class( $this ) . ' are not serializable!' ); |
18 | } |
19 | |
20 | } |