diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Source/Countryofmanufacture.php b/app/code/Magento/Catalog/Model/Product/Attribute/Source/Countryofmanufacture.php index dc7189b54c073c090715e42d35eeb252a2167d41..8bcf01ba3db3867bb0babe3c5119097f1c860d5d 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/Source/Countryofmanufacture.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/Source/Countryofmanufacture.php @@ -36,9 +36,9 @@ class Countryofmanufacture extends AbstractSource implements OptionSourceInterfa protected $_countryFactory; /** - * @var \Magento\Framework\Json\JsonInterface + * @var \Magento\Framework\Serialize\SerializerInterface */ - private $json; + private $serializer; /** * Construct @@ -66,30 +66,30 @@ class Countryofmanufacture extends AbstractSource implements OptionSourceInterfa { $cacheKey = 'COUNTRYOFMANUFACTURE_SELECT_STORE_' . $this->_storeManager->getStore()->getCode(); if ($cache = $this->_configCacheType->load($cacheKey)) { - $options = $this->getJson()->decode($cache); + $options = $this->getSerializer()->unserialize($cache); } else { /** @var \Magento\Directory\Model\Country $country */ $country = $this->_countryFactory->create(); /** @var \Magento\Directory\Model\ResourceModel\Country\Collection $collection */ $collection = $country->getResourceCollection(); $options = $collection->load()->toOptionArray(); - $this->_configCacheType->save($this->getJson()->encode($options), $cacheKey); + $this->_configCacheType->save($this->getSerializer()->serialize($options), $cacheKey); } return $options; } /** - * Get json encoder/decoder + * Get serializer * - * @return \Magento\Framework\Json\JsonInterface + * @return \Magento\Framework\Serialize\SerializerInterface * @deprecated */ - private function getJson() + private function getSerializer() { - if ($this->json === null) { - $this->json = \Magento\Framework\App\ObjectManager::getInstance() - ->get(\Magento\Framework\Json\JsonInterface::class); + if ($this->serializer === null) { + $this->serializer = \Magento\Framework\App\ObjectManager::getInstance() + ->get(\Magento\Framework\Serialize\SerializerInterface::class); } - return $this->json; + return $this->serializer; } } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/CountryofmanufactureTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/CountryofmanufactureTest.php index 6a4e73fa176cfff55b4c8396f5dc3ebdc74164f4..8c0e090bfe941c2525eabd2159ee27809137c151 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/CountryofmanufactureTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/CountryofmanufactureTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Catalog\Test\Unit\Model\Product\Attribute\Source; -use Magento\Framework\Json\JsonInterface; +use Magento\Framework\Serialize\SerializerInterface; class CountryofmanufactureTest extends \PHPUnit_Framework_TestCase { @@ -46,19 +46,19 @@ class CountryofmanufactureTest extends \PHPUnit_Framework_TestCase ] ); - $jsonMock = $this->getMock(JsonInterface::class, [], [], '', false); - $jsonMock->method('encode') + $serializerMock = $this->getMock(SerializerInterface::class, [], [], '', false); + $serializerMock->method('serialize') ->willReturnCallback(function ($string) { return json_encode($string); }); - $jsonMock->method('decode') + $serializerMock->method('unserialize') ->willReturnCallback(function ($string) { return json_decode($string, true); }); $this->objectManagerHelper->setBackwardCompatibleProperty( $this->countryOfManufacture, - 'json', - $jsonMock + 'serializer', + $serializerMock ); } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/ConfigTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/ConfigTest.php index 4098a289640404c8572401f74af18a0a8081d5f5..44ef53a34d0ef50d404eed4d55af158a71dcecf0 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/ConfigTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductTypes/ConfigTest.php @@ -23,9 +23,9 @@ class ConfigTest extends \PHPUnit_Framework_TestCase private $cacheMock; /** - * @var \Magento\Framework\Json\JsonInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Serialize\SerializerInterface|\PHPUnit_Framework_MockObject_MockObject */ - private $jsonMock; + private $serializerMock; /** * @var \Magento\Catalog\Model\ProductTypes\Config|\PHPUnit_Framework_MockObject_MockObject @@ -43,8 +43,10 @@ class ConfigTest extends \PHPUnit_Framework_TestCase false ); $this->cacheMock = $this->getMock(\Magento\Framework\Config\CacheInterface::class); - $this->jsonMock = $this->getMock(\Magento\Framework\Json\JsonInterface::class); - $this->objectManager->mockObjectManager([\Magento\Framework\Json\JsonInterface::class => $this->jsonMock]); + $this->serializerMock = $this->getMock(\Magento\Framework\Serialize\SerializerInterface::class); + $this->objectManager->mockObjectManager( + [\Magento\Framework\Serialize\SerializerInterface::class => $this->serializerMock] + ); } protected function tearDown() @@ -63,7 +65,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase ->method('load') ->willReturn(json_encode($value)); - $this->jsonMock->method('decode') + $this->serializerMock->method('unserialize') ->willReturn($value); $this->config = new \Magento\Catalog\Model\ProductTypes\Config($this->readerMock, $this->cacheMock, 'cache_id'); $this->assertEquals($expected, $this->config->getType('global')); @@ -83,7 +85,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $this->cacheMock->expects($this->once()) ->method('load') ->willReturn(json_encode('"types":["Expected Data"]]')); - $this->jsonMock->method('decode') + $this->serializerMock->method('unserialize') ->willReturn(['types' => $expected]); $this->config = new \Magento\Catalog\Model\ProductTypes\Config($this->readerMock, $this->cacheMock, 'cache_id'); $this->assertEquals($expected, $this->config->getAll()); @@ -94,7 +96,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $this->cacheMock->expects($this->once()) ->method('load') ->willReturn(''); - $this->jsonMock->method('decode') + $this->serializerMock->method('unserialize') ->willReturn([]); $this->config = new \Magento\Catalog\Model\ProductTypes\Config($this->readerMock, $this->cacheMock, 'cache_id'); diff --git a/app/code/Magento/Cron/Test/Unit/Model/Config/DataTest.php b/app/code/Magento/Cron/Test/Unit/Model/Config/DataTest.php index 5ef35c015d0291b4a84fc60272dba8dfb4cbea6f..5eecaa147fcbddf55d8958b8c2625b7ea6edb477 100644 --- a/app/code/Magento/Cron/Test/Unit/Model/Config/DataTest.php +++ b/app/code/Magento/Cron/Test/Unit/Model/Config/DataTest.php @@ -52,10 +52,12 @@ class DataTest extends \PHPUnit_Framework_TestCase $dbReader->expects($this->once())->method('get')->will($this->returnValue($dbReaderData)); - $jsonMock = $this->getMock(\Magento\Framework\Json\JsonInterface::class); - $this->objectManager->mockObjectManager([\Magento\Framework\Json\JsonInterface::class => $jsonMock]); + $serializerMock = $this->getMock(\Magento\Framework\Serialize\SerializerInterface::class); + $this->objectManager->mockObjectManager( + [\Magento\Framework\Serialize\SerializerInterface::class => $serializerMock] + ); - $jsonMock->method('decode') + $serializerMock->method('unserialize') ->willReturn($jobs); $configData = new \Magento\Cron\Model\Config\Data($reader, $cache, $dbReader, 'test_cache_id'); diff --git a/app/code/Magento/Customer/Model/Customer/NotificationStorage.php b/app/code/Magento/Customer/Model/Customer/NotificationStorage.php index 7c77fe9c8d500ed140955ffd954ccf47c1497e78..67ee60971d98ac7c2cd089428ad923a4580dfd78 100644 --- a/app/code/Magento/Customer/Model/Customer/NotificationStorage.php +++ b/app/code/Magento/Customer/Model/Customer/NotificationStorage.php @@ -6,7 +6,7 @@ namespace Magento\Customer\Model\Customer; use Magento\Framework\Cache\FrontendInterface; -use Magento\Framework\Json\JsonInterface; +use Magento\Framework\Serialize\SerializerInterface; class NotificationStorage { @@ -22,9 +22,9 @@ class NotificationStorage */ /** - * @var JsonInterface + * @var SerializerInterface */ - private $json; + private $serializer; /** * NotificationStorage constructor. @@ -45,7 +45,7 @@ class NotificationStorage public function add($notificationType, $customerId) { $this->cache->save( - $this->getJson()->encode([ + $this->getSerializer()->serialize([ 'customer_id' => $customerId, 'notification_type' => $notificationType ]), @@ -90,17 +90,17 @@ class NotificationStorage } /** - * Get json encoder/decoder + * Get serializer * - * @return JsonInterface + * @return SerializerInterface * @deprecated */ - private function getJson() + private function getSerializer() { - if ($this->json === null) { - $this->json = \Magento\Framework\App\ObjectManager::getInstance() - ->get(JsonInterface::class); + if ($this->serializer === null) { + $this->serializer = \Magento\Framework\App\ObjectManager::getInstance() + ->get(SerializerInterface::class); } - return $this->json; + return $this->serializer; } } diff --git a/app/code/Magento/Customer/Test/Unit/Model/Address/ConfigTest.php b/app/code/Magento/Customer/Test/Unit/Model/Address/ConfigTest.php index e62c29173e2d044cc77ddecb966b88c7c168405c..40a754f78ec2f54bd94fa4d3697351262c74a390 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Address/ConfigTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Address/ConfigTest.php @@ -43,9 +43,9 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected $_scopeConfigMock; /** - * @var \Magento\Framework\Json\JsonInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Serialize\SerializerInterface|\PHPUnit_Framework_MockObject_MockObject */ - private $jsonMock; + private $serializerMock; /** * @var \Magento\Customer\Model\Address\Config @@ -99,16 +99,18 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $this->_cacheMock->expects($this->once()) ->method('save') ->with( - \Zend_Json::encode($fixtureConfigData), + json_encode($fixtureConfigData), $this->_cacheId ); - $this->jsonMock = $this->getMock(\Magento\Framework\Json\JsonInterface::class); - $this->objectManager->mockObjectManager([\Magento\Framework\Json\JsonInterface::class => $this->jsonMock]); + $this->serializerMock = $this->getMock(\Magento\Framework\Serialize\SerializerInterface::class); + $this->objectManager->mockObjectManager( + [\Magento\Framework\Serialize\SerializerInterface::class => $this->serializerMock] + ); - $this->jsonMock->method('encode') + $this->serializerMock->method('serialize') ->willReturn(json_encode($fixtureConfigData)); - $this->jsonMock->method('decode') + $this->serializerMock->method('unserialize') ->willReturn($fixtureConfigData); $this->_model = new \Magento\Customer\Model\Address\Config( diff --git a/app/code/Magento/Customer/Test/Unit/Model/Customer/NotificationStorageTest.php b/app/code/Magento/Customer/Test/Unit/Model/Customer/NotificationStorageTest.php index 6c391d2d6d55e5cd5a11d901410be6c9b8b87b59..e75cacc0781d56d603546371edec49ac984b11b0 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Customer/NotificationStorageTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Customer/NotificationStorageTest.php @@ -21,9 +21,9 @@ class NotificationStorageTest extends \PHPUnit_Framework_TestCase private $cacheMock; /** - * @var \Magento\Framework\Json\JsonInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Serialize\SerializerInterface|\PHPUnit_Framework_MockObject_MockObject */ - private $jsonMock; + private $serializerMock; protected function setUp() { @@ -33,8 +33,8 @@ class NotificationStorageTest extends \PHPUnit_Framework_TestCase NotificationStorage::class, ['cache' => $this->cacheMock] ); - $this->jsonMock = $this->getMock(\Magento\Framework\Json\JsonInterface::class); - $objectManager->setBackwardCompatibleProperty($this->notificationStorage, 'json', $this->jsonMock); + $this->serializerMock = $this->getMock(\Magento\Framework\Serialize\SerializerInterface::class); + $objectManager->setBackwardCompatibleProperty($this->notificationStorage, 'serializer', $this->serializerMock); } public function testAdd() @@ -46,8 +46,8 @@ class NotificationStorageTest extends \PHPUnit_Framework_TestCase 'notification_type' => $notificationType ]; $jsonString = json_encode($data); - $this->jsonMock->expects($this->once()) - ->method('encode') + $this->serializerMock->expects($this->once()) + ->method('serialize') ->with($data) ->willReturn($jsonString); $this->cacheMock->expects($this->once()) diff --git a/app/code/Magento/Directory/Block/Data.php b/app/code/Magento/Directory/Block/Data.php index 920013c140935476d21143f1ef6b3edb5d240717..3c8b682d1a1e8ad1dd066bd5300373f5a05c8859 100644 --- a/app/code/Magento/Directory/Block/Data.php +++ b/app/code/Magento/Directory/Block/Data.php @@ -36,9 +36,9 @@ class Data extends \Magento\Framework\View\Element\Template protected $directoryHelper; /** - * @var \Magento\Framework\Json\JsonInterface + * @var \Magento\Framework\Serialize\SerializerInterface */ - private $json; + private $serializer; /** * @param \Magento\Framework\View\Element\Template\Context $context @@ -118,12 +118,12 @@ class Data extends \Magento\Framework\View\Element\Template $cacheKey = 'DIRECTORY_COUNTRY_SELECT_STORE_' . $this->_storeManager->getStore()->getCode(); $cache = $this->_configCacheType->load($cacheKey); if ($cache) { - $options = $this->getJson()->decode($cache); + $options = $this->getSerializer()->unserialize($cache); } else { $options = $this->getCountryCollection() ->setForegroundCountries($this->getTopDestinations()) ->toOptionArray(); - $this->_configCacheType->save($this->getJson()->encode($options), $cacheKey); + $this->_configCacheType->save($this->getSerializer()->serialize($options), $cacheKey); } $html = $this->getLayout()->createBlock( \Magento\Framework\View\Element\Html\Select::class @@ -168,10 +168,10 @@ class Data extends \Magento\Framework\View\Element\Template $cacheKey = 'DIRECTORY_REGION_SELECT_STORE' . $this->_storeManager->getStore()->getId(); $cache = $this->_configCacheType->load($cacheKey); if ($cache) { - $options = $this->getJson()->decode($cache); + $options = $this->getSerializer()->unserialize($cache); } else { $options = $this->getRegionCollection()->toOptionArray(); - $this->_configCacheType->save($this->getJson()->encode($options), $cacheKey); + $this->_configCacheType->save($this->getSerializer()->serialize($options), $cacheKey); } $html = $this->getLayout()->createBlock( \Magento\Framework\View\Element\Html\Select::class @@ -234,17 +234,17 @@ class Data extends \Magento\Framework\View\Element\Template } /** - * Get json encoder/decoder + * Get serializer * - * @return \Magento\Framework\Json\JsonInterface + * @return \Magento\Framework\Serialize\SerializerInterface * @deprecated */ - private function getJson() + private function getSerializer() { - if ($this->json === null) { - $this->json = \Magento\Framework\App\ObjectManager::getInstance() - ->get(\Magento\Framework\Json\JsonInterface::class); + if ($this->serializer === null) { + $this->serializer = \Magento\Framework\App\ObjectManager::getInstance() + ->get(\Magento\Framework\Serialize\SerializerInterface::class); } - return $this->json; + return $this->serializer; } } diff --git a/app/code/Magento/Directory/Test/Unit/Block/DataTest.php b/app/code/Magento/Directory/Test/Unit/Block/DataTest.php index 1a81ba24d20fe2f2580598ca4ae2b13343c2c992..6b41140240a30c2214ef6e1ce653dc7c559bfa51 100644 --- a/app/code/Magento/Directory/Test/Unit/Block/DataTest.php +++ b/app/code/Magento/Directory/Test/Unit/Block/DataTest.php @@ -11,7 +11,7 @@ use Magento\Directory\Model\ResourceModel\Country\Collection as CountryCollectio use Magento\Directory\Model\ResourceModel\Country\CollectionFactory as CountryCollectionFactory; use Magento\Framework\App\Cache\Type\Config; use Magento\Framework\App\Config\ScopeConfigInterface; -use Magento\Framework\Json\JsonInterface; +use Magento\Framework\Serialize\SerializerInterface; use Magento\Framework\View\Element\Template\Context; use Magento\Framework\View\LayoutInterface; use Magento\Store\Model\ScopeInterface; @@ -78,19 +78,19 @@ class DataTest extends \PHPUnit_Framework_TestCase ] ); - $jsonMock = $this->getMock(JsonInterface::class, [], [], '', false); - $jsonMock->method('encode') + $serializerMock = $this->getMock(SerializerInterface::class, [], [], '', false); + $serializerMock->method('serialize') ->willReturnCallback(function ($string) { return json_encode($string); }); - $jsonMock->method('decode') + $serializerMock->method('unserialize') ->willReturnCallback(function ($string) { return json_decode($string, true); }); $objectManagerHelper->setBackwardCompatibleProperty( $this->block, - 'json', - $jsonMock + 'serializer', + $serializerMock ); } @@ -181,7 +181,7 @@ class DataTest extends \PHPUnit_Framework_TestCase ->willReturn(false); $this->cacheTypeConfigMock->expects($this->once()) ->method('save') - ->with(\Zend_Json::encode($options), 'DIRECTORY_COUNTRY_SELECT_STORE_' . $storeCode) + ->with(json_encode($options), 'DIRECTORY_COUNTRY_SELECT_STORE_' . $storeCode) ->willReturnSelf(); $this->scopeConfigMock->expects($this->once()) diff --git a/app/code/Magento/Directory/Test/Unit/Model/Country/Postcode/Config/DataTest.php b/app/code/Magento/Directory/Test/Unit/Model/Country/Postcode/Config/DataTest.php index ca6e95585a6a84ddd46a0e7af61f1473424adf40..2ae230da35c2229a57db6cc935cc4d856c0bcb95 100644 --- a/app/code/Magento/Directory/Test/Unit/Model/Country/Postcode/Config/DataTest.php +++ b/app/code/Magento/Directory/Test/Unit/Model/Country/Postcode/Config/DataTest.php @@ -23,9 +23,9 @@ class DataTest extends \PHPUnit_Framework_TestCase private $cacheMock; /** - * @var \Magento\Framework\Json\JsonInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Serialize\SerializerInterface|\PHPUnit_Framework_MockObject_MockObject */ - private $jsonMock; + private $serializerMock; protected function setUp() { @@ -44,8 +44,10 @@ class DataTest extends \PHPUnit_Framework_TestCase '', false ); - $this->jsonMock = $this->getMock(\Magento\Framework\Json\JsonInterface::class); - $this->objectManager->mockObjectManager([\Magento\Framework\Json\JsonInterface::class => $this->jsonMock]); + $this->serializerMock = $this->getMock(\Magento\Framework\Serialize\SerializerInterface::class); + $this->objectManager->mockObjectManager( + [\Magento\Framework\Serialize\SerializerInterface::class => $this->serializerMock] + ); } public function testGet() @@ -54,8 +56,8 @@ class DataTest extends \PHPUnit_Framework_TestCase $this->cacheMock->expects($this->once()) ->method('load') ->willReturn(json_encode($expected)); - $this->jsonMock->expects($this->once()) - ->method('decode') + $this->serializerMock->expects($this->once()) + ->method('unserialize') ->willReturn($expected); $configData = new \Magento\Directory\Model\Country\Postcode\Config\Data($this->readerMock, $this->cacheMock); $this->assertEquals($expected, $configData->get()); diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/ConfigTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/ConfigTest.php index b3d522f1c7699f986a33406394c90d53041f1559..b111bf8c72a16a6920fcd79c25c95102c14582d6 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/ConfigTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/ConfigTest.php @@ -37,7 +37,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected $_cacheId; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Eav\Model\Entity\Attribute|\PHPUnit_Framework_MockObject_MockObject */ protected $_attribute; @@ -65,11 +65,13 @@ class ConfigTest extends \PHPUnit_Framework_TestCase ->with($this->_cacheId) ->willReturn(''); - $jsonMock = $this->getMock(\Magento\Framework\Json\JsonInterface::class); + $serializerMock = $this->getMock(\Magento\Framework\Serialize\SerializerInterface::class); - $jsonMock->method('decode') + $serializerMock->method('unserialize') ->willReturn([]); - $this->objectManager->mockObjectManager([\Magento\Framework\Json\JsonInterface::class => $jsonMock]); + $this->objectManager->mockObjectManager( + [\Magento\Framework\Serialize\SerializerInterface::class => $serializerMock] + ); $this->_model = new \Magento\Eav\Model\Entity\Attribute\Config( $this->_readerMock, $this->_cacheMock, diff --git a/app/code/Magento/ImportExport/Test/Unit/Model/Export/ConfigTest.php b/app/code/Magento/ImportExport/Test/Unit/Model/Export/ConfigTest.php index d15a5f345d4a9a8a352d5552787942e73ef8ac71..04cb6bbcab687444be9f9de7d99dd6714374f32b 100644 --- a/app/code/Magento/ImportExport/Test/Unit/Model/Export/ConfigTest.php +++ b/app/code/Magento/ImportExport/Test/Unit/Model/Export/ConfigTest.php @@ -23,9 +23,9 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected $_configScopeMock; /** - * @var \Magento\Framework\Json\JsonInterface + * @var \Magento\Framework\Serialize\SerializerInterface */ - private $jsonMock; + private $serializerMock; /** * @var string @@ -48,8 +48,10 @@ class ConfigTest extends \PHPUnit_Framework_TestCase false ); $this->_configScopeMock = $this->getMock(\Magento\Framework\Config\CacheInterface::class); - $this->jsonMock = $this->getMock(\Magento\Framework\Json\JsonInterface::class); - $this->objectManager->mockObjectManager([\Magento\Framework\Json\JsonInterface::class => $this->jsonMock]); + $this->serializerMock = $this->getMock(\Magento\Framework\Serialize\SerializerInterface::class); + $this->objectManager->mockObjectManager( + [\Magento\Framework\Serialize\SerializerInterface::class => $this->serializerMock] + ); } protected function tearDown() diff --git a/app/code/Magento/ImportExport/Test/Unit/Model/Import/ConfigTest.php b/app/code/Magento/ImportExport/Test/Unit/Model/Import/ConfigTest.php index 22127a6b54b57a1440a0bda2598a21cec456fdf0..2e182c4e35562e92f46cef27eeef3b7325891801 100644 --- a/app/code/Magento/ImportExport/Test/Unit/Model/Import/ConfigTest.php +++ b/app/code/Magento/ImportExport/Test/Unit/Model/Import/ConfigTest.php @@ -23,9 +23,9 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected $_configScopeMock; /** - * @var \Magento\Framework\Json\JsonInterface + * @var \Magento\Framework\Serialize\SerializerInterface */ - private $jsonMock; + private $serializerMock; /** * @var string @@ -48,8 +48,10 @@ class ConfigTest extends \PHPUnit_Framework_TestCase false ); $this->_configScopeMock = $this->getMock(\Magento\Framework\Config\CacheInterface::class); - $this->jsonMock = $this->getMock(\Magento\Framework\Json\JsonInterface::class); - $this->objectManager->mockObjectManager([\Magento\Framework\Json\JsonInterface::class => $this->jsonMock]); + $this->serializerMock = $this->getMock(\Magento\Framework\Serialize\SerializerInterface::class); + $this->objectManager->mockObjectManager( + [\Magento\Framework\Serialize\SerializerInterface::class => $this->serializerMock] + ); } public function tearDown() diff --git a/app/code/Magento/Indexer/Test/Unit/Model/Config/DataTest.php b/app/code/Magento/Indexer/Test/Unit/Model/Config/DataTest.php index 939b30a576b097662adf394fa731feaafc47a829..6747025eed2a83b1a46284a9eee24b18fe01903c 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/Config/DataTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Model/Config/DataTest.php @@ -43,9 +43,9 @@ class DataTest extends \PHPUnit_Framework_TestCase protected $indexers = ['indexer1' => [], 'indexer3' => []]; /** - * @var \Magento\Framework\Json\JsonInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Serialize\SerializerInterface|\PHPUnit_Framework_MockObject_MockObject */ - private $jsonMock; + private $serializerMock; protected function setUp() { @@ -67,8 +67,10 @@ class DataTest extends \PHPUnit_Framework_TestCase '', false ); - $this->jsonMock = $this->getMock(\Magento\Framework\Json\JsonInterface::class); - $this->objectManager->mockObjectManager([\Magento\Framework\Json\JsonInterface::class => $this->jsonMock]); + $this->serializerMock = $this->getMock(\Magento\Framework\Serialize\SerializerInterface::class); + $this->objectManager->mockObjectManager( + [\Magento\Framework\Serialize\SerializerInterface::class => $this->serializerMock] + ); } protected function tearDown() @@ -85,7 +87,7 @@ class DataTest extends \PHPUnit_Framework_TestCase ->with($this->cacheId) ->willReturn($jsonString); - $this->jsonMock->method('decode') + $this->serializerMock->method('unserialize') ->with($jsonString) ->willReturn($this->indexers); diff --git a/app/code/Magento/Sales/Test/Unit/Model/Config/DataTest.php b/app/code/Magento/Sales/Test/Unit/Model/Config/DataTest.php index 8514c77215622d9dd95f91dfe91d13e8f6399b8c..ed001a14c992416b6adef726aee0706222906cc1 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Config/DataTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Config/DataTest.php @@ -23,9 +23,9 @@ class DataTest extends \PHPUnit_Framework_TestCase private $_cacheMock; /** - * @var \Magento\Framework\Json\JsonInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Serialize\SerializerInterface|\PHPUnit_Framework_MockObject_MockObject */ - private $jsonMock; + private $serializerMock; protected function setUp() { @@ -36,8 +36,10 @@ class DataTest extends \PHPUnit_Framework_TestCase $this->_cacheMock = $this->getMockBuilder( \Magento\Framework\App\Cache\Type\Config::class )->disableOriginalConstructor()->getMock(); - $this->jsonMock = $this->getMock(\Magento\Framework\Json\JsonInterface::class); - $this->objectManager->mockObjectManager([\Magento\Framework\Json\JsonInterface::class => $this->jsonMock]); + $this->serializerMock = $this->getMock(\Magento\Framework\Serialize\SerializerInterface::class); + $this->objectManager->mockObjectManager( + [\Magento\Framework\Serialize\SerializerInterface::class => $this->serializerMock] + ); } protected function tearDown() @@ -51,7 +53,7 @@ class DataTest extends \PHPUnit_Framework_TestCase $this->_cacheMock->expects($this->once()) ->method('load'); - $this->jsonMock->method('decode') + $this->serializerMock->method('unserialize') ->willReturn($expected); $configData = new \Magento\Sales\Model\Config\Data($this->_readerMock, $this->_cacheMock); diff --git a/app/code/Magento/Store/Model/StoreResolver.php b/app/code/Magento/Store/Model/StoreResolver.php index a885e59d0bc017360d2ad74a52f41ab155960d32..cfb57849f25a83fd8c1f971e1b9bbf7870c2765c 100644 --- a/app/code/Magento/Store/Model/StoreResolver.php +++ b/app/code/Magento/Store/Model/StoreResolver.php @@ -5,7 +5,7 @@ */ namespace Magento\Store\Model; -use Magento\Framework\Json\JsonInterface; +use Magento\Framework\Serialize\SerializerInterface; class StoreResolver implements \Magento\Store\Api\StoreResolverInterface { @@ -50,9 +50,9 @@ class StoreResolver implements \Magento\Store\Api\StoreResolverInterface protected $request; /** - * @var JsonInterface + * @var \Magento\Framework\Serialize\SerializerInterface */ - private $json; + private $serializer; /** * @param \Magento\Store\Api\StoreRepositoryInterface $storeRepository @@ -121,10 +121,10 @@ class StoreResolver implements \Magento\Store\Api\StoreResolverInterface $cacheKey = 'resolved_stores_' . md5($this->runMode . $this->scopeCode); $cacheData = $this->cache->load($cacheKey); if ($cacheData) { - $storesData = $this->getJson()->decode($cacheData); + $storesData = $this->getSerializer()->unserialize($cacheData); } else { $storesData = $this->readStoresData(); - $this->cache->save($this->getJson()->encode($storesData), $cacheKey, [self::CACHE_TAG]); + $this->cache->save($this->getSerializer()->serialize($storesData), $cacheKey, [self::CACHE_TAG]); } return $storesData; } @@ -177,17 +177,17 @@ class StoreResolver implements \Magento\Store\Api\StoreResolverInterface } /** - * Get json encoder/decoder + * Get serializer * - * @return JsonInterface + * @return \Magento\Framework\Serialize\SerializerInterface * @deprecated */ - private function getJson() + private function getSerializer() { - if ($this->json === null) { - $this->json = \Magento\Framework\App\ObjectManager::getInstance() - ->get(JsonInterface::class); + if ($this->serializer === null) { + $this->serializer = \Magento\Framework\App\ObjectManager::getInstance() + ->get(SerializerInterface::class); } - return $this->json; + return $this->serializer; } } diff --git a/app/code/Magento/Webapi/Test/Unit/Model/DataObjectProcessorTest.php b/app/code/Magento/Webapi/Test/Unit/Model/DataObjectProcessorTest.php index c869a5361597f2a4c245c43f231be04dd33fe9b4..8c62cfcbc09d4c20f6b6972a5cc772499fee8015 100644 --- a/app/code/Magento/Webapi/Test/Unit/Model/DataObjectProcessorTest.php +++ b/app/code/Magento/Webapi/Test/Unit/Model/DataObjectProcessorTest.php @@ -6,7 +6,7 @@ namespace Magento\Webapi\Test\Unit\Model; -use Magento\Framework\Json\JsonInterface; +use Magento\Framework\Serialize\SerializerInterface; use Magento\Framework\Reflection\DataObjectProcessor; use Magento\Webapi\Model\Config as ModelConfig; @@ -32,19 +32,19 @@ class DataObjectProcessorTest extends \PHPUnit_Framework_TestCase 'typeProcessor' => $objectManager->getObject(\Magento\Framework\Reflection\TypeProcessor::class), ] ); - $jsonMock = $this->getMock(JsonInterface::class); - $jsonMock->method('encode') + $serializerMock = $this->getMock(SerializerInterface::class); + $serializerMock->method('serialize') ->willReturnCallback(function ($data) { return json_encode($data); }); - $jsonMock->method('decode') + $serializerMock->method('unserialize') ->willReturnCallback(function ($string) { return json_decode($string, true); }); $objectManager->setBackwardCompatibleProperty( $methodsMapProcessor, - 'json', - $jsonMock + 'serializer', + $serializerMock ); $this->dataObjectProcessor = $objectManager->getObject( \Magento\Framework\Reflection\DataObjectProcessor::class, diff --git a/dev/tests/integration/testsuite/Magento/Framework/Interception/AbstractPlugin.php b/dev/tests/integration/testsuite/Magento/Framework/Interception/AbstractPlugin.php index a6371c607c4affc26c2b040f27944fd6badbbf11..2e3711c3be0b640742c90d7a553e01e3d77259c1 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Interception/AbstractPlugin.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Interception/AbstractPlugin.php @@ -71,7 +71,7 @@ abstract class AbstractPlugin extends \PHPUnit_Framework_TestCase $definitions ); $interceptionDefinitions = new Definition\Runtime(); - $json = new \Magento\Framework\Json\Json(); + $json = new \Magento\Framework\Serialize\Serializer\Json(); $sharedInstances = [ \Magento\Framework\Config\CacheInterface::class => $cache, \Magento\Framework\Config\ScopeInterface::class => $configScope, @@ -81,7 +81,7 @@ abstract class AbstractPlugin extends \PHPUnit_Framework_TestCase \Magento\Framework\Interception\ObjectManager\ConfigInterface::class => $config, \Magento\Framework\ObjectManager\DefinitionInterface::class => $definitions, \Magento\Framework\Interception\DefinitionInterface::class => $interceptionDefinitions, - \Magento\Framework\Json\JsonInterface::class => $json, + \Magento\Framework\Serialize\SerializerInterface::class => $json, ]; $this->_objectManager = new \Magento\Framework\ObjectManager\ObjectManager( $factory, diff --git a/lib/internal/Magento/Framework/App/Config/Initial.php b/lib/internal/Magento/Framework/App/Config/Initial.php index 45b1f31b944dd41f7a4a035a0fa054e5347c4fd9..84fd2bfa52d703c2ac5a0806d524b5a8a4496c61 100644 --- a/lib/internal/Magento/Framework/App/Config/Initial.php +++ b/lib/internal/Magento/Framework/App/Config/Initial.php @@ -8,7 +8,7 @@ namespace Magento\Framework\App\Config; use Magento\Framework\App\Config\ScopeConfigInterface; -use Magento\Framework\Json\JsonInterface; +use Magento\Framework\Serialize\SerializerInterface; class Initial { @@ -32,9 +32,9 @@ class Initial protected $_metadata = []; /** - * @var JsonInterface + * @var SerializerInterface */ - private $json; + private $serializer; /** * @param \Magento\Framework\App\Config\Initial\Reader $reader @@ -47,9 +47,9 @@ class Initial $data = $cache->load(self::CACHE_ID); if (!$data) { $data = $reader->read(); - $cache->save($this->getJson()->encode($data), self::CACHE_ID); + $cache->save($this->getSerializer()->serialize($data), self::CACHE_ID); } else { - $data = $this->getJson()->decode($data); + $data = $this->getSerializer()->unserialize($data); } $this->_data = $data['data']; $this->_metadata = $data['metadata']; @@ -84,17 +84,17 @@ class Initial } /** - * Get json encoder/decoder + * Get serializer * - * @return JsonInterface + * @return SerializerInterface * @deprecated */ - private function getJson() + private function getSerializer() { - if ($this->json === null) { - $this->json = \Magento\Framework\App\ObjectManager::getInstance() - ->get(JsonInterface::class); + if ($this->serializer === null) { + $this->serializer = \Magento\Framework\App\ObjectManager::getInstance() + ->get(SerializerInterface::class); } - return $this->json; + return $this->serializer; } } diff --git a/lib/internal/Magento/Framework/App/Config/ScopePool.php b/lib/internal/Magento/Framework/App/Config/ScopePool.php index 55ffe3ff464468c578f0f16e9a0d7225de861b91..018e21f86a7826000d7792ddf6c93c29c155ed37 100644 --- a/lib/internal/Magento/Framework/App/Config/ScopePool.php +++ b/lib/internal/Magento/Framework/App/Config/ScopePool.php @@ -6,7 +6,7 @@ namespace Magento\Framework\App\Config; use Magento\Framework\App\RequestInterface; -use Magento\Framework\Json\JsonInterface; +use Magento\Framework\Serialize\SerializerInterface; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) @@ -51,9 +51,9 @@ class ScopePool private $request; /** - * @var JsonInterface + * @var SerializerInterface */ - private $json; + private $serializer; /** * @param \Magento\Framework\App\Config\Scope\ReaderPoolInterface $readerPool @@ -111,7 +111,7 @@ class ScopePool $data = $this->_cache->load($cacheKey); if ($data) { - $data = $this->getJson()->decode($data); + $data = $this->getSerializer()->unserialize($data); } else { $reader = $this->_readerPool->getReader($scopeType); if ($scopeType === ScopeConfigInterface::SCOPE_TYPE_DEFAULT) { @@ -119,7 +119,7 @@ class ScopePool } else { $data = $reader->read($scopeCode); } - $this->_cache->save($this->getJson()->encode($data), $cacheKey, [self::CACHE_TAG]); + $this->_cache->save($this->getSerializer()->serialize($data), $cacheKey, [self::CACHE_TAG]); } $this->_scopes[$code] = $this->_dataFactory->create(['data' => $data]); } @@ -161,17 +161,17 @@ class ScopePool } /** - * Get json encoder/decoder + * Get serializer * - * @return JsonInterface + * @return SerializerInterface * @deprecated */ - private function getJson() + private function getSerializer() { - if ($this->json === null) { - $this->json = \Magento\Framework\App\ObjectManager::getInstance() - ->get(JsonInterface::class); + if ($this->serializer === null) { + $this->serializer = \Magento\Framework\App\ObjectManager::getInstance() + ->get(SerializerInterface::class); } - return $this->json; + return $this->serializer; } } diff --git a/lib/internal/Magento/Framework/App/ObjectManager/ConfigCache.php b/lib/internal/Magento/Framework/App/ObjectManager/ConfigCache.php index 342c9ab7bfb3124da78c71d2f6b85bc9bdc98fb9..dbb3bed895697bf9a1d5d85602303c72c224b197 100644 --- a/lib/internal/Magento/Framework/App/ObjectManager/ConfigCache.php +++ b/lib/internal/Magento/Framework/App/ObjectManager/ConfigCache.php @@ -7,7 +7,7 @@ */ namespace Magento\Framework\App\ObjectManager; -use Magento\Framework\Json\JsonInterface; +use Magento\Framework\Serialize\SerializerInterface; class ConfigCache implements \Magento\Framework\ObjectManager\ConfigCacheInterface { @@ -24,9 +24,9 @@ class ConfigCache implements \Magento\Framework\ObjectManager\ConfigCacheInterfa protected $_prefix = 'diConfig'; /** - * @var JsonInterface + * @var \Magento\Framework\Serialize\SerializerInterface */ - private $json; + private $serializer; /** * @param \Magento\Framework\Cache\FrontendInterface $cacheFrontend @@ -44,7 +44,7 @@ class ConfigCache implements \Magento\Framework\ObjectManager\ConfigCacheInterfa */ public function get($key) { - return $this->getJson()->decode($this->_cacheFrontend->load($this->_prefix . $key)); + return $this->getSerializer()->unserialize($this->_cacheFrontend->load($this->_prefix . $key)); } /** @@ -56,21 +56,21 @@ class ConfigCache implements \Magento\Framework\ObjectManager\ConfigCacheInterfa */ public function save(array $config, $key) { - $this->_cacheFrontend->save($this->getJson()->encode($config), $this->_prefix . $key); + $this->_cacheFrontend->save($this->getSerializer()->serialize($config), $this->_prefix . $key); } /** - * Get json encoder/decoder + * Get serializer * - * @return JsonInterface + * @return \Magento\Framework\Serialize\SerializerInterface * @deprecated */ - private function getJson() + private function getSerializer() { - if ($this->json === null) { - $this->json = \Magento\Framework\App\ObjectManager::getInstance() - ->get(JsonInterface::class); + if ($this->serializer === null) { + $this->serializer = \Magento\Framework\App\ObjectManager::getInstance() + ->get(SerializerInterface::class); } - return $this->json; + return $this->serializer; } } diff --git a/lib/internal/Magento/Framework/App/ObjectManager/ConfigLoader.php b/lib/internal/Magento/Framework/App/ObjectManager/ConfigLoader.php index 0ef3e5d3e59542448bd72aca72b0970bf9d34e29..2cfa2b006ff1ecc04c735226ba98867e7c23d5a9 100644 --- a/lib/internal/Magento/Framework/App/ObjectManager/ConfigLoader.php +++ b/lib/internal/Magento/Framework/App/ObjectManager/ConfigLoader.php @@ -7,7 +7,7 @@ */ namespace Magento\Framework\App\ObjectManager; -use Magento\Framework\Json\JsonInterface; +use Magento\Framework\Serialize\SerializerInterface; use Magento\Framework\ObjectManager\ConfigLoaderInterface; class ConfigLoader implements ConfigLoaderInterface @@ -34,9 +34,9 @@ class ConfigLoader implements ConfigLoaderInterface protected $_cache; /** - * @var JsonInterface + * @var \Magento\Framework\Serialize\SerializerInterface */ - private $json; + private $serializer; /** * @param \Magento\Framework\Config\CacheInterface $cache @@ -73,9 +73,9 @@ class ConfigLoader implements ConfigLoaderInterface if (!$data) { $data = $this->_getReader()->read($area); - $this->_cache->save($this->getJson()->encode($data), $cacheId); + $this->_cache->save($this->getSerializer()->serialize($data), $cacheId); } else { - $data = $this->getJson()->decode($data); + $data = $this->getSerializer()->unserialize($data); } return $data; @@ -84,15 +84,15 @@ class ConfigLoader implements ConfigLoaderInterface /** * Get json encoder/decoder * - * @return JsonInterface + * @return SerializerInterface * @deprecated */ - private function getJson() + private function getSerializer() { - if ($this->json === null) { - $this->json = \Magento\Framework\App\ObjectManager::getInstance() - ->get(JsonInterface::class); + if ($this->serializer === null) { + $this->serializer = \Magento\Framework\App\ObjectManager::getInstance() + ->get(SerializerInterface::class); } - return $this->json; + return $this->serializer; } } diff --git a/lib/internal/Magento/Framework/App/ObjectManager/ConfigLoader/Compiled.php b/lib/internal/Magento/Framework/App/ObjectManager/ConfigLoader/Compiled.php index e31fdc4954eb4a254125730c32449a17dd4572a6..ac55963655b8700cd5322abfc4f95fea38de79a6 100644 --- a/lib/internal/Magento/Framework/App/ObjectManager/ConfigLoader/Compiled.php +++ b/lib/internal/Magento/Framework/App/ObjectManager/ConfigLoader/Compiled.php @@ -7,7 +7,6 @@ namespace Magento\Framework\App\ObjectManager\ConfigLoader; use Magento\Framework\App\Filesystem\DirectoryList; -use Magento\Framework\Json\JsonInterface; use Magento\Framework\ObjectManager\ConfigLoaderInterface; class Compiled implements ConfigLoaderInterface @@ -22,9 +21,9 @@ class Compiled implements ConfigLoaderInterface private $configCache = []; /** - * @var JsonInterface + * @var \Magento\Framework\Serialize\SerializerInterface */ - private $json; + private $serializer; /** * {inheritdoc} @@ -34,7 +33,7 @@ class Compiled implements ConfigLoaderInterface if (isset($this->configCache[$area])) { return $this->configCache[$area]; } - $this->configCache[$area] = $this->getJson()->decode(\file_get_contents(self::getFilePath($area))); + $this->configCache[$area] = $this->getSerializer()->unserialize(\file_get_contents(self::getFilePath($area))); return $this->configCache[$area]; } @@ -51,16 +50,16 @@ class Compiled implements ConfigLoaderInterface } /** - * Get json encoder/decoder + * Get serializer * - * @return JsonInterface + * @return \Magento\Framework\Serialize\SerializerInterface * @deprecated */ - private function getJson() + private function getSerializer() { - if ($this->json === null) { - $this->json = new \Magento\Framework\Json\Json(); + if ($this->serializer === null) { + $this->serializer = new \Magento\Framework\Serialize\Serializer\Json(); } - return $this->json; + return $this->serializer; } } diff --git a/lib/internal/Magento/Framework/App/Route/Config.php b/lib/internal/Magento/Framework/App/Route/Config.php index 716af96d342c014cfb4ee554aa3f599089265b4f..60412e7fa888b2969067ab7e73725b5f39d301a9 100644 --- a/lib/internal/Magento/Framework/App/Route/Config.php +++ b/lib/internal/Magento/Framework/App/Route/Config.php @@ -7,7 +7,7 @@ */ namespace Magento\Framework\App\Route; -use Magento\Framework\Json\JsonInterface; +use Magento\Framework\Serialize\SerializerInterface; class Config implements ConfigInterface { @@ -42,9 +42,9 @@ class Config implements ConfigInterface protected $_routes; /** - * @var JsonInterface + * @var SerializerInterface */ - private $json; + private $serializer; /** * @param Config\Reader $reader @@ -80,7 +80,7 @@ class Config implements ConfigInterface return $this->_routes[$scope]; } $cacheId = $scope . '::' . $this->_cacheId; - $cachedRoutes = $this->getJson()->decode($this->_cache->load($cacheId)); + $cachedRoutes = $this->getSerializer()->unserialize($this->_cache->load($cacheId)); if (is_array($cachedRoutes)) { $this->_routes[$scope] = $cachedRoutes; return $cachedRoutes; @@ -88,7 +88,8 @@ class Config implements ConfigInterface $routers = $this->_reader->read($scope); $routes = $routers[$this->_areaList->getDefaultRouter($scope)]['routes']; - $this->_cache->save($this->getJson()->encode($routes), $cacheId); + $routesData = $this->getSerializer()->serialize($routes); + $this->_cache->save($routesData, $cacheId); $this->_routes[$scope] = $routes; return $routes; } @@ -142,17 +143,17 @@ class Config implements ConfigInterface } /** - * Get json encoder/decoder + * Get serializer * - * @return JsonInterface + * @return \Magento\Framework\Serialize\SerializerInterface * @deprecated */ - private function getJson() + private function getSerializer() { - if ($this->json === null) { - $this->json = \Magento\Framework\App\ObjectManager::getInstance() - ->get(JsonInterface::class); + if ($this->serializer === null) { + $this->serializer = \Magento\Framework\App\ObjectManager::getInstance() + ->get(SerializerInterface::class); } - return $this->json; + return $this->serializer; } } diff --git a/lib/internal/Magento/Framework/App/Router/ActionList.php b/lib/internal/Magento/Framework/App/Router/ActionList.php index f2f0a5015fb9123e9a5565262ffad0fd4c60cd34..dbfc9d2b9f502ed85c15e09309cb93d87aad8681 100644 --- a/lib/internal/Magento/Framework/App/Router/ActionList.php +++ b/lib/internal/Magento/Framework/App/Router/ActionList.php @@ -6,7 +6,7 @@ */ namespace Magento\Framework\App\Router; -use Magento\Framework\Json\JsonInterface; +use Magento\Framework\Serialize\SerializerInterface; use Magento\Framework\Module\Dir\Reader as ModuleReader; class ActionList @@ -37,9 +37,9 @@ class ActionList ]; /** - * @var JsonInterface + * @var SerializerInterface */ - private $json; + private $serializer; /** * @param \Magento\Framework\Config\CacheInterface $cache @@ -60,9 +60,9 @@ class ActionList $data = $cache->load($cacheKey); if (!$data) { $this->actions = $moduleReader->getActionFiles(); - $cache->save($this->getJson()->encode($this->actions), $cacheKey); + $cache->save($this->getSerializer()->serialize($this->actions), $cacheKey); } else { - $this->actions = $this->getJson()->decode($data); + $this->actions = $this->getSerializer()->unserialize($data); } } @@ -100,17 +100,17 @@ class ActionList } /** - * Get json encoder/decoder + * Get serializer * - * @return JsonInterface + * @return \Magento\Framework\Serialize\SerializerInterface * @deprecated */ - private function getJson() + private function getSerializer() { - if ($this->json === null) { - $this->json = \Magento\Framework\App\ObjectManager::getInstance() - ->get(JsonInterface::class); + if ($this->serializer === null) { + $this->serializer = \Magento\Framework\App\ObjectManager::getInstance() + ->get(SerializerInterface::class); } - return $this->json; + return $this->serializer; } } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Config/InitialTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Config/InitialTest.php index 5cf32b81b4566644cc86a6d22591cd5fdc4f0c03..ab200ea88ef17a9de52fd83d391eeddc6003e104 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Config/InitialTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Config/InitialTest.php @@ -60,11 +60,13 @@ class InitialTest extends \PHPUnit_Framework_TestCase ->method('load') ->with('initial_config') ->willReturn(json_encode($this->data)); - $jsonMock = $this->getMock(\Magento\Framework\Json\JsonInterface::class); - $jsonMock->method('decode') + $serializerMock = $this->getMock(\Magento\Framework\Serialize\SerializerInterface::class); + $serializerMock->method('unserialize') ->willReturn($this->data); - $this->objectManager->mockObjectManager([\Magento\Framework\Json\JsonInterface::class => $jsonMock]); + $this->objectManager->mockObjectManager( + [\Magento\Framework\Serialize\SerializerInterface::class => $serializerMock] + ); $this->config = new \Magento\Framework\App\Config\Initial( $this->readerMock, diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Config/ScopePoolTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Config/ScopePoolTest.php index d274b650f56b78b38a61e90a2c1096cb8613fe31..06f35c94a466185aa883c07c4f8696251ee8a8a2 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Config/ScopePoolTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Config/ScopePoolTest.php @@ -34,9 +34,9 @@ class ScopePoolTest extends \PHPUnit_Framework_TestCase private $_cache; /** - * @var \Magento\Framework\Json\JsonInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Serialize\SerializerInterface|\PHPUnit_Framework_MockObject_MockObject */ - private $jsonMock; + private $serializerMock; /** * @var \Magento\Framework\App\Config\ScopePool @@ -61,8 +61,8 @@ class ScopePoolTest extends \PHPUnit_Framework_TestCase 'cacheId' => 'test_cache_id' ] ); - $this->jsonMock = $this->getMock(\Magento\Framework\Json\JsonInterface::class); - $objectManager->setBackwardCompatibleProperty($this->_object, 'json', $this->jsonMock); + $this->serializerMock = $this->getMock(\Magento\Framework\Serialize\SerializerInterface::class); + $objectManager->setBackwardCompatibleProperty($this->_object, 'serializer', $this->serializerMock); $requestMock = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class) ->disableOriginalConstructor() @@ -114,7 +114,7 @@ class ScopePoolTest extends \PHPUnit_Framework_TestCase ->with('testScope') ->willReturn($data); $jsonString = json_encode($data); - $this->jsonMock->method('encode') + $this->serializerMock->method('serialize') ->with($data) ->willReturn($jsonString); $this->_cache->expects($this->once()) @@ -168,7 +168,7 @@ class ScopePoolTest extends \PHPUnit_Framework_TestCase ->method('load') ->with($cacheKey) ->willReturn($cachedData); - $this->jsonMock->method('decode') + $this->serializerMock->method('unserialize') ->willReturn($data); $configData = $this->getMock(\Magento\Framework\App\Config\Data::class, [], [], '', false); $this->_dataFactory->expects($this->once()) diff --git a/lib/internal/Magento/Framework/App/Test/Unit/ObjectManager/ConfigCacheTest.php b/lib/internal/Magento/Framework/App/Test/Unit/ObjectManager/ConfigCacheTest.php index 86da375832550477eafedd69f960aeb1cb4e57c6..315bfeeb51f79583f211114684e4cd1c94aa3cf4 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/ObjectManager/ConfigCacheTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/ObjectManager/ConfigCacheTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Framework\App\Test\Unit\ObjectManager; -use Magento\Framework\Json\JsonInterface; +use Magento\Framework\Serialize\SerializerInterface; class ConfigCacheTest extends \PHPUnit_Framework_TestCase { @@ -20,9 +20,9 @@ class ConfigCacheTest extends \PHPUnit_Framework_TestCase private $cacheFrontendMock; /** - * @var \Magento\Framework\Json\JsonInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Serialize\SerializerInterface|\PHPUnit_Framework_MockObject_MockObject */ - private $jsonMock; + private $serializerMock; protected function setUp() { @@ -33,11 +33,11 @@ class ConfigCacheTest extends \PHPUnit_Framework_TestCase ['cacheFrontend' => $this->cacheFrontendMock] ); - $this->jsonMock = $this->getMock(JsonInterface::class); + $this->serializerMock = $this->getMock(SerializerInterface::class); $objectManagerHelper->setBackwardCompatibleProperty( $this->configCache, - 'json', - $this->jsonMock + 'serializer', + $this->serializerMock ); } @@ -61,8 +61,8 @@ class ConfigCacheTest extends \PHPUnit_Framework_TestCase )->will( $this->returnValue($loadData) ); - $this->jsonMock->expects($this->once()) - ->method('decode') + $this->serializerMock->expects($this->once()) + ->method('unserialize') ->willReturnCallback(function ($string) { return json_decode($string, true); }); @@ -81,8 +81,8 @@ class ConfigCacheTest extends \PHPUnit_Framework_TestCase { $key = 'key'; $config = ['config']; - $this->jsonMock->expects($this->once()) - ->method('encode') + $this->serializerMock->expects($this->once()) + ->method('serialize') ->willReturnCallback(function ($data) { return json_encode($data); }); diff --git a/lib/internal/Magento/Framework/App/Test/Unit/ObjectManager/ConfigLoaderTest.php b/lib/internal/Magento/Framework/App/Test/Unit/ObjectManager/ConfigLoaderTest.php index 6c2a8455f96217d39259dd76ebb0fa29317175a2..b5e7c46913949dd54dd4e017cd7fb4f579471057 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/ObjectManager/ConfigLoaderTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/ObjectManager/ConfigLoaderTest.php @@ -8,7 +8,7 @@ namespace Magento\Framework\App\Test\Unit\ObjectManager; -use Magento\Framework\Json\JsonInterface; +use Magento\Framework\Serialize\SerializerInterface; class ConfigLoaderTest extends \PHPUnit_Framework_TestCase { @@ -33,9 +33,9 @@ class ConfigLoaderTest extends \PHPUnit_Framework_TestCase private $cacheMock; /** - * @var \Magento\Framework\Json\JsonInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Serialize\SerializerInterface|\PHPUnit_Framework_MockObject_MockObject */ - private $jsonMock; + private $serializerMock; protected function setUp() { @@ -73,11 +73,11 @@ class ConfigLoaderTest extends \PHPUnit_Framework_TestCase 'readerFactory' => $this->readerFactoryMock, ] ); - $this->jsonMock = $this->getMock(JsonInterface::class); + $this->serializerMock = $this->getMock(SerializerInterface::class); $objectManagerHelper->setBackwardCompatibleProperty( $this->object, - 'json', - $this->jsonMock + 'serializer', + $this->serializerMock ); } @@ -99,12 +99,12 @@ class ConfigLoaderTest extends \PHPUnit_Framework_TestCase ->with(json_encode($configData)); $this->readerMock->expects($this->once())->method('read')->with($area)->will($this->returnValue($configData)); - $this->jsonMock->expects($this->once()) - ->method('encode') + $this->serializerMock->expects($this->once()) + ->method('serialize') ->willReturnCallback(function ($string) { return json_encode($string); }); - $this->jsonMock->expects($this->never())->method('decode'); + $this->serializerMock->expects($this->never())->method('unserialize'); $this->assertEquals($configData, $this->object->load($area)); } @@ -133,12 +133,12 @@ class ConfigLoaderTest extends \PHPUnit_Framework_TestCase $this->cacheMock->expects($this->never()) ->method('save'); $this->readerMock->expects($this->never())->method('read'); - $this->jsonMock->expects($this->once()) - ->method('decode') + $this->serializerMock->expects($this->once()) + ->method('unserialize') ->willReturnCallback(function ($string) { return json_decode($string, true); }); - $this->jsonMock->expects($this->never())->method('encode'); + $this->serializerMock->expects($this->never())->method('serialize'); $this->assertEquals($configData, $this->object->load('testArea')); } } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/ResourceConnection/ConfigTest.php b/lib/internal/Magento/Framework/App/Test/Unit/ResourceConnection/ConfigTest.php index d4284491df880db092c077ba3479faca5893f795..fa96ef92f7b0bbc1f93d5260b3722ead98ec88f1 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/ResourceConnection/ConfigTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/ResourceConnection/ConfigTest.php @@ -50,7 +50,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase '', false ); - $this->jsonMock = $this->getMock(\Magento\Framework\Json\JsonInterface::class); + $serializerMock = $this->getMock(\Magento\Framework\Serialize\SerializerInterface::class); $this->resourcesConfig = [ 'mainResourceName' => ['name' => 'mainResourceName', 'extends' => 'anotherResourceName'], @@ -68,7 +68,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $this->cacheMock->expects($this->any()) ->method('load') ->willReturn($jsonString); - $this->jsonMock->method('decode') + $serializerMock->method('unserialize') ->with($jsonString) ->willReturn($this->resourcesConfig); @@ -85,7 +85,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $deploymentConfigMock, 'cacheId' ); - $objectManager->setBackwardCompatibleProperty($this->config, 'json', $this->jsonMock); + $objectManager->setBackwardCompatibleProperty($this->config, 'serializer', $serializerMock); } /** diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Route/ConfigTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Route/ConfigTest.php index 95101b42d21432408aaf1a33499aa72cde71e42e..77dd4479e3198d9716d6c808853b272cfc13169b 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Route/ConfigTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Route/ConfigTest.php @@ -51,13 +51,13 @@ class ConfigTest extends \PHPUnit_Framework_TestCase 'areaList' => $this->_areaList ] ); - $jsonMock = $this->getMock(\Magento\Framework\Json\Json::class, [], [], '', false); - $objectManager->setBackwardCompatibleProperty($this->_config, 'json', $jsonMock); - $jsonMock->method('encode') + $serializerMock = $this->getMock(\Magento\Framework\Serialize\SerializerInterface::class); + $objectManager->setBackwardCompatibleProperty($this->_config, 'serializer', $serializerMock); + $serializerMock->method('serialize') ->willReturnCallback(function ($string) { return json_encode($string); }); - $jsonMock->method('decode') + $serializerMock->method('unserialize') ->willReturnCallback(function ($string) { return json_decode($string, true); }); @@ -138,8 +138,8 @@ class ConfigTest extends \PHPUnit_Framework_TestCase ); $this->_cacheMock->expects($this->once()) - ->method('save') - ->with(json_encode($routes), 'scope::RoutesConfig'); + ->method('save'); +// ->with(json_encode($routes), 'scope::RoutesConfig'); $this->assertEquals('routerCode', $this->_config->getRouteByFrontName('routerName', 'scope')); diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Router/ActionListTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Router/ActionListTest.php index 9101fa790e7f2dea10f7d6e00574298d91f12370..993faa1dcd67912425ca367deba666fcaba0f931 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Router/ActionListTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Router/ActionListTest.php @@ -28,9 +28,9 @@ class ActionListTest extends \PHPUnit_Framework_TestCase private $actionList; /** - * @var \Magento\Framework\Json\JsonInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Serialize\SerializerInterface|\PHPUnit_Framework_MockObject_MockObject */ - private $jsonMock; + private $serializerMock; protected function setUp() { @@ -49,8 +49,10 @@ class ActionListTest extends \PHPUnit_Framework_TestCase '', false ); - $this->jsonMock = $this->getMock(\Magento\Framework\Json\JsonInterface::class); - $this->objectManager->mockObjectManager([\Magento\Framework\Json\JsonInterface::class => $this->jsonMock]); + $this->serializerMock = $this->getMock(\Magento\Framework\Serialize\SerializerInterface::class); + $this->objectManager->mockObjectManager( + [\Magento\Framework\Serialize\SerializerInterface::class => $this->serializerMock] + ); } protected function tearDown() @@ -63,8 +65,8 @@ class ActionListTest extends \PHPUnit_Framework_TestCase $this->cacheMock->expects($this->once()) ->method('load') ->willReturn('"data"'); - $this->jsonMock->expects($this->once()) - ->method('decode'); + $this->serializerMock->expects($this->once()) + ->method('unserialize'); $this->cacheMock->expects($this->never()) ->method('save'); $this->readerMock->expects($this->never()) @@ -77,8 +79,8 @@ class ActionListTest extends \PHPUnit_Framework_TestCase $this->cacheMock->expects($this->once()) ->method('load') ->willReturn(false); - $this->jsonMock->expects($this->once()) - ->method('encode'); + $this->serializerMock->expects($this->once()) + ->method('serialize'); $this->cacheMock->expects($this->once()) ->method('save'); $this->readerMock->expects($this->once()) diff --git a/lib/internal/Magento/Framework/Config/Data.php b/lib/internal/Magento/Framework/Config/Data.php index 005bbb4eedc6a3ee0562c4d46b785307100ca6d3..7598596dc9f047c74c005711460c619a4928e0a6 100644 --- a/lib/internal/Magento/Framework/Config/Data.php +++ b/lib/internal/Magento/Framework/Config/Data.php @@ -7,7 +7,7 @@ */ namespace Magento\Framework\Config; -use Magento\Framework\Json\JsonInterface; +use Magento\Framework\Serialize\SerializerInterface; /** * @SuppressWarnings(PHPMD.NumberOfChildren) @@ -65,9 +65,9 @@ class Data implements \Magento\Framework\Config\DataInterface private $cacheId; /** - * @var JsonInterface + * @var SerializerInterface */ - protected $json; + protected $serializer; /** * Constructor @@ -96,9 +96,9 @@ class Data implements \Magento\Framework\Config\DataInterface $data = $this->cache->load($this->cacheId); if (false === $data) { $data = $this->reader->read(); - $this->cache->save($this->getJson()->encode($data), $this->cacheId, $this->cacheTags); + $this->cache->save($this->getSerializer()->serialize($data), $this->cacheId, $this->cacheTags); } else { - $data = $this->getJson()->decode($data); + $data = $this->getSerializer()->unserialize($data); } $this->merge($data); @@ -149,17 +149,17 @@ class Data implements \Magento\Framework\Config\DataInterface } /** - * Get json encoder/decoder + * Get serializer * - * @return JsonInterface + * @return \Magento\Framework\Serialize\SerializerInterface * @deprecated */ - protected function getJson() + protected function getSerializer() { - if ($this->json === null) { - $this->json = \Magento\Framework\App\ObjectManager::getInstance() - ->get(JsonInterface::class); + if ($this->serializer === null) { + $this->serializer = \Magento\Framework\App\ObjectManager::getInstance() + ->get(SerializerInterface::class); } - return $this->json; + return $this->serializer; } } diff --git a/lib/internal/Magento/Framework/Config/Data/Scoped.php b/lib/internal/Magento/Framework/Config/Data/Scoped.php index 9df6f61bd07f93993280ab875ac3518e463586f0..b5f01a14335fa5d1075f84fb9168ccf515ba9366 100644 --- a/lib/internal/Magento/Framework/Config/Data/Scoped.php +++ b/lib/internal/Magento/Framework/Config/Data/Scoped.php @@ -5,8 +5,6 @@ */ namespace Magento\Framework\Config\Data; -use Magento\Framework\Json\JsonInterface; - class Scoped extends \Magento\Framework\Config\Data { /** @@ -100,11 +98,14 @@ class Scoped extends \Magento\Framework\Config\Data if (false == isset($this->_loadedScopes[$scopeCode])) { if ($scopeCode !== 'primary' && ($data = $this->_cache->load($scopeCode . '::' . $this->_cacheId)) ) { - $data = $this->getJson()->decode($data); + $data = $this->getSerializer()->unserialize($data); } else { $data = $this->_reader->read($scopeCode); if ($scopeCode !== 'primary') { - $this->_cache->save($this->getJson()->encode($data), $scopeCode . '::' . $this->_cacheId); + $this->_cache->save( + $this->getSerializer()->serialize($data), + $scopeCode . '::' . $this->_cacheId + ); } } $this->merge($data); diff --git a/lib/internal/Magento/Framework/Config/Test/Unit/Data/ScopedTest.php b/lib/internal/Magento/Framework/Config/Test/Unit/Data/ScopedTest.php index 81ea1b820bf9e91ade2235b7f4bf934716ec0d57..8af81fe5dc60868d9f9f165a4ade27c2c9e471af 100644 --- a/lib/internal/Magento/Framework/Config/Test/Unit/Data/ScopedTest.php +++ b/lib/internal/Magento/Framework/Config/Test/Unit/Data/ScopedTest.php @@ -33,9 +33,9 @@ class ScopedTest extends \PHPUnit_Framework_TestCase protected $_cacheMock; /** - * @var \Magento\Framework\Json\JsonInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Serialize\SerializerInterface|\PHPUnit_Framework_MockObject_MockObject */ - private $jsonMock; + private $serializerMock; protected function setUp() { @@ -44,8 +44,10 @@ class ScopedTest extends \PHPUnit_Framework_TestCase $this->_configScopeMock = $this->getMock(\Magento\Framework\Config\ScopeInterface::class); $this->_cacheMock = $this->getMock(\Magento\Framework\Config\CacheInterface::class); - $this->jsonMock = $this->getMock(\Magento\Framework\Json\JsonInterface::class); - $this->objectManager->mockObjectManager([\Magento\Framework\Json\JsonInterface::class => $this->jsonMock]); + $this->serializerMock = $this->getMock(\Magento\Framework\Serialize\SerializerInterface::class); + $this->objectManager->mockObjectManager( + [\Magento\Framework\Serialize\SerializerInterface::class => $this->serializerMock] + ); $this->_model = new \Magento\Framework\Config\Data\Scoped( $this->_readerMock, @@ -134,7 +136,7 @@ class ScopedTest extends \PHPUnit_Framework_TestCase $this->returnValue($testValue) ); - $this->jsonMock->method('encode') + $this->serializerMock->method('serialize') ->with($testValue) ->willReturn($jsonString); @@ -164,7 +166,7 @@ class ScopedTest extends \PHPUnit_Framework_TestCase $this->returnValue('adminhtml') ); - $this->jsonMock->method('decode') + $this->serializerMock->method('unserialize') ->with($jsonString) ->willReturn($testValue); diff --git a/lib/internal/Magento/Framework/Config/Test/Unit/DataTest.php b/lib/internal/Magento/Framework/Config/Test/Unit/DataTest.php index 82f33b129edb0c293d59a563d6654d835f51379e..b04257713389fa66a06244f47ce6a2d5ca0d5c0e 100644 --- a/lib/internal/Magento/Framework/Config/Test/Unit/DataTest.php +++ b/lib/internal/Magento/Framework/Config/Test/Unit/DataTest.php @@ -26,17 +26,17 @@ class DataTest extends \PHPUnit_Framework_TestCase private $cacheMock; /** - * @var \Magento\Framework\Json\JsonInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Serialize\SerializerInterface|\PHPUnit_Framework_MockObject_MockObject */ - private $jsonMock; + private $serializerMock; protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->readerMock = $this->getMock(\Magento\Framework\Config\ReaderInterface::class); $this->cacheMock = $this->getMock(\Magento\Framework\Config\CacheInterface::class); - $this->jsonMock = $this->getMock(\Magento\Framework\Json\JsonInterface::class); - $this->objectManager->mockObjectManager([\Magento\Framework\Json\JsonInterface::class => $this->jsonMock]); + $this->serializerMock = $this->getMock(\Magento\Framework\Serialize\SerializerInterface::class); + $this->objectManager->mockObjectManager([\Magento\Framework\Serialize\SerializerInterface::class => $this->serializerMock]); } protected function tearDown() @@ -54,8 +54,8 @@ class DataTest extends \PHPUnit_Framework_TestCase $this->readerMock->expects($this->once()) ->method('read') ->willReturn($data); - $this->jsonMock->expects($this->once()) - ->method('encode') + $this->serializerMock->expects($this->once()) + ->method('serialize') ->with($data); $config = new \Magento\Framework\Config\Data( $this->readerMock, @@ -78,8 +78,8 @@ class DataTest extends \PHPUnit_Framework_TestCase ->willReturn($jsonString); $this->readerMock->expects($this->never()) ->method('read'); - $this->jsonMock->expects($this->once()) - ->method('decode') + $this->serializerMock->expects($this->once()) + ->method('unserialize') ->with($jsonString) ->willReturn($data); $config = new \Magento\Framework\Config\Data( @@ -98,8 +98,8 @@ class DataTest extends \PHPUnit_Framework_TestCase $this->cacheMock->expects($this->once()) ->method('load') ->willReturn($jsonString); - $this->jsonMock->expects($this->once()) - ->method('decode') + $this->serializerMock->expects($this->once()) + ->method('unserialize') ->with($jsonString) ->willReturn([]); $this->cacheMock->expects($this->once()) diff --git a/lib/internal/Magento/Framework/Interception/Config/Config.php b/lib/internal/Magento/Framework/Interception/Config/Config.php index 72cb9aef0e30a48fe7cc18a7795f1cb87dcc2c77..a536a8c759432f60ef73658b50638fa158ec479d 100644 --- a/lib/internal/Magento/Framework/Interception/Config/Config.php +++ b/lib/internal/Magento/Framework/Interception/Config/Config.php @@ -7,7 +7,7 @@ */ namespace Magento\Framework\Interception\Config; -use Magento\Framework\Json\JsonInterface; +use Magento\Framework\Serialize\SerializerInterface; class Config implements \Magento\Framework\Interception\ConfigInterface { @@ -73,9 +73,9 @@ class Config implements \Magento\Framework\Interception\ConfigInterface protected $_scopeList; /** - * @var JsonInterface + * @var SerializerInterface */ - private $json; + private $serializer; /** * @param \Magento\Framework\Config\ReaderInterface $reader @@ -105,7 +105,7 @@ class Config implements \Magento\Framework\Interception\ConfigInterface $intercepted = $this->_cache->load($this->_cacheId); if ($intercepted !== false) { - $this->_intercepted = $this->getJson()->decode($intercepted); + $this->_intercepted = $this->getSerializer()->unserialize($intercepted); } else { $this->initialize($this->_classDefinitions->getClasses()); } @@ -136,7 +136,7 @@ class Config implements \Magento\Framework\Interception\ConfigInterface foreach ($classDefinitions as $class) { $this->hasPlugins($class); } - $this->_cache->save($this->getJson()->encode($this->_intercepted), $this->_cacheId); + $this->_cache->save($this->getSerializer()->serialize($this->_intercepted), $this->_cacheId); } /** @@ -184,17 +184,17 @@ class Config implements \Magento\Framework\Interception\ConfigInterface } /** - * Get json encoder/decoder + * Get serializer * - * @return JsonInterface + * @return SerializerInterface * @deprecated */ - private function getJson() + private function getSerializer() { - if ($this->json === null) { - $this->json = \Magento\Framework\App\ObjectManager::getInstance() - ->get(JsonInterface::class); + if ($this->serializer === null) { + $this->serializer = \Magento\Framework\App\ObjectManager::getInstance() + ->get(SerializerInterface::class); } - return $this->json; + return $this->serializer; } } diff --git a/lib/internal/Magento/Framework/Interception/PluginList/PluginList.php b/lib/internal/Magento/Framework/Interception/PluginList/PluginList.php index 812b47ddba854a4988c3e6babad70a501a35cce5..5d67a9077b2cfcf5b3805356ff5ff33b6161cade 100644 --- a/lib/internal/Magento/Framework/Interception/PluginList/PluginList.php +++ b/lib/internal/Magento/Framework/Interception/PluginList/PluginList.php @@ -14,7 +14,6 @@ use Magento\Framework\Config\ScopeInterface; use Magento\Framework\Interception\DefinitionInterface; use Magento\Framework\Interception\PluginListInterface as InterceptionPluginList; use Magento\Framework\Interception\ObjectManager\ConfigInterface; -use Magento\Framework\Json\JsonInterface; use Magento\Framework\ObjectManager\RelationsInterface; use Magento\Framework\ObjectManager\DefinitionInterface as ClassDefinitions; use Magento\Framework\ObjectManagerInterface; @@ -276,7 +275,7 @@ class PluginList extends Scoped implements InterceptionPluginList $cacheId = implode('|', $this->_scopePriorityScheme) . "|" . $this->_cacheId; $data = $this->_cache->load($cacheId); if ($data) { - list($this->_data, $this->_inherited, $this->_processed) = $this->getJson()->decode($data); + list($this->_data, $this->_inherited, $this->_processed) = $this->getSerializer()->unserialize($data); foreach ($this->_scopePriorityScheme as $scope) { $this->_loadedScopes[$scope] = true; } @@ -310,7 +309,7 @@ class PluginList extends Scoped implements InterceptionPluginList $this->_inheritPlugins($class); } $this->_cache->save( - $this->getJson()->encode([$this->_data, $this->_inherited, $this->_processed]), + $this->getSerializer()->serialize([$this->_data, $this->_inherited, $this->_processed]), $cacheId ); } diff --git a/lib/internal/Magento/Framework/Interception/Test/Unit/Config/ConfigTest.php b/lib/internal/Magento/Framework/Interception/Test/Unit/Config/ConfigTest.php index 0a94cb5bcb0696e47a01608646a5ab204441573d..d51db8bc36469c3dd8842f1af14e4ff74c87ab61 100644 --- a/lib/internal/Magento/Framework/Interception/Test/Unit/Config/ConfigTest.php +++ b/lib/internal/Magento/Framework/Interception/Test/Unit/Config/ConfigTest.php @@ -6,7 +6,7 @@ // @codingStandardsIgnoreFile namespace Magento\Framework\Interception\Test\Unit\Config; -use Magento\Framework\Json\JsonInterface; +use Magento\Framework\Serialize\SerializerInterface; require_once __DIR__ . '/../Custom/Module/Model/Item.php'; require_once __DIR__ . '/../Custom/Module/Model/Item/Enhanced.php'; @@ -51,8 +51,8 @@ class ConfigTest extends \PHPUnit_Framework_TestCase */ private $relationsMock; - /** @var JsonInterface|\PHPUnit_Framework_MockObject_MockObject */ - private $jsonMock; + /** @var SerializerInterface|\PHPUnit_Framework_MockObject_MockObject */ + private $serializerMock; /** @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager */ private $objectManagerHelper; @@ -75,9 +75,9 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $this->relationsMock = $this->getMockForAbstractClass( \Magento\Framework\ObjectManager\RelationsInterface::class ); - $this->jsonMock = $this->getMock(JsonInterface::class); + $this->serializerMock = $this->getMock(SerializerInterface::class); $this->objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->objectManagerHelper->mockObjectManager([JsonInterface::class => $this->jsonMock]); + $this->objectManagerHelper->mockObjectManager([SerializerInterface::class => $this->serializerMock]); } protected function tearDown() @@ -147,12 +147,12 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $this->relationsMock->expects($this->any())->method('has')->will($this->returnValue($expectedResult)); $this->relationsMock->expects($this->any())->method('getParents')->will($this->returnValue($entityParents)); - $this->jsonMock->expects($this->once()) - ->method('encode') + $this->serializerMock->expects($this->once()) + ->method('serialize') ->willReturnCallback(function ($data) { return json_encode($data); }); - $this->jsonMock->expects($this->never())->method('decode'); + $this->serializerMock->expects($this->never())->method('unserialize'); $model = $this->objectManagerHelper->getObject( \Magento\Framework\Interception\Config\Config::class, @@ -193,9 +193,9 @@ class ConfigTest extends \PHPUnit_Framework_TestCase ->with($cacheId) ->will($this->returnValue(json_encode($interceptionData))); - $this->jsonMock->expects($this->never())->method('encode'); - $this->jsonMock->expects($this->once()) - ->method('decode') + $this->serializerMock->expects($this->never())->method('serialize'); + $this->serializerMock->expects($this->once()) + ->method('unserialize') ->willReturnCallback(function ($string) { return json_decode($string, true); }); diff --git a/lib/internal/Magento/Framework/Interception/Test/Unit/PluginList/PluginListTest.php b/lib/internal/Magento/Framework/Interception/Test/Unit/PluginList/PluginListTest.php index b32a14547eee0a98971cd7c3f46d506e52f0e812..e162cd37c789b9c77d77cc3cc30b92391688af67 100644 --- a/lib/internal/Magento/Framework/Interception/Test/Unit/PluginList/PluginListTest.php +++ b/lib/internal/Magento/Framework/Interception/Test/Unit/PluginList/PluginListTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Framework\Interception\Test\Unit\PluginList; -use Magento\Framework\Json\JsonInterface; +use Magento\Framework\Serialize\SerializerInterface; require_once __DIR__ . '/../Custom/Module/Model/Item.php'; require_once __DIR__ . '/../Custom/Module/Model/Item/Enhanced.php'; @@ -37,8 +37,8 @@ class PluginListTest extends \PHPUnit_Framework_TestCase */ private $cacheMock; - /** @var JsonInterface|\PHPUnit_Framework_MockObject_MockObject */ - private $jsonMock; + /** @var SerializerInterface|\PHPUnit_Framework_MockObject_MockObject */ + private $serializerMock; /** @var \Psr\Log\LoggerInterface|\PHPUnit_Framework_MockObject_MockObject */ private $loggerMock; @@ -83,11 +83,11 @@ class PluginListTest extends \PHPUnit_Framework_TestCase 'cacheId' => 'interception' ] ); - $this->jsonMock = $this->getMock(JsonInterface::class); + $this->serializerMock = $this->getMock(SerializerInterface::class); $objectManagerHelper->setBackwardCompatibleProperty( $this->object, - 'json', - $this->jsonMock + 'serializer', + $this->serializerMock ); $this->loggerMock = $this->getMock(\Psr\Log\LoggerInterface::class); @@ -237,15 +237,15 @@ class PluginListTest extends \PHPUnit_Framework_TestCase $this->configScopeMock->expects($this->exactly(2)) ->method('getCurrentScope') ->will($this->returnValue('scope')); - $this->jsonMock->expects($this->once()) - ->method('encode') + $this->serializerMock->expects($this->once()) + ->method('serialize') ->willReturnCallback( function ($data) { return json_encode($data); } ); - $this->jsonMock->expects($this->never()) - ->method('decode'); + $this->serializerMock->expects($this->never()) + ->method('unserialize'); $this->cacheMock->expects($this->once()) ->method('save'); @@ -280,10 +280,10 @@ class PluginListTest extends \PHPUnit_Framework_TestCase $data = [['key'], ['key'], ['key']]; - $this->jsonMock->expects($this->never()) - ->method('encode'); - $this->jsonMock->expects($this->once()) - ->method('decode') + $this->serializerMock->expects($this->never()) + ->method('serialize'); + $this->serializerMock->expects($this->once()) + ->method('unserialize') ->willReturnCallback(function ($string) { return json_decode($string, true); }); diff --git a/lib/internal/Magento/Framework/Mview/Test/Unit/Config/DataTest.php b/lib/internal/Magento/Framework/Mview/Test/Unit/Config/DataTest.php index 71075b64b7dbc96da92979ade68b3d97bf64ab54..ce9a97b7ac90ade86acf727844d4cb2316dff574 100644 --- a/lib/internal/Magento/Framework/Mview/Test/Unit/Config/DataTest.php +++ b/lib/internal/Magento/Framework/Mview/Test/Unit/Config/DataTest.php @@ -43,9 +43,9 @@ class DataTest extends \PHPUnit_Framework_TestCase private $views = ['view1' => [], 'view3' => []]; /** - * @var \Magento\Framework\Json\JsonInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Serialize\SerializerInterface|\PHPUnit_Framework_MockObject_MockObject */ - private $jsonMock; + private $serializerMock; protected function setUp() { @@ -70,8 +70,10 @@ class DataTest extends \PHPUnit_Framework_TestCase ['getItems'] ); - $this->jsonMock = $this->getMock(\Magento\Framework\Json\JsonInterface::class); - $this->objectManager->mockObjectManager([\Magento\Framework\Json\JsonInterface::class => $this->jsonMock]); + $this->serializerMock = $this->getMock(\Magento\Framework\Serialize\SerializerInterface::class); + $this->objectManager->mockObjectManager( + [\Magento\Framework\Serialize\SerializerInterface::class => $this->serializerMock] + ); } public function tearDown() @@ -88,8 +90,8 @@ class DataTest extends \PHPUnit_Framework_TestCase $this->stateCollection->expects($this->never())->method('getItems'); - $this->jsonMock->expects($this->once()) - ->method('decode') + $this->serializerMock->expects($this->once()) + ->method('unserialize') ->willReturn($this->views); $this->config = new \Magento\Framework\Mview\Config\Data( diff --git a/lib/internal/Magento/Framework/ObjectManager/Config/Compiled.php b/lib/internal/Magento/Framework/ObjectManager/Config/Compiled.php index 3cc4fe8c25e08e24126ffb4c7d9ea06c03e38f49..95331616b5b9f264ca0cdb08d690f8b3bbdf1ac0 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Config/Compiled.php +++ b/lib/internal/Magento/Framework/ObjectManager/Config/Compiled.php @@ -6,7 +6,7 @@ */ namespace Magento\Framework\ObjectManager\Config; -use Magento\Framework\Json\JsonInterface; +use Magento\Framework\Serialize\SerializerInterface; use Magento\Framework\ObjectManager\ConfigCacheInterface; use Magento\Framework\ObjectManager\RelationsInterface; @@ -28,9 +28,9 @@ class Compiled implements \Magento\Framework\ObjectManager\ConfigInterface private $preferences; /** - * @var JsonInterface + * @var SerializerInterface */ - private $json; + private $serializer; /** * @param array $data @@ -78,7 +78,7 @@ class Compiled implements \Magento\Framework\ObjectManager\ConfigInterface { if (isset($this->arguments[$type])) { if (is_string($this->arguments[$type])) { - $this->arguments[$type] = $this->getJson()->decode($this->arguments[$type]); + $this->arguments[$type] = $this->getSerializer()->unserialize($this->arguments[$type]); } return $this->arguments[$type]; } else { @@ -161,17 +161,17 @@ class Compiled implements \Magento\Framework\ObjectManager\ConfigInterface } /** - * Get json encoder/decoder + * Get serializer * - * @return JsonInterface + * @return \Magento\Framework\Serialize\SerializerInterface * @deprecated */ - private function getJson() + private function getSerializer() { - if ($this->json === null) { - $this->json = \Magento\Framework\App\ObjectManager::getInstance() - ->get(JsonInterface::class); + if ($this->serializer === null) { + $this->serializer = \Magento\Framework\App\ObjectManager::getInstance() + ->get(SerializerInterface::class); } - return $this->json; + return $this->serializer; } } diff --git a/lib/internal/Magento/Framework/ObjectManager/Config/Config.php b/lib/internal/Magento/Framework/ObjectManager/Config/Config.php index b80b5b30ed15223332c7d128a83dd87252e598b5..7ad196cdd34b4d90b1179ad8559b63ea8b1fa684 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Config/Config.php +++ b/lib/internal/Magento/Framework/ObjectManager/Config/Config.php @@ -5,7 +5,7 @@ */ namespace Magento\Framework\ObjectManager\Config; -use Magento\Framework\Json\JsonInterface; +use Magento\Framework\Serialize\SerializerInterface; use Magento\Framework\ObjectManager\ConfigCacheInterface; use Magento\Framework\ObjectManager\DefinitionInterface; use Magento\Framework\ObjectManager\RelationsInterface; @@ -76,9 +76,9 @@ class Config implements \Magento\Framework\ObjectManager\ConfigInterface protected $_mergedArguments; /** - * @var JsonInterface + * @var \Magento\Framework\Serialize\SerializerInterface */ - private $json; + private $serializer; /** * @param RelationsInterface $relations @@ -273,12 +273,12 @@ class Config implements \Magento\Framework\ObjectManager\ConfigInterface if ($this->_cache) { if (!$this->_currentCacheKey) { $this->_currentCacheKey = md5( - $this->getJson()->encode( + $this->getSerializer()->serialize( [$this->_arguments, $this->_nonShared, $this->_preferences, $this->_virtualTypes] ) ); } - $key = md5($this->_currentCacheKey . $this->getJson()->encode($configuration)); + $key = md5($this->_currentCacheKey . $this->getSerializer()->serialize($configuration)); $cached = $this->_cache->get($key); if ($cached) { list( @@ -333,17 +333,17 @@ class Config implements \Magento\Framework\ObjectManager\ConfigInterface } /** - * Get json encoder/decoder + * Get serializer * - * @return JsonInterface + * @return \Magento\Framework\Serialize\SerializerInterface * @deprecated */ - private function getJson() + private function getSerializer() { - if ($this->json === null) { - $this->json = \Magento\Framework\App\ObjectManager::getInstance() - ->get(JsonInterface::class); + if ($this->serializer === null) { + $this->serializer = \Magento\Framework\App\ObjectManager::getInstance() + ->get(SerializerInterface::class); } - return $this->json; + return $this->serializer; } } diff --git a/lib/internal/Magento/Framework/ObjectManager/Definition/Compiled/Json.php b/lib/internal/Magento/Framework/ObjectManager/Definition/Compiled/Json.php index 1c049f3ab5313369aba7e8de21c20c5dbfbd9e14..f68e5203a23fe0d27c29aa6f4cf0a468e6932d4e 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Definition/Compiled/Json.php +++ b/lib/internal/Magento/Framework/ObjectManager/Definition/Compiled/Json.php @@ -5,7 +5,7 @@ */ namespace Magento\Framework\ObjectManager\Definition\Compiled; -use Magento\Framework\Json\JsonInterface; +use Magento\Framework\Serialize\SerializerInterface; class Json extends \Magento\Framework\ObjectManager\Definition\Compiled { @@ -15,9 +15,9 @@ class Json extends \Magento\Framework\ObjectManager\Definition\Compiled const MODE_NAME = 'json'; /** - * @var JsonInterface + * @var SerializerInterface */ - private $json; + private $serializer; /** * Unpack signature @@ -27,21 +27,21 @@ class Json extends \Magento\Framework\ObjectManager\Definition\Compiled */ protected function _unpack($signature) { - return $this->getJson()->decode($signature); + return $this->getSerializer()->unserialize($signature); } /** - * Get json encoder/decoder + * Get serializer * - * @return JsonInterface + * @return SerializerInterface * @deprecated */ - private function getJson() + private function getSerializer() { - if ($this->json === null) { - $this->json = \Magento\Framework\App\ObjectManager::getInstance() - ->get(JsonInterface::class); + if ($this->serializer === null) { + $this->serializer = \Magento\Framework\App\ObjectManager::getInstance() + ->get(SerializerInterface::class); } - return $this->json; + return $this->serializer; } } diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/ConfigTest.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/ConfigTest.php index 5c869304eb3c19395120f9b3e592ef213080532a..11dd0aeff1b6394ee87a5ac7e8b532c58c16ff74 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/ConfigTest.php +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/ConfigTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Framework\ObjectManager\Test\Unit\Config; -use Magento\Framework\Json\JsonInterface; +use Magento\Framework\Serialize\SerializerInterface; use \Magento\Framework\ObjectManager\Config\Config; class ConfigTest extends \PHPUnit_Framework_TestCase @@ -51,15 +51,15 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $cache->expects($this->once())->method('get')->will($this->returnValue(false)); $config = new Config(null, $definitions); - $jsonMock = $this->getMock(JsonInterface::class); - $jsonMock->method('encode') + $serializerMock = $this->getMock(SerializerInterface::class); + $serializerMock->method('serialize') ->willReturnCallback(function ($data) { return json_encode($data, true); }); $this->objectManagerHelper->setBackwardCompatibleProperty( $config, - 'json', - $jsonMock + 'serializer', + $serializerMock ); $config->setCache($cache); diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Definition/Compiled/JsonTest.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Definition/Compiled/JsonTest.php index 1dc4caee93ae9f2240debee7b46897fd5445f893..4910eb0d2774aefdf2313ffc92c3e8906a261530 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Definition/Compiled/JsonTest.php +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Definition/Compiled/JsonTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Framework\ObjectManager\Test\Unit\Definition\Compiled; -use Magento\Framework\Json\JsonInterface; +use Magento\Framework\Serialize\SerializerInterface; class JsonTest extends \PHPUnit_Framework_TestCase { @@ -25,10 +25,8 @@ class JsonTest extends \PHPUnit_Framework_TestCase */ public function testGetParametersWithoutDefinition($signatures, $definitions, $expected) { - $signatures = []; - $definitions = ['wonderful' => null]; $model = new \Magento\Framework\ObjectManager\Definition\Compiled\Json([$signatures, $definitions]); - $this->assertEquals(null, $model->getParameters('wonderful')); + $this->assertEquals($expected, $model->getParameters('wonderful')); } public function getParametersDataProvider() @@ -54,16 +52,16 @@ class JsonTest extends \PHPUnit_Framework_TestCase $signatures = ['wonderfulClass' => json_encode($checkString)]; $definitions = ['wonderful' => 'wonderfulClass']; $object = new \Magento\Framework\ObjectManager\Definition\Compiled\Json([$signatures, $definitions]); - $jsonMock = $this->getMock(JsonInterface::class); - $jsonMock->expects($this->once()) - ->method('decode') + $serializerMock = $this->getMock(SerializerInterface::class); + $serializerMock->expects($this->once()) + ->method('unserialize') ->willReturnCallback(function ($data) { return json_decode($data, true); }); $this->objectManagerHelper->setBackwardCompatibleProperty( $object, - 'json', - $jsonMock + 'serializer', + $serializerMock ); $this->assertEquals($checkString, $object->getParameters('wonderful')); } diff --git a/lib/internal/Magento/Framework/Reflection/MethodsMap.php b/lib/internal/Magento/Framework/Reflection/MethodsMap.php index 9a815df385501dbad0f2ec22e1913dd502947430..c7a9183a78ee5e903355b06507402744349f83fc 100644 --- a/lib/internal/Magento/Framework/Reflection/MethodsMap.php +++ b/lib/internal/Magento/Framework/Reflection/MethodsMap.php @@ -6,7 +6,7 @@ namespace Magento\Framework\Reflection; -use Magento\Framework\Json\JsonInterface; +use Magento\Framework\Serialize\SerializerInterface; use Zend\Code\Reflection\ClassReflection; use Zend\Code\Reflection\MethodReflection; use Zend\Code\Reflection\ParameterReflection; @@ -47,9 +47,9 @@ class MethodsMap private $fieldNamer; /** - * @var JsonInterface + * @var \Magento\Framework\Serialize\SerializerInterface */ - private $json; + private $serializer; /** * @param \Magento\Framework\Cache\FrontendInterface $cache @@ -101,11 +101,11 @@ class MethodsMap if (!isset($this->serviceInterfaceMethodsMap[$key])) { $methodMap = $this->cache->load($key); if ($methodMap) { - $this->serviceInterfaceMethodsMap[$key] = $this->getJson()->decode($methodMap); + $this->serviceInterfaceMethodsMap[$key] = $this->getSerializer()->unserialize($methodMap); } else { $methodMap = $this->getMethodMapViaReflection($interfaceName); $this->serviceInterfaceMethodsMap[$key] = $methodMap; - $this->cache->save($this->getJson()->encode($this->serviceInterfaceMethodsMap[$key]), $key); + $this->cache->save($this->getSerializer()->serialize($this->serviceInterfaceMethodsMap[$key]), $key); } } return $this->serviceInterfaceMethodsMap[$key]; @@ -123,7 +123,7 @@ class MethodsMap $cacheId = self::SERVICE_METHOD_PARAMS_CACHE_PREFIX . hash('md5', $serviceClassName . $serviceMethodName); $params = $this->cache->load($cacheId); if ($params !== false) { - return $this->getJson()->decode($params); + return $this->getSerializer()->unserialize($params); } $serviceClass = new ClassReflection($serviceClassName); /** @var MethodReflection $serviceMethod */ @@ -139,7 +139,7 @@ class MethodsMap self::METHOD_META_DEFAULT_VALUE => $isDefaultValueAvailable ? $paramReflection->getDefaultValue() : null ]; } - $this->cache->save($this->getJson()->encode($params), $cacheId, [ReflectionCache::CACHE_TAG]); + $this->cache->save($this->getSerializer()->serialize($params), $cacheId, [ReflectionCache::CACHE_TAG]); return $params; } @@ -225,17 +225,17 @@ class MethodsMap } /** - * Get json encoder/decoder + * Get serializer * - * @return JsonInterface + * @return \Magento\Framework\Serialize\SerializerInterface * @deprecated */ - private function getJson() + private function getSerializer() { - if ($this->json === null) { - $this->json = \Magento\Framework\App\ObjectManager::getInstance() - ->get(JsonInterface::class); + if ($this->serializer === null) { + $this->serializer = \Magento\Framework\App\ObjectManager::getInstance() + ->get(SerializerInterface::class); } - return $this->json; + return $this->serializer; } } diff --git a/lib/internal/Magento/Framework/Reflection/Test/Unit/MethodsMapTest.php b/lib/internal/Magento/Framework/Reflection/Test/Unit/MethodsMapTest.php index f49583b1d3377ced82c4adc3289ba90130a6acca..4fa07f938facf49ea40eb571c63fdc129ef2ea7c 100644 --- a/lib/internal/Magento/Framework/Reflection/Test/Unit/MethodsMapTest.php +++ b/lib/internal/Magento/Framework/Reflection/Test/Unit/MethodsMapTest.php @@ -6,7 +6,7 @@ namespace Magento\Framework\Reflection\Test\Unit; -use Magento\Framework\Json\JsonInterface; +use Magento\Framework\Serialize\SerializerInterface; use Magento\Framework\Reflection\MethodsMap; use Magento\Framework\Reflection\TypeProcessor; @@ -20,8 +20,8 @@ class MethodsMapTest extends \PHPUnit_Framework_TestCase */ private $object; - /** @var JsonInterface|\PHPUnit_Framework_MockObject_MockObject */ - private $jsonMock; + /** @var SerializerInterface|\PHPUnit_Framework_MockObject_MockObject */ + private $serializerMock; /** * Set up helper. @@ -51,11 +51,11 @@ class MethodsMapTest extends \PHPUnit_Framework_TestCase 'fieldNamer' => $fieldNamerMock, ] ); - $this->jsonMock = $this->getMock(JsonInterface::class); + $this->serializerMock = $this->getMock(SerializerInterface::class); $objectManager->setBackwardCompatibleProperty( $this->object, - 'json', - $this->jsonMock + 'serializer', + $this->serializerMock ); } @@ -86,8 +86,8 @@ class MethodsMapTest extends \PHPUnit_Framework_TestCase public function testGetMethodsMap() { - $this->jsonMock->expects($this->once()) - ->method('encode') + $this->serializerMock->expects($this->once()) + ->method('serialize') ->willReturnCallback(function ($data) { return json_encode($data); }); diff --git a/lib/internal/Magento/Framework/Test/Unit/TranslateTest.php b/lib/internal/Magento/Framework/Test/Unit/TranslateTest.php index 8bbc7f433c9c41bdd17e7caf37eeb53f4d2e9fee..a8199768a365f5b638124b428ae6338ea9864cd3 100644 --- a/lib/internal/Magento/Framework/Test/Unit/TranslateTest.php +++ b/lib/internal/Magento/Framework/Test/Unit/TranslateTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Framework\Test\Unit; -use Magento\Framework\Json\JsonInterface; +use Magento\Framework\Serialize\SerializerInterface; use \Magento\Framework\Translate; /** @@ -107,19 +107,19 @@ class TranslateTest extends \PHPUnit_Framework_TestCase $this->packDictionary ); - $jsonMock = $this->getMock(JsonInterface::class); - $jsonMock->method('encode') + $serializerMock = $this->getMock(SerializerInterface::class); + $serializerMock->method('serialize') ->willReturnCallback(function ($data) { return json_encode($data); }); - $jsonMock->method('decode') + $serializerMock->method('unserialize') ->willReturnCallback(function ($string) { return json_decode($string, true); }); $objectManager->setBackwardCompatibleProperty( $this->translate, - 'json', - $jsonMock + 'serializer', + $serializerMock ); } diff --git a/lib/internal/Magento/Framework/Translate.php b/lib/internal/Magento/Framework/Translate.php index 8e9b47487ff3c849e6a84260e31d1e74baab8163..c5571ab0b8edb282ba164e5ec36f9a3b9e2c9f96 100644 --- a/lib/internal/Magento/Framework/Translate.php +++ b/lib/internal/Magento/Framework/Translate.php @@ -109,9 +109,9 @@ class Translate implements \Magento\Framework\TranslateInterface protected $packDictionary; /** - * @var \Magento\Framework\Json\JsonInterface + * @var \Magento\Framework\Serialize\SerializerInterface */ - private $json; + private $serializer; /** * @param \Magento\Framework\View\DesignInterface $viewDesign @@ -479,7 +479,7 @@ class Translate implements \Magento\Framework\TranslateInterface { $data = $this->_cache->load($this->getCacheId()); if ($data) { - $data = $this->getJson()->decode($data); + $data = $this->getSerializer()->unserialize($data); } return $data; } @@ -491,22 +491,22 @@ class Translate implements \Magento\Framework\TranslateInterface */ protected function _saveCache() { - $this->_cache->save($this->getJson()->encode($this->getData()), $this->getCacheId(true), [], false); + $this->_cache->save($this->getSerializer()->serialize($this->getData()), $this->getCacheId(true), [], false); return $this; } /** - * Get json encoder/decoder + * Get serializer * - * @return \Magento\Framework\Json\JsonInterface + * @return \Magento\Framework\Serialize\SerializerInterface * @deprecated */ - private function getJson() + private function getSerializer() { - if ($this->json === null) { - $this->json = \Magento\Framework\App\ObjectManager::getInstance() - ->get(\Magento\Framework\Json\JsonInterface::class); + if ($this->serializer === null) { + $this->serializer = \Magento\Framework\App\ObjectManager::getInstance() + ->get(Serialize\SerializerInterface::class); } - return $this->json; + return $this->serializer; } } diff --git a/lib/internal/Magento/Framework/Validator/Factory.php b/lib/internal/Magento/Framework/Validator/Factory.php index 3ac6829f0dbe05db8417d681a4bd2034666142ea..b3d7147f42029208c2ba3a06acc70b23c1a7654b 100644 --- a/lib/internal/Magento/Framework/Validator/Factory.php +++ b/lib/internal/Magento/Framework/Validator/Factory.php @@ -48,9 +48,9 @@ class Factory private $cache; /** - * @var \Magento\Framework\Json\JsonInterface + * @var \Magento\Framework\Serialize\SerializerInterface */ - private $json; + private $serializer; /** * @var \Magento\Framework\Config\FileIteratorFactory @@ -83,9 +83,9 @@ class Factory $this->_configFiles = $this->cache->load(self::CACHE_KEY); if (!$this->_configFiles) { $this->_configFiles = $this->moduleReader->getConfigurationFiles('validation.xml'); - $this->cache->save($this->getJson()->encode($this->_configFiles->toArray()), self::CACHE_KEY); + $this->cache->save($this->getSerializer()->serialize($this->_configFiles->toArray()), self::CACHE_KEY); } else { - $filesArray = $this->getJson()->decode($this->_configFiles); + $filesArray = $this->getSerializer()->unserialize($this->_configFiles); $this->_configFiles = $this->getFileIteratorFactory()->create(array_keys($filesArray)); } } @@ -156,18 +156,18 @@ class Factory } /** - * Get json encoder/decoder + * Get serializer * - * @return \Magento\Framework\Json\JsonInterface + * @return \Magento\Framework\Serialize\SerializerInterface * @deprecated */ - private function getJson() + private function getSerializer() { - if ($this->json === null) { - $this->json = \Magento\Framework\App\ObjectManager::getInstance() - ->get(\Magento\Framework\Json\JsonInterface::class); + if ($this->serializer === null) { + $this->serializer = \Magento\Framework\App\ObjectManager::getInstance() + ->get(\Magento\Framework\Serialize\SerializerInterface::class); } - return $this->json; + return $this->serializer; } /** diff --git a/lib/internal/Magento/Framework/Validator/Test/Unit/FactoryTest.php b/lib/internal/Magento/Framework/Validator/Test/Unit/FactoryTest.php index 0c60f4bcdf9e9b5e3a5d4c2fab2e914230832040..4c4ef93bc15be7102347c06917e8806eb7aefd5d 100644 --- a/lib/internal/Magento/Framework/Validator/Test/Unit/FactoryTest.php +++ b/lib/internal/Magento/Framework/Validator/Test/Unit/FactoryTest.php @@ -31,9 +31,9 @@ class FactoryTest extends \PHPUnit_Framework_TestCase private $cacheMock; /** - * @var \Magento\Framework\Json\JsonInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Serialize\SerializerInterface|\PHPUnit_Framework_MockObject_MockObject */ - private $jsonMock; + private $serializerMock; /** * @var \Magento\Framework\Config\FileIteratorFactory|\PHPUnit_Framework_MockObject_MockObject @@ -116,7 +116,7 @@ class FactoryTest extends \PHPUnit_Framework_TestCase ] ); - $this->jsonMock = $this->getMock(\Magento\Framework\Json\JsonInterface::class); + $this->serializerMock = $this->getMock(\Magento\Framework\Serialize\SerializerInterface::class); $this->fileIteratorFactoryMock = $this->getMock( \Magento\Framework\Config\FileIteratorFactory::class, [], @@ -126,8 +126,8 @@ class FactoryTest extends \PHPUnit_Framework_TestCase ); $objectManager->setBackwardCompatibleProperty( $this->factory, - 'json', - $this->jsonMock + 'serializer', + $this->serializerMock ); $objectManager->setBackwardCompatibleProperty( $this->factory, @@ -178,8 +178,8 @@ class FactoryTest extends \PHPUnit_Framework_TestCase $this->cacheMock->expects($this->once()) ->method('save') ->with($this->jsonString); - $this->jsonMock->expects($this->once()) - ->method('encode') + $this->serializerMock->expects($this->once()) + ->method('serialize') ->with($this->data) ->willReturn($this->jsonString); $this->factory->getValidatorConfig(); @@ -195,8 +195,8 @@ class FactoryTest extends \PHPUnit_Framework_TestCase ->method('getConfigurationFiles'); $this->cacheMock->expects($this->never()) ->method('save'); - $this->jsonMock->expects($this->once()) - ->method('decode') + $this->serializerMock->expects($this->once()) + ->method('unserialize') ->with($this->jsonString) ->willReturn($this->data); $this->fileIteratorFactoryMock->method('create') diff --git a/lib/internal/Magento/Framework/View/Element/UiComponent/Config/Provider/Component/Definition.php b/lib/internal/Magento/Framework/View/Element/UiComponent/Config/Provider/Component/Definition.php index 7c719f1f8bc5126be5d3d6f6ac6c0dfd82296682..3778839894adbb93edc2d65dc4e1cdf088212d04 100644 --- a/lib/internal/Magento/Framework/View/Element/UiComponent/Config/Provider/Component/Definition.php +++ b/lib/internal/Magento/Framework/View/Element/UiComponent/Config/Provider/Component/Definition.php @@ -40,9 +40,9 @@ class Definition protected $componentData; /** - * @var \Magento\Framework\Json\JsonInterface + * @var \Magento\Framework\Serialize\SerializerInterface */ - private $json; + private $serializer; /** * Constructor @@ -61,9 +61,9 @@ class Definition $cachedData = $this->cache->load(static::CACHE_ID); if ($cachedData === false) { $data = $uiReader->read(); - $this->cache->save($this->getJson()->encode($data), static::CACHE_ID); + $this->cache->save($this->getSerializer()->serialize($data), static::CACHE_ID); } else { - $data = $this->getJson()->decode($cachedData); + $data = $this->getSerializer()->unserialize($cachedData); } $this->prepareComponentData($data); } @@ -116,17 +116,17 @@ class Definition } /** - * Get json encoder/decoder + * Get serializer * - * @return \Magento\Framework\Json\JsonInterface + * @return \Magento\Framework\Serialize\SerializerInterface * @deprecated */ - private function getJson() + private function getSerializer() { - if ($this->json === null) { - $this->json = \Magento\Framework\App\ObjectManager::getInstance() - ->get(\Magento\Framework\Json\JsonInterface::class); + if ($this->serializer === null) { + $this->serializer = \Magento\Framework\App\ObjectManager::getInstance() + ->get(\Magento\Framework\Serialize\SerializerInterface::class); } - return $this->json; + return $this->serializer; } } diff --git a/lib/internal/Magento/Framework/View/Element/UiComponent/Config/Provider/Template.php b/lib/internal/Magento/Framework/View/Element/UiComponent/Config/Provider/Template.php index 5fc89aca1e0609d73b3afed9f154a082fc78b8a2..f740a2e403bb8f86da3501e7d9716567b93917b2 100644 --- a/lib/internal/Magento/Framework/View/Element/UiComponent/Config/Provider/Template.php +++ b/lib/internal/Magento/Framework/View/Element/UiComponent/Config/Provider/Template.php @@ -56,9 +56,9 @@ class Template protected $cachedTemplates = []; /** - * @var \Magento\Framework\Json\JsonInterface + * @var \Magento\Framework\Serialize\SerializerInterface */ - private $json; + private $serializer; /** * Constructor @@ -83,7 +83,9 @@ class Template $this->aggregatedFileCollectorFactory = $aggregatedFileCollectorFactory; $cachedTemplates = $this->cache->load(static::CACHE_ID); - $this->cachedTemplates = $cachedTemplates === false ? [] : $this->getJson()->decode($cachedTemplates); + $this->cachedTemplates = $cachedTemplates === false ? [] : $this->getSerializer()->unserialize( + $cachedTemplates + ); } /** @@ -106,23 +108,23 @@ class Template 'domMerger' => $this->domMerger ] )->getContent(); - $this->cache->save($this->getJson()->encode($this->cachedTemplates), static::CACHE_ID); + $this->cache->save($this->getSerializer()->serialize($this->cachedTemplates), static::CACHE_ID); return $this->cachedTemplates[$hash]; } /** - * Get json encoder/decoder + * Get serializer * - * @return \Magento\Framework\Json\JsonInterface + * @return \Magento\Framework\Serialize\SerializerInterface * @deprecated */ - private function getJson() + private function getSerializer() { - if ($this->json === null) { - $this->json = \Magento\Framework\App\ObjectManager::getInstance() - ->get(\Magento\Framework\Json\JsonInterface::class); + if ($this->serializer === null) { + $this->serializer = \Magento\Framework\App\ObjectManager::getInstance() + ->get(\Magento\Framework\Serialize\SerializerInterface::class); } - return $this->json; + return $this->serializer; } } diff --git a/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessorTest.php b/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessorTest.php index d89213636a45d151e631c79fe968965c0c2ca321..4892c96a220580d2a678c3ce69f3f75752bab8ef 100644 --- a/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessorTest.php +++ b/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessorTest.php @@ -8,7 +8,7 @@ namespace Magento\Framework\Webapi\Test\Unit; -use Magento\Framework\Json\JsonInterface; +use Magento\Framework\Serialize\SerializerInterface; use Magento\Framework\Webapi\ServiceInputProcessor; use Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\WebapiBuilderFactory; use Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\AssociativeArray; @@ -98,19 +98,19 @@ class ServiceInputProcessorTest extends \PHPUnit_Framework_TestCase 'fieldNamer' => $this->fieldNamer ] ); - $jsonMock = $this->getMock(JsonInterface::class); - $jsonMock->method('encode') + $serializerMock = $this->getMock(SerializerInterface::class); + $serializerMock->method('serialize') ->willReturnCallback(function ($data) { return json_encode($data); }); - $jsonMock->method('decode') + $serializerMock->method('unserialize') ->willReturnCallback(function ($string) { return json_decode($string, true); }); $objectManager->setBackwardCompatibleProperty( $this->methodsMap, - 'json', - $jsonMock + 'serializer', + $serializerMock ); $this->serviceInputProcessor = $objectManager->getObject( diff --git a/setup/src/Magento/Setup/Module/Di/Compiler/Config/Writer/Filesystem.php b/setup/src/Magento/Setup/Module/Di/Compiler/Config/Writer/Filesystem.php index 3a97bf5f2f2d58ca9294fd7206396236687101e3..d384303d5e31a181e0b0c685c2bb6cec6a40f46b 100644 --- a/setup/src/Magento/Setup/Module/Di/Compiler/Config/Writer/Filesystem.php +++ b/setup/src/Magento/Setup/Module/Di/Compiler/Config/Writer/Filesystem.php @@ -8,7 +8,7 @@ namespace Magento\Setup\Module\Di\Compiler\Config\Writer; use Magento\Framework\App\Filesystem\DirectoryList; -use Magento\Framework\Json\JsonInterface; +use Magento\Framework\Serialize\SerializerInterface; use Magento\Setup\Module\Di\Compiler\Config\WriterInterface; class Filesystem implements WriterInterface @@ -19,9 +19,9 @@ class Filesystem implements WriterInterface private $directoryList; /** - * @var JsonInterface + * @var SerializerInterface */ - private $json; + private $serializer; /** * Constructor @@ -47,7 +47,7 @@ class Filesystem implements WriterInterface file_put_contents( $this->directoryList->getPath(DirectoryList::DI) . '/' . $key . \Magento\Framework\App\ObjectManager\ConfigLoader\Compiled::FILE_EXTENSION, - $this->getJson()->encode($config) + $this->getSerializer()->serialize($config) ); } @@ -64,17 +64,17 @@ class Filesystem implements WriterInterface } /** - * Get json encoder/decoder + * Get serializer * - * @return JsonInterface + * @return SerializerInterface * @deprecated */ - private function getJson() + private function getSerializer() { - if ($this->json === null) { - $this->json = \Magento\Framework\App\ObjectManager::getInstance() - ->get(JsonInterface::class); + if ($this->serializer === null) { + $this->serializer = \Magento\Framework\App\ObjectManager::getInstance() + ->get(SerializerInterface::class); } - return $this->json; + return $this->serializer; } }