Mark some/most implementations of Serializable as @internal

This commit is contained in:
Nicolas Grekas 2019-01-30 10:03:33 +01:00
parent 3cfb558f03
commit 7b9d73d891
14 changed files with 63 additions and 15 deletions

View File

@ -97,7 +97,7 @@ class ClassExistenceResource implements SelfCheckingResourceInterface, \Serializ
} }
/** /**
* {@inheritdoc} * @internal
*/ */
public function serialize() public function serialize()
{ {
@ -109,7 +109,7 @@ class ClassExistenceResource implements SelfCheckingResourceInterface, \Serializ
} }
/** /**
* {@inheritdoc} * @internal
*/ */
public function unserialize($serialized) public function unserialize($serialized)
{ {

View File

@ -51,11 +51,17 @@ class ComposerResource implements SelfCheckingResourceInterface, \Serializable
return self::$runtimeVendors === $this->vendors; return self::$runtimeVendors === $this->vendors;
} }
/**
* @internal
*/
public function serialize() public function serialize()
{ {
return serialize($this->vendors); return serialize($this->vendors);
} }
/**
* @internal
*/
public function unserialize($serialized) public function unserialize($serialized)
{ {
$this->vendors = unserialize($serialized); $this->vendors = unserialize($serialized);

View File

@ -104,11 +104,17 @@ class DirectoryResource implements SelfCheckingResourceInterface, \Serializable
return true; return true;
} }
/**
* @internal
*/
public function serialize() public function serialize()
{ {
return serialize([$this->resource, $this->pattern]); return serialize([$this->resource, $this->pattern]);
} }
/**
* @internal
*/
public function unserialize($serialized) public function unserialize($serialized)
{ {
list($this->resource, $this->pattern) = unserialize($serialized); list($this->resource, $this->pattern) = unserialize($serialized);

View File

@ -59,7 +59,7 @@ class FileExistenceResource implements SelfCheckingResourceInterface, \Serializa
} }
/** /**
* {@inheritdoc} * @internal
*/ */
public function serialize() public function serialize()
{ {
@ -67,7 +67,7 @@ class FileExistenceResource implements SelfCheckingResourceInterface, \Serializa
} }
/** /**
* {@inheritdoc} * @internal
*/ */
public function unserialize($serialized) public function unserialize($serialized)
{ {

View File

@ -63,11 +63,17 @@ class FileResource implements SelfCheckingResourceInterface, \Serializable
return false !== ($filemtime = @filemtime($this->resource)) && $filemtime <= $timestamp; return false !== ($filemtime = @filemtime($this->resource)) && $filemtime <= $timestamp;
} }
/**
* @internal
*/
public function serialize() public function serialize()
{ {
return serialize($this->resource); return serialize($this->resource);
} }
/**
* @internal
*/
public function unserialize($serialized) public function unserialize($serialized)
{ {
$this->resource = unserialize($serialized); $this->resource = unserialize($serialized);

View File

@ -73,6 +73,9 @@ class GlobResource implements \IteratorAggregate, SelfCheckingResourceInterface,
return $this->hash === $hash; return $this->hash === $hash;
} }
/**
* @internal
*/
public function serialize() public function serialize()
{ {
if (null === $this->hash) { if (null === $this->hash) {
@ -82,6 +85,9 @@ class GlobResource implements \IteratorAggregate, SelfCheckingResourceInterface,
return serialize([$this->prefix, $this->pattern, $this->recursive, $this->hash]); return serialize([$this->prefix, $this->pattern, $this->recursive, $this->hash]);
} }
/**
* @internal
*/
public function unserialize($serialized) public function unserialize($serialized)
{ {
list($this->prefix, $this->pattern, $this->recursive, $this->hash) = unserialize($serialized); list($this->prefix, $this->pattern, $this->recursive, $this->hash) = unserialize($serialized);

View File

@ -57,6 +57,9 @@ class ReflectionClassResource implements SelfCheckingResourceInterface, \Seriali
return 'reflection.'.$this->className; return 'reflection.'.$this->className;
} }
/**
* @internal
*/
public function serialize() public function serialize()
{ {
if (null === $this->hash) { if (null === $this->hash) {
@ -67,6 +70,9 @@ class ReflectionClassResource implements SelfCheckingResourceInterface, \Seriali
return serialize([$this->files, $this->className, $this->hash]); return serialize([$this->files, $this->className, $this->hash]);
} }
/**
* @internal
*/
public function unserialize($serialized) public function unserialize($serialized)
{ {
list($this->files, $this->className, $this->hash) = unserialize($serialized); list($this->files, $this->className, $this->hash) = unserialize($serialized);

View File

@ -58,11 +58,17 @@ class AutowireServiceResource implements SelfCheckingResourceInterface, \Seriali
return 'service.autowire.'.$this->class; return 'service.autowire.'.$this->class;
} }
/**
* @internal
*/
public function serialize() public function serialize()
{ {
return serialize([$this->class, $this->filePath, $this->autowiringMetadata]); return serialize([$this->class, $this->filePath, $this->autowiringMetadata]);
} }
/**
* @internal
*/
public function unserialize($serialized) public function unserialize($serialized)
{ {
if (\PHP_VERSION_ID >= 70000) { if (\PHP_VERSION_ID >= 70000) {

View File

@ -39,7 +39,7 @@ class ContainerParametersResource implements ResourceInterface, \Serializable
} }
/** /**
* {@inheritdoc} * @internal
*/ */
public function serialize() public function serialize()
{ {
@ -47,7 +47,7 @@ class ContainerParametersResource implements ResourceInterface, \Serializable
} }
/** /**
* {@inheritdoc} * @internal
*/ */
public function unserialize($serialized) public function unserialize($serialized)
{ {

View File

@ -135,9 +135,7 @@ class FormError implements \Serializable
} }
/** /**
* Serializes this error. * @internal
*
* @return string The serialized error
*/ */
public function serialize() public function serialize()
{ {
@ -151,9 +149,7 @@ class FormError implements \Serializable
} }
/** /**
* Unserializes a serialized error. * @internal
*
* @param string $serialized The serialized error
*/ */
public function unserialize($serialized) public function unserialize($serialized)
{ {

View File

@ -65,11 +65,17 @@ class EnvParametersResource implements SelfCheckingResourceInterface, \Serializa
return $this->findVariables() === $this->variables; return $this->findVariables() === $this->variables;
} }
/**
* @internal
*/
public function serialize() public function serialize()
{ {
return serialize(['prefix' => $this->prefix, 'variables' => $this->variables]); return serialize(['prefix' => $this->prefix, 'variables' => $this->variables]);
} }
/**
* @internal
*/
public function unserialize($serialized) public function unserialize($serialized)
{ {
if (\PHP_VERSION_ID >= 70000) { if (\PHP_VERSION_ID >= 70000) {

View File

@ -40,6 +40,9 @@ abstract class DataCollector implements DataCollectorInterface, \Serializable
*/ */
private $cloner; private $cloner;
/**
* @internal
*/
public function serialize() public function serialize()
{ {
$trace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 2); $trace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 2);
@ -48,6 +51,9 @@ abstract class DataCollector implements DataCollectorInterface, \Serializable
return $isCalledFromOverridingMethod ? $this->data : serialize($this->data); return $isCalledFromOverridingMethod ? $this->data : serialize($this->data);
} }
/**
* @internal
*/
public function unserialize($data) public function unserialize($data)
{ {
$this->data = \is_array($data) ? $data : unserialize($data); $this->data = \is_array($data) ? $data : unserialize($data);

View File

@ -61,11 +61,17 @@ class FileLinkFormatter implements \Serializable
return false; return false;
} }
/**
* @internal
*/
public function serialize() public function serialize()
{ {
return serialize($this->getFileLinkFormat()); return serialize($this->getFileLinkFormat());
} }
/**
* @internal
*/
public function unserialize($serialized) public function unserialize($serialized)
{ {
if (\PHP_VERSION_ID >= 70000) { if (\PHP_VERSION_ID >= 70000) {

View File

@ -284,9 +284,7 @@ abstract class Constraint
* *
* @return array The properties to serialize * @return array The properties to serialize
* *
* @internal This method may be replaced by an implementation of * @internal
* {@link \Serializable} in the future. Please don't use or
* overwrite it.
*/ */
public function __sleep() public function __sleep()
{ {