diff --git a/src/DeepCopySerializer.php b/src/DeepCopySerializer.php index e59875a..bd2cb63 100644 --- a/src/DeepCopySerializer.php +++ b/src/DeepCopySerializer.php @@ -8,7 +8,6 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ - namespace NilPortugues\Serializer; use ReflectionClass; @@ -24,15 +23,15 @@ class DeepCopySerializer extends Serializer */ protected function serializeObject($value) { - if ($this->objectStorage->contains($value)) { - return $this->objectStorage[$value]; + if (self::$objectStorage->contains($value)) { + return self::$objectStorage[$value]; } $reflection = new ReflectionClass($value); $className = $reflection->getName(); $serialized = $this->serializeInternalClass($value, $className, $reflection); - $this->objectStorage->attach($value, $serialized); + self::$objectStorage->attach($value, $serialized); return $serialized; } diff --git a/src/JsonSerializer.php b/src/JsonSerializer.php index dd0b192..1c81ed9 100644 --- a/src/JsonSerializer.php +++ b/src/JsonSerializer.php @@ -8,13 +8,15 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ - namespace NilPortugues\Serializer; use NilPortugues\Serializer\Strategy\JsonStrategy; class JsonSerializer extends Serializer { + /** + * + */ public function __construct() { parent::__construct(new JsonStrategy()); diff --git a/src/Serializer.php b/src/Serializer.php index cb33e88..2603e5c 100644 --- a/src/Serializer.php +++ b/src/Serializer.php @@ -23,21 +23,21 @@ class Serializer * * @var SplObjectStorage */ - protected $objectStorage; + protected static $objectStorage; /** * Object mapping for recursion. * * @var array */ - protected $objectMapping = []; + protected static $objectMapping = []; /** * Object mapping index. * * @var int */ - protected $objectMappingIndex = 0; + protected static $objectMappingIndex = 0; /** * @var \NilPortugues\Serializer\Strategy\StrategyInterface|\NilPortugues\Serializer\Strategy\JsonStrategy @@ -122,9 +122,9 @@ public function serialize($value) */ protected function reset() { - $this->objectStorage = new SplObjectStorage(); - $this->objectMapping = []; - $this->objectMappingIndex = 0; + self::$objectStorage = new SplObjectStorage(); + self::$objectMapping = []; + self::$objectMappingIndex = 0; } /** @@ -267,7 +267,7 @@ protected function unserializeObject(array $value) } if ($className[0] === '@') { - return $this->objectMapping[substr($className, 1)]; + return self::$objectMapping[substr($className, 1)]; } if (!class_exists($className)) { @@ -299,7 +299,7 @@ protected function unserializeDateTimeFamilyObject(array $value, $className) } $obj = $this->restoreUsingUnserialize($className, $value); - $this->objectMapping[$this->objectMappingIndex++] = $obj; + self::$objectMapping[self::$objectMappingIndex++] = $obj; } return $obj; @@ -354,7 +354,7 @@ protected function unserializeUserDefinedObject(array $value, $className) $ref = new ReflectionClass($className); $obj = $ref->newInstanceWithoutConstructor(); - $this->objectMapping[$this->objectMappingIndex++] = $obj; + self::$objectMapping[self::$objectMappingIndex++] = $obj; $this->setUnserializedObjectProperties($value, $ref, $obj); if (\method_exists($obj, '__wakeup')) { @@ -432,11 +432,11 @@ protected function serializeArray(array $value) */ protected function serializeObject($value) { - if ($this->objectStorage->contains($value)) { - return [self::CLASS_IDENTIFIER_KEY => '@'.$this->objectStorage[$value]]; + if (self::$objectStorage->contains($value)) { + return [self::CLASS_IDENTIFIER_KEY => '@'.self::$objectStorage[$value]]; } - $this->objectStorage->attach($value, $this->objectMappingIndex++); + self::$objectStorage->attach($value, self::$objectMappingIndex++); $reflection = new ReflectionClass($value); $className = $reflection->getName(); diff --git a/src/Serializer/HHVM/DatePeriodSerializer.php b/src/Serializer/HHVM/DatePeriodSerializer.php index ee7d6ff..4b719ff 100644 --- a/src/Serializer/HHVM/DatePeriodSerializer.php +++ b/src/Serializer/HHVM/DatePeriodSerializer.php @@ -8,7 +8,6 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ - namespace NilPortugues\Serializer\Serializer\HHVM; /** diff --git a/src/Serializer/HHVM/DateTimeImmutableSerializer.php b/src/Serializer/HHVM/DateTimeImmutableSerializer.php index d401046..0700412 100644 --- a/src/Serializer/HHVM/DateTimeImmutableSerializer.php +++ b/src/Serializer/HHVM/DateTimeImmutableSerializer.php @@ -8,7 +8,6 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ - namespace NilPortugues\Serializer\Serializer\HHVM; use NilPortugues\Serializer\Serializer; diff --git a/src/Serializer/HHVM/DateTimeSerializer.php b/src/Serializer/HHVM/DateTimeSerializer.php index ac237e2..0192bab 100644 --- a/src/Serializer/HHVM/DateTimeSerializer.php +++ b/src/Serializer/HHVM/DateTimeSerializer.php @@ -8,7 +8,6 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ - namespace NilPortugues\Serializer\Serializer\HHVM; use NilPortugues\Serializer\Serializer; diff --git a/src/Serializer/InternalClasses/DateIntervalSerializer.php b/src/Serializer/InternalClasses/DateIntervalSerializer.php index 2e8b61b..3a9aaba 100644 --- a/src/Serializer/InternalClasses/DateIntervalSerializer.php +++ b/src/Serializer/InternalClasses/DateIntervalSerializer.php @@ -8,7 +8,6 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ - namespace NilPortugues\Serializer\Serializer\InternalClasses; use DateInterval; diff --git a/src/Serializer/InternalClasses/DatePeriodSerializer.php b/src/Serializer/InternalClasses/DatePeriodSerializer.php index 2dbf046..ed11c60 100644 --- a/src/Serializer/InternalClasses/DatePeriodSerializer.php +++ b/src/Serializer/InternalClasses/DatePeriodSerializer.php @@ -8,7 +8,6 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ - namespace NilPortugues\Serializer\Serializer\InternalClasses; /** diff --git a/src/Serializer/InternalClasses/DateTimeZoneSerializer.php b/src/Serializer/InternalClasses/DateTimeZoneSerializer.php index c5ab7c4..ebae790 100644 --- a/src/Serializer/InternalClasses/DateTimeZoneSerializer.php +++ b/src/Serializer/InternalClasses/DateTimeZoneSerializer.php @@ -8,7 +8,6 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ - namespace NilPortugues\Serializer\Serializer\InternalClasses; use DateTimeZone; diff --git a/src/Strategy/JsonStrategy.php b/src/Strategy/JsonStrategy.php index 16c89fa..821b5f5 100644 --- a/src/Strategy/JsonStrategy.php +++ b/src/Strategy/JsonStrategy.php @@ -8,7 +8,6 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ - namespace NilPortugues\Serializer\Strategy; /** diff --git a/src/Strategy/NullStrategy.php b/src/Strategy/NullStrategy.php index 2e64512..6db3d5c 100644 --- a/src/Strategy/NullStrategy.php +++ b/src/Strategy/NullStrategy.php @@ -8,7 +8,6 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ - namespace NilPortugues\Serializer\Strategy; /** diff --git a/src/Strategy/StrategyInterface.php b/src/Strategy/StrategyInterface.php index 15f0259..975eb5f 100644 --- a/src/Strategy/StrategyInterface.php +++ b/src/Strategy/StrategyInterface.php @@ -8,7 +8,6 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ - namespace NilPortugues\Serializer\Strategy; interface StrategyInterface diff --git a/src/Strategy/XmlStrategy.php b/src/Strategy/XmlStrategy.php index bccc661..94f7dfb 100644 --- a/src/Strategy/XmlStrategy.php +++ b/src/Strategy/XmlStrategy.php @@ -8,7 +8,6 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ - namespace NilPortugues\Serializer\Strategy; use NilPortugues\Serializer\Serializer; diff --git a/src/Strategy/YamlStrategy.php b/src/Strategy/YamlStrategy.php index 8bc7a8f..1e2bc15 100644 --- a/src/Strategy/YamlStrategy.php +++ b/src/Strategy/YamlStrategy.php @@ -8,7 +8,6 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ - namespace NilPortugues\Serializer\Strategy; use Symfony\Component\Yaml\Yaml; diff --git a/src/Transformer/AbstractTransformer.php b/src/Transformer/AbstractTransformer.php index e4f847f..7c745c8 100644 --- a/src/Transformer/AbstractTransformer.php +++ b/src/Transformer/AbstractTransformer.php @@ -8,7 +8,6 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ - namespace NilPortugues\Serializer\Transformer; use InvalidArgumentException; diff --git a/src/Transformer/ArrayTransformer.php b/src/Transformer/ArrayTransformer.php index 234c74c..e78128a 100644 --- a/src/Transformer/ArrayTransformer.php +++ b/src/Transformer/ArrayTransformer.php @@ -8,7 +8,6 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ - namespace NilPortugues\Serializer\Transformer; use NilPortugues\Serializer\Serializer; diff --git a/src/Transformer/FlatArrayTransformer.php b/src/Transformer/FlatArrayTransformer.php index c87bf20..7f54b36 100644 --- a/src/Transformer/FlatArrayTransformer.php +++ b/src/Transformer/FlatArrayTransformer.php @@ -8,7 +8,6 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ - namespace NilPortugues\Serializer\Transformer; class FlatArrayTransformer extends ArrayTransformer diff --git a/src/Transformer/XmlTransformer.php b/src/Transformer/XmlTransformer.php index 53598f0..cbf2522 100644 --- a/src/Transformer/XmlTransformer.php +++ b/src/Transformer/XmlTransformer.php @@ -8,7 +8,6 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ - namespace NilPortugues\Serializer\Transformer; use DOMDocument; diff --git a/src/Transformer/YamlTransformer.php b/src/Transformer/YamlTransformer.php index 5fdf8af..20c8e39 100644 --- a/src/Transformer/YamlTransformer.php +++ b/src/Transformer/YamlTransformer.php @@ -8,7 +8,6 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ - namespace NilPortugues\Serializer\Transformer; use Symfony\Component\Yaml\Yaml; diff --git a/src/XmlSerializer.php b/src/XmlSerializer.php index 3721c69..0d9d73e 100644 --- a/src/XmlSerializer.php +++ b/src/XmlSerializer.php @@ -8,13 +8,15 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ - namespace NilPortugues\Serializer; use NilPortugues\Serializer\Strategy\XmlStrategy; class XmlSerializer extends Serializer { + /** + * + */ public function __construct() { parent::__construct(new XmlStrategy()); diff --git a/src/YamlSerializer.php b/src/YamlSerializer.php index 65bf6a4..026d801 100644 --- a/src/YamlSerializer.php +++ b/src/YamlSerializer.php @@ -8,13 +8,15 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ - namespace NilPortugues\Serializer; use NilPortugues\Serializer\Strategy\YamlStrategy; class YamlSerializer extends Serializer { + /** + * + */ public function __construct() { parent::__construct(new YamlStrategy());