8000 Drop \Serializable implementations by renanbr · Pull Request #30051 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Drop \Serializable implementations #30051

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Symfony/Component/Config/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ CHANGELOG
-----

* deprecated using environment variables with `cannotBeEmpty()` if the value is validated with `validate()`
* made `Resource\*` classes final and not implement `Serializable` anymore

4.2.0
-----
Expand Down
16 changes: 5 additions & 11 deletions src/Symfony/Component/Config/Resource/ClassExistenceResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
* The resource must be a fully-qualified class name.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @final since Symfony 4.3
*/
class ClassExistenceResource implements SelfCheckingResourceInterface, \Serializable
class ClassExistenceResource implements SelfCheckingResourceInterface
{
private $resource;
private $exists;
Expand Down Expand Up @@ -97,21 +99,13 @@ public function isFresh($timestamp)
/**
* @internal
*/
public function serialize()
public function __sleep(): array
{
if (null === $this->exists) {
$this->isFresh(0);
}

return serialize([$this->resource, $this->exists]);
}

/**
* @internal
*/
public function unserialize($serialized)
{
list($this->resource, $this->exists) = unserialize($serialized);
return ['resource', 'exists'];
}

/**
Expand Down
20 changes: 3 additions & 17 deletions src/Symfony/Component/Config/Resource/ComposerResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
* ComposerResource tracks the PHP version and Composer dependencies.
*
* @author Nicolas Grekas <p@tchwork.com>
*
* @final since Symfony 4.3
*/
class ComposerResource implements SelfCheckingResourceInterface, \Serializable
class ComposerResource implements SelfCheckingResourceInterface
{
private $vendors;

Expand Down Expand Up @@ -51,22 +53,6 @@ public function isFresh($timestamp)
return self::$runtimeVendors === $this->vendors;
}

/**
* @internal
*/
public function serialize()
{
return serialize($this->vendors);
}

/**
* @internal
*/
public function unserialize($serialized)
{
$this->vendors = unserialize($serialized);
}

private static function refresh()
{
self::$runtimeVendors = [];
Expand Down
20 changes: 3 additions & 17 deletions src/Symfony/Component/Config/Resource/DirectoryResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
* DirectoryResource represents a resources stored in a subdirectory tree.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @final since Symfony 4.3
*/
class DirectoryResource implements SelfCheckingResourceInterface, \Serializable
class DirectoryResource implements SelfCheckingResourceInterface
{
private $resource;
private $pattern;
Expand Down Expand Up @@ -103,20 +105,4 @@ public function isFresh($timestamp)

return true;
}

/**
* @internal
*/
public function serialize()
{
return serialize([$this->resource, $this->pattern]);
}

/**
* @internal
*/
public function unserialize($serialized)
{
list($this->resource, $this->pattern) = unserialize($serialized);
}
}
20 changes: 3 additions & 17 deletions src/Symfony/Component/Config/Resource/FileExistenceResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
* The resource can be a file or a directory.
*
* @author Charles-Henri Bruyand <charleshenri.bruyand@gmail.com>
*
* @final since Symfony 4.3
*/
class FileExistenceResource implements SelfCheckingResourceInterface, \Serializable
class FileExistenceResource implements SelfCheckingResourceInterface
{
private $resource;

Expand Down Expand Up @@ -57,20 +59,4 @@ public function isFresh($timestamp)
{
return file_exists($this->resource) === $this->exists;
}

/**
* @internal
*/
public function serialize()
{
return serialize([$this->resource, $this->exists]);
}

/**
* @internal
*/
public function unserialize($serialized)
{
list($this->resource, $this->exists) = unserialize($serialized);
}
}
20 changes: 3 additions & 17 deletions src/Symfony/Component/Config/Resource/FileResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
* The resource can be a file or a directory.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @final since Symfony 4.3
*/
class FileResource implements SelfCheckingResourceInterface, \Serializable
class FileResource implements SelfCheckingResourceInterface
{
/**
* @var string|false
Expand Down Expand Up @@ -62,20 +64,4 @@ public function isFresh($timestamp)
{
return false !== ($filemtime = @filemtime($this->resource)) && $filemtime <= $timestamp;
}

/**
* @internal
*/
public function serialize()
{
return serialize($this->resource);
}

/**
* @internal
*/
public function unserialize($serialized)
{
$this->resource = unserialize($serialized);
}
}
16 changes: 5 additions & 11 deletions src/Symfony/Component/Config/Resource/GlobResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
* Only existence/removal is tracked (not mtimes.)
*
* @author Nicolas Grekas <p@tchwork.com>
*
* @final since Symfony 4.3
*/
class GlobResource implements \IteratorAggregate, SelfCheckingResourceInterface, \Serializable
class GlobResource implements \IteratorAggregate, SelfCheckingResourceInterface
{
private $prefix;
private $pattern;
Expand Down Expand Up @@ -80,21 +82,13 @@ public function isFresh($timestamp)
/**
* @internal
*/
public function serialize()
public function __sleep(): array
{
if (null === $this->hash) {
$this->hash = $this->computeHash();
}

return serialize([$this->prefix, $this->pattern, $this->recursive, $this->hash, $this->forExclusion, $this->excludedPrefixes]);
}

/**
* @internal
*/
public function unserialize($serialized)
{
list($this->prefix, $this->pattern, $this->recursive, $this->hash, $this->forExclusion, $this->excludedPrefixes) = unserialize($serialized) + [4 => false, []];
return ['prefix', 'pattern', 'recursive', 'hash', 'forExclusion', 'excludedPrefixes'];
}

public function getIterator()
Expand Down
16 changes: 5 additions & 11 deletions src/Symfony/Component/Config/Resource/ReflectionClassResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@

/**
* @author Nicolas Grekas <p@tchwork.com>
*
* @final since Symfony 4.3
*/
class ReflectionClassResource implements SelfCheckingResourceInterface, \Serializable
class ReflectionClassResource implements SelfCheckingResourceInterface
{
private $files = [];
private $className;
Expand Down Expand Up @@ -61,22 +63,14 @@ public function __toString()
/**
* @internal
*/
public function serialize()
public function __sleep(): array
{
if (null === $this->hash) {
$this->hash = $this->computeHash();
$this->loadFiles($this->classReflector);
}

return serialize([$this->files, $this->className, $this->hash]);
}

/**
* @internal
*/
public function unserialize($serialized)
{
list($this->files, $this->className, $this->hash) = unserialize($serialized);
return ['files', 'className', 'hash'];
}

private function loadFiles(\ReflectionClass $class)
Expand Down
10 changes: 9 additions & 1 deletion src/Symfony/Component/Config/ResourceCheckerConfigCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ private function safelyUnserialize($file)
$meta = false;
$content = file_get_contents($file);
$signalingException = new \UnexpectedValueException();
$prevUnserializeHandler = ini_set('unserialize_callback_func', '');
$prevUnserializeHandler = ini_set('unserialize_callback_func', self::class.'::handleUnserializeCallback');
$prevErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = []) use (&$prevErrorHandler, $signalingException) {
if (__FILE__ === $file) {
throw $signalingException;
Expand All @@ -180,4 +180,12 @@ private function safelyUnserialize($file)

return $meta;
}

/**
* @internal
*/
public static function handleUnserializeCallback($class)
{
trigger_error('Class not found: '.$class);
}
}
1 change: 1 addition & 0 deletions src/Symfony/Component/DependencyInjection/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ CHANGELOG
* added `%env(default:...)%` processor to fallback to a default value
* added `%env(nullable:...)%` processor to allow empty variables to be processed as null values
* added support for deprecating aliases
* made `ContainerParametersResource` final and not implement `Serializable` anymore

4.2.0
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
* Tracks container parameters.
*
* @author Maxime Steinhausser <maxime.steinhausser@gmail.com>
*
* @final since Symfony 4.3
*/
class ContainerParametersResource implements ResourceInterface, \Serializable
class ContainerParametersResource implements ResourceInterface
{
private $parameters;

Expand All @@ -38,22 +40,6 @@ public function __toString()
return 'container_parameters_'.md5(serialize($this->parameters));
}

/**
* @internal
*/
public function serialize()
{
return serialize($this->parameters);
}

/**
* @internal
*/
public function unserialize($serialized)
{
$this->parameters = unserialize($serialized);
}

/**
* @return array Tracked parameters
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Form/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ CHANGELOG
option is set to `single_text`
* added `block_prefix` option to `BaseType`.
* added `help_html` option to display the `help` text as HTML.
* `FormError` doesn't implement `Serializable` anymore
* added `label_translation_parameters`, `attr_translation_parameters`, `help_translation_parameters` options
to `FormType` to pass translation parameters to form labels, attributes (`placeholder` and `title`) and help text respectively.
The passed parameters will replace placeholders in translation messages.
Expand All @@ -32,7 +33,6 @@ CHANGELOG
}
```


4.2.0
-----

Expand Down
24 changes: 1 addition & 23 deletions src/Symfony/Component/Form/FormError.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class FormError implements \Serializable
class FormError
{
protected $messageTemplate;
protected $messageParameters;
Expand Down Expand Up @@ -133,26 +133,4 @@ public function getOrigin()
{
return $this->origin;
}

/**
* @internal
*/
public function serialize()
{
return serialize([
$this->message,
$this->messageTemplate,
$this->messageParameters,
$this->messagePluralization,
$this->cause,
]);
}

/**
* @internal
*/
public function unserialize($serialized)
{
list($this->message, $this->messageTemplate, $this->messageParameters, $this->messagePluralization, $this->cause) = unserialize($serialized, ['allowed_classes' => false]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ public function testSerializeWithFormAddedMultipleTimes()
$this->dataCollector->collectViewVariables($form2View);
$this->dataCollector->buildFinalFormTree($form2, $form2View);

$this->dataCollector->serialize();
serialize($this->dataCollector);
}

public function testFinalFormReliesOnFormViewStructure()
Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Component/HttpKernel/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ CHANGELOG

* increased the priority of `Symfony\Component\HttpKernel\EventListener\AddRequestFormatsListener`
* made `Symfony\Component\HttpKernel\EventListenerLocaleListener` set the default locale early
* made `FileLinkFormatter` final and not implement `Serializable` anymore

4.2.0
-----
Expand Down
Loading
0