Skip to content

Commit

Permalink
Merge pull request #5484 from magento-trigger/MC-13825
Browse files Browse the repository at this point in the history
[TR] Migrate ZF2 components to Laminas
  • Loading branch information
fascinosum authored Mar 24, 2020
2 parents 70cf0c2 + b26e6c9 commit 892dee4
Show file tree
Hide file tree
Showing 249 changed files with 6,154 additions and 5,747 deletions.
2 changes: 1 addition & 1 deletion app/code/Magento/Backend/App/Area/FrontNameResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Magento\Framework\App\RequestInterface;
use Magento\Store\Model\ScopeInterface;
use Magento\Store\Model\Store;
use Zend\Uri\Uri;
use Laminas\Uri\Uri;

/**
* Class to get area front name.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class FrontNameResolverTest extends \PHPUnit\Framework\TestCase
protected $scopeConfigMock;

/**
* @var \PHPUnit_Framework_MockObject_MockObject|\Zend\Uri\Uri
* @var \PHPUnit_Framework_MockObject_MockObject|\Laminas\Uri\Uri
*/
protected $uri;

Expand All @@ -51,7 +51,7 @@ protected function setUp()
->method('get')
->with(ConfigOptionsList::CONFIG_PATH_BACKEND_FRONTNAME)
->will($this->returnValue($this->_defaultFrontName));
$this->uri = $this->createMock(\Zend\Uri\Uri::class);
$this->uri = $this->createMock(\Laminas\Uri\Uri::class);

$this->request = $this->createMock(\Magento\Framework\App\Request\Http::class);

Expand Down
6 changes: 3 additions & 3 deletions app/code/Magento/CacheInvalidate/Model/PurgeCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Magento\Framework\Cache\InvalidateLogger;

