wiki.techinc.nl/includes/libs/NonSerializableTrait.php
Umherirrender 44fd53fee3 Using @return never documentation on always-throw-function
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
2021-09-07 17:29:03 +02:00

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!' );
}
}