diff --git a/composer.json b/composer.json index b34b3ca..7356396 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,8 @@ "symfony/yaml": "^2.7" }, "require-dev": { - "phpunit/phpunit": "4.4.*", + "phpunit/phpunit": "5.*", + "nilportugues/php_backslasher": "~0.2", "fabpot/php-cs-fixer": "^1.9", "mmoreram/php-formatter": "dev-master", "satooshi/php-coveralls": "dev-master", diff --git a/src/DeepCopySerializer.php b/src/DeepCopySerializer.php index 4bb5ffe..e59875a 100644 --- a/src/DeepCopySerializer.php +++ b/src/DeepCopySerializer.php @@ -8,6 +8,7 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + namespace NilPortugues\Serializer; use ReflectionClass; diff --git a/src/JsonSerializer.php b/src/JsonSerializer.php index caf29f8..dd0b192 100644 --- a/src/JsonSerializer.php +++ b/src/JsonSerializer.php @@ -8,6 +8,7 @@ * 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; diff --git a/src/Serializer.php b/src/Serializer.php index e4cf8ff..cb33e88 100644 --- a/src/Serializer.php +++ b/src/Serializer.php @@ -77,14 +77,14 @@ class Serializer */ public function __construct(StrategyInterface $strategy) { - $this->isHHVM = defined('HHVM_VERSION'); + $this->isHHVM = \defined('HHVM_VERSION'); if ($this->isHHVM) { // @codeCoverageIgnoreStart - $this->serializationMap = array_merge( + $this->serializationMap = \array_merge( $this->serializationMap, - include realpath(dirname(__FILE__).'/Mapping/serialization_hhvm.php') + include \realpath(\dirname(__FILE__).'/Mapping/serialization_hhvm.php') ); - $this->unserializationMapHHVM = include realpath(dirname(__FILE__).'/Mapping/unserialization_hhvm.php'); + $this->unserializationMapHHVM = include \realpath(\dirname(__FILE__).'/Mapping/unserialization_hhvm.php'); // @codeCoverageIgnoreEnd } $this->serializationStrategy = $strategy; @@ -142,15 +142,15 @@ protected function serializeData($value) if ($this->isHHVM && ($value instanceof \DateTimeZone || $value instanceof \DateInterval)) { // @codeCoverageIgnoreStart - return call_user_func_array($this->serializationMap[get_class($value)], [$this, $value]); + return \call_user_func_array($this->serializationMap[get_class($value)], [$this, $value]); // @codeCoverageIgnoreEnd } - if (is_object($value)) { + if (\is_object($value)) { return $this->serializeObject($value); } - $type = (gettype($value) && $value !== null) ? gettype($value) : 'string'; + $type = (\gettype($value) && $value !== null) ? \gettype($value) : 'string'; $func = $this->serializationMap[$type]; return $this->$func($value); @@ -173,7 +173,7 @@ protected function guardForUnsupportedValues($value) ); } - if (is_resource($value)) { + if (\is_resource($value)) { throw new SerializerException('Resource is not supported in Serializer'); } } @@ -187,7 +187,7 @@ protected function guardForUnsupportedValues($value) */ public function unserialize($value) { - if (is_array($value) && isset($value[self::SCALAR_TYPE])) { + if (\is_array($value) && isset($value[self::SCALAR_TYPE])) { return $this->unserializeData($value); } @@ -223,7 +223,7 @@ protected function unserializeData($value) return $this->unserializeObject($value); } - return array_map([$this, __FUNCTION__], $value); + return \array_map([$this, __FUNCTION__], $value); } /** @@ -235,9 +235,9 @@ protected function getScalarValue($value) { switch ($value[self::SCALAR_TYPE]) { case 'integer': - return intval($value[self::SCALAR_VALUE]); + return \intval($value[self::SCALAR_VALUE]); case 'float': - return floatval($value[self::SCALAR_VALUE]); + return \floatval($value[self::SCALAR_VALUE]); case 'boolean': return $value[self::SCALAR_VALUE]; case 'NULL': @@ -291,7 +291,7 @@ protected function unserializeDateTimeFamilyObject(array $value, $className) if ($this->isDateTimeFamilyObject($className)) { if ($this->isHHVM) { // @codeCoverageIgnoreStart - return call_user_func_array( + return \call_user_func_array( $this->unserializationMapHHVM[$className], [$this, $className, $value] ); @@ -315,7 +315,7 @@ protected function isDateTimeFamilyObject($className) $isDateTime = false; foreach ($this->dateTimeClassType as $class) { - $isDateTime = $isDateTime || is_subclass_of($className, $class, true) || $class === $className; + $isDateTime = $isDateTime || \is_subclass_of($className, $class, true) || $class === $className; } return $isDateTime; @@ -334,13 +334,13 @@ protected function restoreUsingUnserialize($className, array $attributes) } $obj = (object) $attributes; - $serialized = preg_replace( + $serialized = \preg_replace( '|^O:\d+:"\w+":|', 'O:'.strlen($className).':"'.$className.'":', - serialize($obj) + \serialize($obj) ); - return unserialize($serialized); + return \unserialize($serialized); } /** @@ -357,7 +357,7 @@ protected function unserializeUserDefinedObject(array $value, $className) $this->objectMapping[$this->objectMappingIndex++] = $obj; $this->setUnserializedObjectProperties($value, $ref, $obj); - if (method_exists($obj, '__wakeup')) { + if (\method_exists($obj, '__wakeup')) { $obj->__wakeup(); } @@ -393,7 +393,7 @@ protected function setUnserializedObjectProperties(array $value, ReflectionClass */ protected function serializeScalar($value) { - $type = gettype($value); + $type = \gettype($value); if ($type === 'double') { $type = 'float'; } @@ -411,7 +411,7 @@ protected function serializeScalar($value) */ protected function serializeArray(array $value) { - if (array_key_exists(self::MAP_TYPE, $value)) { + if (\array_key_exists(self::MAP_TYPE, $value)) { return $value; } @@ -455,7 +455,7 @@ protected function serializeInternalClass($value, $className, ReflectionClass $r { $paramsToSerialize = $this->getObjectProperties($ref, $value); $data = [self::CLASS_IDENTIFIER_KEY => $className]; - $data += array_map([$this, 'serializeData'], $this->extractObjectData($value, $ref, $paramsToSerialize)); + $data += \array_map([$this, 'serializeData'], $this->extractObjectData($value, $ref, $paramsToSerialize)); return $data; } @@ -475,7 +475,7 @@ protected function getObjectProperties(ReflectionClass $ref, $value) $props[] = $prop->getName(); } - return array_unique(array_merge($props, array_keys(get_object_vars($value)))); + return \array_unique(\array_merge($props, \array_keys(\get_object_vars($value)))); } /** @@ -530,7 +530,7 @@ protected function extractAllInhertitedProperties($value, ReflectionClass $rc, a $property->setAccessible(true); $rp[$property->getName()] = $property->getValue($this); } - $data = array_merge($rp, $data); + $data = \array_merge($rp, $data); } while ($rc = $rc->getParentClass()); } } diff --git a/src/Serializer/HHVM/DatePeriodSerializer.php b/src/Serializer/HHVM/DatePeriodSerializer.php index 4b719ff..ee7d6ff 100644 --- a/src/Serializer/HHVM/DatePeriodSerializer.php +++ b/src/Serializer/HHVM/DatePeriodSerializer.php @@ -8,6 +8,7 @@ * 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 0700412..d401046 100644 --- a/src/Serializer/HHVM/DateTimeImmutableSerializer.php +++ b/src/Serializer/HHVM/DateTimeImmutableSerializer.php @@ -8,6 +8,7 @@ * 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 0192bab..ac237e2 100644 --- a/src/Serializer/HHVM/DateTimeSerializer.php +++ b/src/Serializer/HHVM/DateTimeSerializer.php @@ -8,6 +8,7 @@ * 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 a6c8860..2e8b61b 100644 --- a/src/Serializer/InternalClasses/DateIntervalSerializer.php +++ b/src/Serializer/InternalClasses/DateIntervalSerializer.php @@ -8,6 +8,7 @@ * 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; @@ -72,10 +73,10 @@ protected static function getTypedValue(Serializer $serializer, array $value) public static function serialize(Serializer $serializer, DateInterval $dateInterval) { return array( - Serializer::CLASS_IDENTIFIER_KEY => get_class($dateInterval), + Serializer::CLASS_IDENTIFIER_KEY => \get_class($dateInterval), 'construct' => array( Serializer::SCALAR_TYPE => 'string', - Serializer::SCALAR_VALUE => sprintf( + Serializer::SCALAR_VALUE => \sprintf( 'P%sY%sM%sDT%sH%sM%sS', $dateInterval->y, $dateInterval->m, @@ -90,7 +91,7 @@ public static function serialize(Serializer $serializer, DateInterval $dateInter Serializer::SCALAR_VALUE => (empty($dateInterval->invert)) ? 0 : 1, ), 'days' => array( - Serializer::SCALAR_TYPE => gettype($dateInterval->days), + Serializer::SCALAR_TYPE => \gettype($dateInterval->days), Serializer::SCALAR_VALUE => $dateInterval->days, ), ); diff --git a/src/Serializer/InternalClasses/DatePeriodSerializer.php b/src/Serializer/InternalClasses/DatePeriodSerializer.php index ed11c60..2dbf046 100644 --- a/src/Serializer/InternalClasses/DatePeriodSerializer.php +++ b/src/Serializer/InternalClasses/DatePeriodSerializer.php @@ -8,6 +8,7 @@ * 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 612a397..c5ab7c4 100644 --- a/src/Serializer/InternalClasses/DateTimeZoneSerializer.php +++ b/src/Serializer/InternalClasses/DateTimeZoneSerializer.php @@ -8,6 +8,7 @@ * 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; @@ -45,7 +46,7 @@ public static function unserialize(Serializer $serializer, $className, array $va $ref = new ReflectionClass($className); foreach ($value as &$v) { - if (is_array($v)) { + if (\is_array($v)) { $v = $serializer->unserialize($v); } } diff --git a/src/Strategy/JsonStrategy.php b/src/Strategy/JsonStrategy.php index 497401b..16c89fa 100644 --- a/src/Strategy/JsonStrategy.php +++ b/src/Strategy/JsonStrategy.php @@ -8,6 +8,7 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + namespace NilPortugues\Serializer\Strategy; /** @@ -22,7 +23,7 @@ class JsonStrategy implements StrategyInterface */ public function serialize($value) { - return json_encode($value, JSON_UNESCAPED_UNICODE); + return \json_encode($value, JSON_UNESCAPED_UNICODE); } /** @@ -32,6 +33,6 @@ public function serialize($value) */ public function unserialize($value) { - return json_decode($value, true); + return \json_decode($value, true); } } diff --git a/src/Strategy/NullStrategy.php b/src/Strategy/NullStrategy.php index 6db3d5c..2e64512 100644 --- a/src/Strategy/NullStrategy.php +++ b/src/Strategy/NullStrategy.php @@ -8,6 +8,7 @@ * 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 975eb5f..15f0259 100644 --- a/src/Strategy/StrategyInterface.php +++ b/src/Strategy/StrategyInterface.php @@ -8,6 +8,7 @@ * 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 3949b23..bccc661 100644 --- a/src/Strategy/XmlStrategy.php +++ b/src/Strategy/XmlStrategy.php @@ -8,6 +8,7 @@ * 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; @@ -49,9 +50,9 @@ private static function replaceKeys(array &$replacements, array $input) { $return = []; foreach ($input as $key => $value) { - $key = str_replace(array_keys($replacements), array_values($replacements), $key); + $key = \str_replace(\array_keys($replacements), \array_values($replacements), $key); - if (is_array($value)) { + if (\is_array($value)) { $value = self::replaceKeys($replacements, $value); } @@ -70,8 +71,8 @@ private static function replaceKeys(array &$replacements, array $input) private function arrayToXml(array &$data, SimpleXMLElement $xmlData) { foreach ($data as $key => $value) { - if (is_array($value)) { - if (is_numeric($key)) { + if (\is_array($value)) { + if (\is_numeric($key)) { $key = 'np_serializer_element_'.gettype($key).'_'.$key; } $subnode = $xmlData->addChild($key); @@ -89,10 +90,10 @@ private function arrayToXml(array &$data, SimpleXMLElement $xmlData) */ public function unserialize($value) { - $array = (array) simplexml_load_string($value); + $array = (array) \simplexml_load_string($value); self::castToArray($array); self::recoverArrayNumericKeyValues($array); - $replacements = array_flip($this->replacements); + $replacements = \array_flip($this->replacements); $array = self::replaceKeys($replacements, $array); return $array; @@ -108,7 +109,7 @@ private static function castToArray(array &$array) $value = (array) $value; } - if (is_array($value)) { + if (\is_array($value)) { self::castToArray($value); } } @@ -121,13 +122,13 @@ private static function recoverArrayNumericKeyValues(array &$array) { $newArray = []; foreach ($array as $key => &$value) { - if (false !== strpos($key, 'np_serializer_element_')) { + if (false !== \strpos($key, 'np_serializer_element_')) { $key = self::getNumericKeyValue($key); } $newArray[$key] = $value; - if (is_array($newArray[$key])) { + if (\is_array($newArray[$key])) { self::recoverArrayNumericKeyValues($newArray[$key]); } } @@ -141,8 +142,8 @@ private static function recoverArrayNumericKeyValues(array &$array) */ private static function getNumericKeyValue($key) { - $newKey = str_replace('np_serializer_element_', '', $key); - list($type, $index) = explode('_', $newKey); + $newKey = \str_replace('np_serializer_element_', '', $key); + list($type, $index) = \explode('_', $newKey); if ('integer' === $type) { $index = (int) $index; diff --git a/src/Strategy/YamlStrategy.php b/src/Strategy/YamlStrategy.php index 1e2bc15..8bc7a8f 100644 --- a/src/Strategy/YamlStrategy.php +++ b/src/Strategy/YamlStrategy.php @@ -8,6 +8,7 @@ * 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 a1ddc52..e4f847f 100644 --- a/src/Transformer/AbstractTransformer.php +++ b/src/Transformer/AbstractTransformer.php @@ -8,6 +8,7 @@ * 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; @@ -23,13 +24,13 @@ abstract class AbstractTransformer implements StrategyInterface protected function recursiveUnset(array &$array, array $unwantedKey) { foreach ($unwantedKey as $key) { - if (array_key_exists($key, $array)) { + if (\array_key_exists($key, $array)) { unset($array[$key]); } } foreach ($array as &$value) { - if (is_array($value)) { + if (\is_array($value)) { $this->recursiveUnset($value, $unwantedKey); } } @@ -40,13 +41,13 @@ protected function recursiveUnset(array &$array, array $unwantedKey) */ protected function recursiveSetValues(array &$array) { - if (array_key_exists(Serializer::SCALAR_VALUE, $array)) { + if (\array_key_exists(Serializer::SCALAR_VALUE, $array)) { $array = $array[Serializer::SCALAR_VALUE]; } - if (is_array($array) && !array_key_exists(Serializer::SCALAR_VALUE, $array)) { + if (\is_array($array) && !array_key_exists(Serializer::SCALAR_VALUE, $array)) { foreach ($array as &$value) { - if (is_array($value)) { + if (\is_array($value)) { $this->recursiveSetValues($value); } } @@ -58,13 +59,13 @@ protected function recursiveSetValues(array &$array) */ protected function recursiveFlattenOneElementObjectsToScalarType(array &$array) { - if (1 === count($array) && is_scalar(end($array))) { - $array = array_pop($array); + if (1 === \count($array) && \is_scalar(\end($array))) { + $array = \array_pop($array); } - if (is_array($array)) { + if (\is_array($array)) { foreach ($array as &$value) { - if (is_array($value)) { + if (\is_array($value)) { $this->recursiveFlattenOneElementObjectsToScalarType($value); } } @@ -80,6 +81,6 @@ protected function recursiveFlattenOneElementObjectsToScalarType(array &$array) */ public function unserialize($value) { - throw new InvalidArgumentException(sprintf('%s does not perform unserializations.', __CLASS__)); + throw new InvalidArgumentException(\sprintf('%s does not perform unserializations.', __CLASS__)); } } diff --git a/src/Transformer/ArrayTransformer.php b/src/Transformer/ArrayTransformer.php index e78128a..234c74c 100644 --- a/src/Transformer/ArrayTransformer.php +++ b/src/Transformer/ArrayTransformer.php @@ -8,6 +8,7 @@ * 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 bc2d018..c87bf20 100644 --- a/src/Transformer/FlatArrayTransformer.php +++ b/src/Transformer/FlatArrayTransformer.php @@ -8,6 +8,7 @@ * 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 @@ -32,7 +33,7 @@ private function flatten(array $array, $prefix = '') { $result = []; foreach ($array as $key => $value) { - if (is_array($value)) { + if (\is_array($value)) { $result = $result + $this->flatten($value, $prefix.$key.'.'); } else { $result[$prefix.$key] = $value; diff --git a/src/Transformer/JsonTransformer.php b/src/Transformer/JsonTransformer.php index 2174300..46c02f0 100644 --- a/src/Transformer/JsonTransformer.php +++ b/src/Transformer/JsonTransformer.php @@ -14,7 +14,7 @@ class JsonTransformer extends ArrayTransformer */ public function serialize($value) { - return json_encode( + return \json_encode( parent::serialize($value), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES ); diff --git a/src/Transformer/XmlTransformer.php b/src/Transformer/XmlTransformer.php index 5bc69d4..53598f0 100644 --- a/src/Transformer/XmlTransformer.php +++ b/src/Transformer/XmlTransformer.php @@ -8,6 +8,7 @@ * 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; @@ -48,8 +49,8 @@ public function serialize($value) private function arrayToXml(array &$data, SimpleXMLElement $xmlData) { foreach ($data as $key => $value) { - if (is_array($value)) { - if (is_numeric($key)) { + if (\is_array($value)) { + if (\is_numeric($key)) { $key = 'sequential-item'; } $subnode = $xmlData->addChild($key); @@ -58,7 +59,7 @@ private function arrayToXml(array &$data, SimpleXMLElement $xmlData) } else { $subnode = $xmlData->addChild("$key", "$value"); - $type = gettype($value); + $type = \gettype($value); if ('array' !== $type) { $subnode->addAttribute('type', $type); } diff --git a/src/Transformer/YamlTransformer.php b/src/Transformer/YamlTransformer.php index 20c8e39..5fdf8af 100644 --- a/src/Transformer/YamlTransformer.php +++ b/src/Transformer/YamlTransformer.php @@ -8,6 +8,7 @@ * 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 5a40e70..3721c69 100644 --- a/src/XmlSerializer.php +++ b/src/XmlSerializer.php @@ -8,6 +8,7 @@ * 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; diff --git a/src/YamlSerializer.php b/src/YamlSerializer.php index 4c48f9c..65bf6a4 100644 --- a/src/YamlSerializer.php +++ b/src/YamlSerializer.php @@ -8,6 +8,7 @@ * 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; diff --git a/tests/DeepCopySerializerTest.php b/tests/DeepCopySerializerTest.php index 1340bda..bf0e8f5 100644 --- a/tests/DeepCopySerializerTest.php +++ b/tests/DeepCopySerializerTest.php @@ -8,6 +8,7 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + namespace NilPortugues\Test\Serializer; use DateTime; diff --git a/tests/Dummy/ComplexObject/Comment.php b/tests/Dummy/ComplexObject/Comment.php index 79816d5..ea16ddd 100644 --- a/tests/Dummy/ComplexObject/Comment.php +++ b/tests/Dummy/ComplexObject/Comment.php @@ -8,6 +8,7 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + namespace NilPortugues\Test\Serializer\Dummy\ComplexObject; use NilPortugues\Test\Serializer\Dummy\ComplexObject\ValueObject\CommentId; diff --git a/tests/Dummy/ComplexObject/Post.php b/tests/Dummy/ComplexObject/Post.php index ee4269f..48bd93d 100644 --- a/tests/Dummy/ComplexObject/Post.php +++ b/tests/Dummy/ComplexObject/Post.php @@ -8,6 +8,7 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + namespace NilPortugues\Test\Serializer\Dummy\ComplexObject; use NilPortugues\Test\Serializer\Dummy\ComplexObject\ValueObject\PostId; diff --git a/tests/Dummy/ComplexObject/User.php b/tests/Dummy/ComplexObject/User.php index a904738..0320284 100644 --- a/tests/Dummy/ComplexObject/User.php +++ b/tests/Dummy/ComplexObject/User.php @@ -8,6 +8,7 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + namespace NilPortugues\Test\Serializer\Dummy\ComplexObject; use NilPortugues\Test\Serializer\Dummy\ComplexObject\ValueObject\UserId; diff --git a/tests/Dummy/ComplexObject/ValueObject/CommentId.php b/tests/Dummy/ComplexObject/ValueObject/CommentId.php index c4a207c..4b77f76 100644 --- a/tests/Dummy/ComplexObject/ValueObject/CommentId.php +++ b/tests/Dummy/ComplexObject/ValueObject/CommentId.php @@ -8,6 +8,7 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + namespace NilPortugues\Test\Serializer\Dummy\ComplexObject\ValueObject; class CommentId diff --git a/tests/Dummy/ComplexObject/ValueObject/PostId.php b/tests/Dummy/ComplexObject/ValueObject/PostId.php index f7c70cc..20c7133 100644 --- a/tests/Dummy/ComplexObject/ValueObject/PostId.php +++ b/tests/Dummy/ComplexObject/ValueObject/PostId.php @@ -8,6 +8,7 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + namespace NilPortugues\Test\Serializer\Dummy\ComplexObject\ValueObject; class PostId diff --git a/tests/Dummy/ComplexObject/ValueObject/UserId.php b/tests/Dummy/ComplexObject/ValueObject/UserId.php index 62d1b98..99b739e 100644 --- a/tests/Dummy/ComplexObject/ValueObject/UserId.php +++ b/tests/Dummy/ComplexObject/ValueObject/UserId.php @@ -8,6 +8,7 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + namespace NilPortugues\Test\Serializer\Dummy\ComplexObject\ValueObject; class UserId diff --git a/tests/Dummy/SimpleObject/Post.php b/tests/Dummy/SimpleObject/Post.php index 1d6fc02..4727f49 100644 --- a/tests/Dummy/SimpleObject/Post.php +++ b/tests/Dummy/SimpleObject/Post.php @@ -8,6 +8,7 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + namespace NilPortugues\Test\Serializer\Dummy\SimpleObject; class Post diff --git a/tests/JsonSerializerTest.php b/tests/JsonSerializerTest.php index c3f2d69..f43dcec 100644 --- a/tests/JsonSerializerTest.php +++ b/tests/JsonSerializerTest.php @@ -8,6 +8,7 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + namespace NilPortugues\Test\Serializer; use DateTime; diff --git a/tests/SerializerTest.php b/tests/SerializerTest.php index 7f65fb8..02bdb7f 100644 --- a/tests/SerializerTest.php +++ b/tests/SerializerTest.php @@ -98,7 +98,7 @@ public function scalarDataToJson() public function testSerializeResource() { $this->setExpectedException(SerializerException::class); - $this->serializer->serialize(fopen(__FILE__, 'r')); + $this->serializer->serialize(\fopen(__FILE__, 'r')); } /** @@ -213,7 +213,7 @@ public function testUnserializeObjects() $serialized = '{"instance":{"@type":"NilPortugues\\\\Test\\\\Serializer\\\\SupportClasses\\\\EmptyClass"}}'; $array = $this->serializer->unserialize($serialized); - $this->assertTrue(is_array($array)); + $this->assertTrue(\is_array($array)); $this->assertInstanceOf(EmptyClass::class, $array['instance']); } @@ -273,7 +273,7 @@ public function testSerializationOfArrayAccessClasses() */ public function testSerializationOfDateTimeImmutable() { - if (version_compare(PHP_VERSION, '5.5.0', '<')) { + if (\version_compare(PHP_VERSION, '5.5.0', '<')) { $this->markTestSkipped('Supported for PHP 5.5.0 and above'); } diff --git a/tests/SupportClasses/ArrayAccessClass.php b/tests/SupportClasses/ArrayAccessClass.php index 90efeee..468888a 100644 --- a/tests/SupportClasses/ArrayAccessClass.php +++ b/tests/SupportClasses/ArrayAccessClass.php @@ -23,7 +23,7 @@ public function __construct() */ public function offsetSet($offset, $value) { - if (is_null($offset)) { + if (\is_null($offset)) { $this->container[] = $value; } else { $this->container[$offset] = $value; diff --git a/tests/Transformer/ArrayTransformerTest.php b/tests/Transformer/ArrayTransformerTest.php index 54b0c25..62443eb 100644 --- a/tests/Transformer/ArrayTransformerTest.php +++ b/tests/Transformer/ArrayTransformerTest.php @@ -8,6 +8,7 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + namespace NilPortugues\Test\Serializer\Transformer; use DateTime; diff --git a/tests/Transformer/FlatArrayTransformerTest.php b/tests/Transformer/FlatArrayTransformerTest.php index f4c3741..81cb33d 100644 --- a/tests/Transformer/FlatArrayTransformerTest.php +++ b/tests/Transformer/FlatArrayTransformerTest.php @@ -8,6 +8,7 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + namespace NilPortugues\Test\Serializer\Transformer; use DateTime; diff --git a/tests/Transformer/JsonTransformerTest.php b/tests/Transformer/JsonTransformerTest.php index 385d9e9..ae4a97a 100644 --- a/tests/Transformer/JsonTransformerTest.php +++ b/tests/Transformer/JsonTransformerTest.php @@ -8,6 +8,7 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + namespace NilPortugues\Test\Serializer\Transformer; use DateTime; diff --git a/tests/Transformer/XmlTransformerTest.php b/tests/Transformer/XmlTransformerTest.php index 777bfc2..50857e0 100644 --- a/tests/Transformer/XmlTransformerTest.php +++ b/tests/Transformer/XmlTransformerTest.php @@ -8,6 +8,7 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + namespace NilPortugues\Test\Serializer\Transformer; use DateTime; diff --git a/tests/Transformer/YamlTransformerTest.php b/tests/Transformer/YamlTransformerTest.php index 0996354..dfbef32 100644 --- a/tests/Transformer/YamlTransformerTest.php +++ b/tests/Transformer/YamlTransformerTest.php @@ -8,6 +8,7 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + namespace NilPortugues\Test\Serializer\Transformer; use DateTime; diff --git a/tests/XmlSerializerTest.php b/tests/XmlSerializerTest.php index 98a5f0e..98f0949 100644 --- a/tests/XmlSerializerTest.php +++ b/tests/XmlSerializerTest.php @@ -8,6 +8,7 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + namespace NilPortugues\Test\Serializer; use DateTime; diff --git a/tests/YamlSerializerTest.php b/tests/YamlSerializerTest.php index 7abffb2..6010106 100644 --- a/tests/YamlSerializerTest.php +++ b/tests/YamlSerializerTest.php @@ -8,6 +8,7 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + namespace NilPortugues\Test\Serializer; use DateTime;