/**
* Class PurgeCache
* PurgeCache model
*/
class PurgeCache
{
Expand Down Expand Up @@ -110,8 +110,8 @@ private function splitTags($tagsPattern)
/**
* Send curl purge request to servers to invalidate cache by tags pattern
*
* @param \Zend\Http\Client\Adapter\Socket $socketAdapter
* @param \Zend\Uri\Uri[] $servers
* @param \Laminas\Http\Client\Adapter\Socket $socketAdapter
* @param \Laminas\Uri\Uri[] $servers
* @param string $formattedTagsChunk
* @return bool Return true if successful; otherwise return false
*/
Expand Down
11 changes: 9 additions & 2 deletions app/code/Magento/CacheInvalidate/Model/SocketFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,22 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\CacheInvalidate\Model;

/**
* Factory for the \Laminas\Http\Client\Adapter\Socket
*/
class SocketFactory
{
/**
* @return \Zend\Http\Client\Adapter\Socket
* Create object
*
* @return \Laminas\Http\Client\Adapter\Socket
*/
public function create()
{
return new \Zend\Http\Client\Adapter\Socket();
return new \Laminas\Http\Client\Adapter\Socket();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
*/
namespace Magento\CacheInvalidate\Test\Unit\Model;

use Zend\Uri\UriFactory;
use Laminas\Uri\UriFactory;

class PurgeCacheTest extends \PHPUnit\Framework\TestCase
{
/** @var \Magento\CacheInvalidate\Model\PurgeCache */
protected $model;

/** @var \PHPUnit_Framework_MockObject_MockObject | \Zend\Http\Client\Adapter\Socket */
/** @var \PHPUnit_Framework_MockObject_MockObject | \Laminas\Http\Client\Adapter\Socket */
protected $socketAdapterMock;

/** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\Cache\InvalidateLogger */
Expand All @@ -24,7 +24,7 @@ class PurgeCacheTest extends \PHPUnit\Framework\TestCase
protected function setUp()
{
$socketFactoryMock = $this->createMock(\Magento\CacheInvalidate\Model\SocketFactory::class);
$this->socketAdapterMock = $this->createMock(\Zend\Http\Client\Adapter\Socket::class);
$this->socketAdapterMock = $this->createMock(\Laminas\Http\Client\Adapter\Socket::class);
$this->socketAdapterMock->expects($this->once())
->method('setOptions')
->with(['timeout' => 10]);
Expand Down Expand Up @@ -113,7 +113,7 @@ public function testSendPurgeRequestWithException()
->method('getUris')
->willReturn($uris);
$this->socketAdapterMock->method('connect')
->willThrowException(new \Zend\Http\Client\Adapter\Exception\RuntimeException());
->willThrowException(new \Laminas\Http\Client\Adapter\Exception\RuntimeException());
$this->loggerMock->expects($this->never())
->method('execute');
$this->loggerMock->expects($this->once())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ class SocketFactoryTest extends \PHPUnit\Framework\TestCase
public function testCreate()
{
$factory = new \Magento\CacheInvalidate\Model\SocketFactory();
$this->assertInstanceOf(\Zend\Http\Client\Adapter\Socket::class, $factory->create());
$this->assertInstanceOf(\Laminas\Http\Client\Adapter\Socket::class, $factory->create());
}
}
10 changes: 5 additions & 5 deletions app/code/Magento/Captcha/Model/DefaultModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
use Magento\Framework\Math\Random;

/**
* Implementation of \Zend\Captcha\Image
* Implementation of \Laminas\Captcha\Image
*
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
*
* @api
* @since 100.0.2
*/
class DefaultModel extends \Zend\Captcha\Image implements \Magento\Captcha\Model\CaptchaInterface
class DefaultModel extends \Laminas\Captcha\Image implements \Magento\Captcha\Model\CaptchaInterface
{
/**
* Key in session for captcha code
Expand Down Expand Up @@ -51,7 +51,7 @@ class DefaultModel extends \Zend\Captcha\Image implements \Magento\Captcha\Model
/**
* Override default value to prevent a captcha cut off
* @var int
* @see \Zend\Captcha\Image::$fsize
* @see \Laminas\Captcha\Image::$fsize
* @since 100.2.0
*/
protected $fsize = 22;
Expand Down Expand Up @@ -99,7 +99,7 @@ class DefaultModel extends \Zend\Captcha\Image implements \Magento\Captcha\Model
* @param ResourceModel\LogFactory $resLogFactory
* @param string $formId
* @param Random $randomMath
* @throws \Zend\Captcha\Exception\ExtensionNotLoadedException
* @throws \Laminas\Captcha\Exception\ExtensionNotLoadedException
*/
public function __construct(
\Magento\Framework\Session\SessionManagerInterface $session,
Expand Down Expand Up @@ -537,7 +537,7 @@ private function clearWord()
/**
* Override function to generate less curly captcha that will not cut off
*
* @see \Zend\Captcha\Image::_randomSize()
* @see \Laminas\Captcha\Image::_randomSize()
* @return int
* @throws \Magento\Framework\Exception\LocalizedException
* @since 100.2.0
Expand Down
6 changes: 3 additions & 3 deletions app/code/Magento/Captcha/Model/ResourceModel/Log.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
class Log extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
{
/**
* Type Remote Address
* Remote Address log type
*/
const TYPE_REMOTE_ADDRESS = 1;

Expand Down Expand Up @@ -79,7 +79,7 @@ public function logAttempt($login)
'count' => 1,
'updated_at' => $this->_coreDate->gmtDate()
],
['count' => new \Zend\Db\Sql\Expression('count+1'), 'updated_at']
['count' => new \Laminas\Db\Sql\Expression('count+1'), 'updated_at']
);
}
$ip = $this->_remoteAddress->getRemoteAddress();
Expand All @@ -92,7 +92,7 @@ public function logAttempt($login)
'count' => 1,
'updated_at' => $this->_coreDate->gmtDate()
],
['count' => new \Zend\Db\Sql\Expression('count+1'), 'updated_at']
['count' => new \Laminas\Db\Sql\Expression('count+1'), 'updated_at']
);
}
return $this;
Expand Down
6 changes: 3 additions & 3 deletions app/code/Magento/Captcha/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"magento/module-checkout": "*",
"magento/module-customer": "*",
"magento/module-store": "*",
"zendframework/zend-captcha": "^2.7.1",
"zendframework/zend-db": "^2.8.2",
"zendframework/zend-session": "^2.7.3"
"laminas/laminas-captcha": "^2.7.1",
"laminas/laminas-db": "^2.8.2",
"laminas/laminas-session": "^2.7.3"
},
"type": "magento2-module",
"license": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@

use Magento\Catalog\Model\Product\ProductFrontendAction\Synchronizer;
use Magento\Framework\App\Action\Context;
use Magento\Framework\App\Action\HttpPostActionInterface;
use Magento\Framework\Controller\Result\JsonFactory;

/**
* Synchronizes Product Frontend Actions with database
*/
class Synchronize extends \Magento\Framework\App\Action\Action
class Synchronize extends \Magento\Framework\App\Action\Action implements HttpPostActionInterface
{
/**
* @var Context
Expand Down Expand Up @@ -46,6 +47,8 @@ public function __construct(
}

/**
* @inheritDoc
*
* This is handle for synchronizing between frontend and backend product actions:
* - visit product page (recently_viewed)
* - compare products (recently_compared)
Expand All @@ -57,9 +60,6 @@ public function __construct(
* 'added_at' => "JS_TIMESTAMP"
* ]
* ]
*
*
* @inheritdoc
*/
public function execute()
{
Expand All @@ -71,8 +71,8 @@ public function execute()
$this->synchronizer->syncActions($productsData, $typeId);
} catch (\Exception $e) {
$resultJson->setStatusHeader(
\Zend\Http\Response::STATUS_CODE_400,
\Zend\Http\AbstractMessage::VERSION_11,
\Laminas\Http\Response::STATUS_CODE_400,
\Laminas\Http\AbstractMessage::VERSION_11,
'Bad Request'
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ public function testExecuteActionException()
$jsonObject->expects($this->once())
->method('setStatusHeader')
->with(
\Zend\Http\Response::STATUS_CODE_400,
\Zend\Http\AbstractMessage::VERSION_11,
\Laminas\Http\Response::STATUS_CODE_400,
\Laminas\Http\AbstractMessage::VERSION_11,
'Bad Request'
);
$jsonObject->expects($this->once())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

use Magento\Framework\Locale\ResolverInterface;

/**
* Cart request quantity processor
*/
class RequestQuantityProcessor
{
/**
Expand All @@ -34,7 +37,7 @@ public function __construct(
*/
public function process(array $cartData): array
{
$filter = new \Zend\I18n\Filter\NumberParse($this->localeResolver->getLocale());
$filter = new \Laminas\I18n\Filter\NumberParse($this->localeResolver->getLocale());

foreach ($cartData as $index => $data) {
if (isset($data['qty'])) {
Expand Down
4 changes: 2 additions & 2 deletions app/code/Magento/Customer/Controller/Section/Load.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ public function execute()
$response = $this->sectionPool->getSectionsData($sectionNames, (bool)$forceNewSectionTimestamp);
} catch (\Exception $e) {
$resultJson->setStatusHeader(
\Zend\Http\Response::STATUS_CODE_400,
\Zend\Http\AbstractMessage::VERSION_11,
\Laminas\Http\Response::STATUS_CODE_400,
\Laminas\Http\AbstractMessage::VERSION_11,
'Bad Request'
);
$response = ['message' => $this->escaper->escapeHtml($e->getMessage())];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ public function testExecuteWithThrowException()
$this->resultJsonMock->expects($this->once())
->method('setStatusHeader')
->with(
\Zend\Http\Response::STATUS_CODE_400,
\Zend\Http\AbstractMessage::VERSION_11,
\Laminas\Http\Response::STATUS_CODE_400,
\Laminas\Http\AbstractMessage::VERSION_11,
'Bad Request'
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

use Magento\Downloadable\Api\DomainManagerInterface as DomainManager;
use Magento\Framework\Validator\Ip as IpValidator;
use Zend\Uri\Uri as UriHandler;
use Laminas\Uri\Uri as UriHandler;

/**
* Class is responsible for checking if downloadable product link domain is allowed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,22 @@

namespace Magento\Downloadable\Setup\Patch\Data;

use Laminas\Uri\Uri as UriHandler;
use Magento\Backend\App\Area\FrontNameResolver;
use Magento\Config\Model\Config\Backend\Admin\Custom;
use Magento\Downloadable\Api\DomainManagerInterface as DomainManager;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Framework\Url\ScopeResolverInterface;
use Magento\Framework\UrlInterface;
use Magento\Store\Model\ScopeInterface;
use Magento\Store\Model\Store;
use Zend\Uri\Uri as UriHandler;
use Magento\Framework\Url\ScopeResolverInterface;
use Magento\Downloadable\Api\DomainManagerInterface as DomainManager;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Backend\App\Area\FrontNameResolver;

/**
* Adding base url as allowed downloadable domain.
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class AddDownloadableHostsConfig implements DataPatchInterface
{
Expand Down Expand Up @@ -79,7 +80,7 @@ public function __construct(
}

/**
* @inheritdoc
* @inheritDoc
*/
public function apply()
{
Expand Down Expand Up @@ -141,6 +142,8 @@ public function apply()
}

$this->domainManager->addDomains($this->whitelist);

return $this;
}

/**
Expand Down
Loading

0 comments on commit 892dee4

Please sign in to comment.