Skip to content

Migrate ZF2 components to Laminas components #26436

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 2 additions & 2 deletions app/code/Magento/CacheInvalidate/Model/PurgeCache.php
Original file line number Diff line number Diff line change
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
4 changes: 2 additions & 2 deletions app/code/Magento/CacheInvalidate/Model/SocketFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
class SocketFactory
{
/**
* @return \Zend\Http\Client\Adapter\Socket
* @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
4 changes: 2 additions & 2 deletions app/code/Magento/Captcha/Model/ResourceModel/Log.php
Original file line number Diff line number Diff line change
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 @@ -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 @@ -34,7 +34,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 @@ -14,7 +14,7 @@
use Magento\Framework\UrlInterface;
use Magento\Store\Model\ScopeInterface;
use Magento\Store\Model\Store;
use Zend\Uri\Uri as UriHandler;
use Laminas\Uri\Uri as UriHandler;
use Magento\Framework\Url\ScopeResolverInterface;
use Magento\Downloadable\Api\DomainManagerInterface as DomainManager;
use Magento\Framework\Setup\ModuleDataSetupInterface;
Expand Down
22 changes: 11 additions & 11 deletions app/code/Magento/Email/Model/Transport.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
use Magento\Framework\Mail\TransportInterface;
use Magento\Framework\Phrase;
use Magento\Store\Model\ScopeInterface;
use Zend\Mail\Message;
use Zend\Mail\Transport\Sendmail;
use Laminas\Mail\Message;
use Laminas\Mail\Transport\Sendmail;

/**
* Class that responsible for filling some message data before transporting it.
* @see \Zend\Mail\Transport\Sendmail is used for transport
* @see \Laminas\Mail\Transport\Sendmail is used for transport
*/
class Transport implements TransportInterface
{
Expand Down Expand Up @@ -53,7 +53,7 @@ class Transport implements TransportInterface
/**
* @var Sendmail
*/
private $zendTransport;
private $laminasTransport;

/**
* @var MessageInterface
Expand All @@ -79,7 +79,7 @@ public function __construct(
ScopeInterface::SCOPE_STORE
);

$this->zendTransport = new Sendmail($parameters);
$this->laminasTransport = new Sendmail($parameters);
$this->message = $message;
}

Expand All @@ -89,16 +89,16 @@ public function __construct(
public function sendMessage()
{
try {
$zendMessage = Message::fromString($this->message->getRawMessage())->setEncoding('utf-8');
$laminasMessage = Message::fromString($this->message->getRawMessage())->setEncoding('utf-8');
if (2 === $this->isSetReturnPath && $this->returnPathValue) {
$zendMessage->setSender($this->returnPathValue);
} elseif (1 === $this->isSetReturnPath && $zendMessage->getFrom()->count()) {
$fromAddressList = $zendMessage->getFrom();
$laminasMessage->setSender($this->returnPathValue);
} elseif (1 === $this->isSetReturnPath && $laminasMessage->getFrom()->count()) {
$fromAddressList = $laminasMessage->getFrom();
$fromAddressList->rewind();
$zendMessage->setSender($fromAddressList->current()->getEmail());
$laminasMessage->setSender($fromAddressList->current()->getEmail());
}

$this->zendTransport->send($zendMessage);
$this->laminasTransport->send($laminasMessage);
} catch (\Exception $e) {
throw new MailException(new Phrase($e->getMessage()), $e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace Magento\Integration\Test\Unit\Model\Oauth;

use Magento\Framework\Url\Validator as UrlValidator;
use Zend\Validator\Uri as ZendUriValidator;
use Laminas\Validator\Uri as LaminasUriValidator;
use Magento\Integration\Model\Oauth\Consumer\Validator\KeyLength;

/**
Expand Down Expand Up @@ -85,7 +85,7 @@ protected function setUp()

$this->keyLengthValidator = new KeyLength();

$this->urlValidator = new UrlValidator(new ZendUriValidator());
$this->urlValidator = new UrlValidator(new LaminasUriValidator());

$this->oauthDataMock = $this->createPartialMock(
\Magento\Integration\Helper\Oauth\Data::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Magento\MediaGalleryApi\Api\Data\AssetInterfaceFactory;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
use Zend\Db\Adapter\Driver\Pdo\Statement;
use Laminas\Db\Adapter\Driver\Pdo\Statement;

/**
* Test the GetById command with exception during media asset initialization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Magento\MediaGalleryApi\Api\Data\AssetInterfaceFactory;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
use Zend\Db\Adapter\Driver\Pdo\Statement;
use Laminas\Db\Adapter\Driver\Pdo\Statement;

/**
* Test the GetById command with exception thrown in case when there is no such entity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Magento\MediaGalleryApi\Api\Data\AssetInterfaceFactory;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
use Zend\Db\Adapter\Driver\Pdo\Statement;
use Laminas\Db\Adapter\Driver\Pdo\Statement;

/**
* Test the GetById command with exception during get media data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Magento\MediaGalleryApi\Api\Data\AssetInterfaceFactory;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
use Zend\Db\Adapter\Driver\Pdo\Statement;
use Laminas\Db\Adapter\Driver\Pdo\Statement;

/**
* Test the GetById command successful scenario
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected function setUp()
public function testSendResponse(): void
{
$filePath = 'file_path';
$headers = $this->getMockBuilder(\Zend\Http\Headers::class)->getMock();
$headers = $this->getMockBuilder(\Laminas\Http\Headers::class)->getMock();
$this->response->setFilePath($filePath);
$this->response->setHeaders($headers);
$this->transferAdapter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function aroundDispatch(
protected function addDebugHeaders(ResponseHttp $result)
{
$cacheControlHeader = $result->getHeader('Cache-Control');
if ($cacheControlHeader instanceof \Zend\Http\Header\HeaderInterface) {
if ($cacheControlHeader instanceof \Laminas\Http\Header\HeaderInterface) {
$this->addDebugHeader($result, 'X-Magento-Cache-Control', $cacheControlHeader->getFieldValue());
}
$this->addDebugHeader($result, 'X-Magento-Cache-Debug', 'MISS', true);
Expand Down
4 changes: 2 additions & 2 deletions app/code/Magento/PageCache/Model/Cache/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
use Magento\Framework\App\DeploymentConfig;
use Magento\Framework\Config\ConfigOptionsListConstants;
use Magento\Framework\App\RequestInterface;
use Zend\Uri\Uri;
use Zend\Uri\UriFactory;
use Laminas\Uri\Uri;
use Laminas\Uri\UriFactory;

/**
* Cache server model.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Magento\Framework\Registry;
use Magento\Framework\Controller\ResultInterface;
use Magento\Framework\App\Response\Http as ResponseHttp;
use Zend\Http\Header\HeaderInterface as HttpHeaderInterface;
use Laminas\Http\Header\HeaderInterface as HttpHeaderInterface;
use Magento\PageCache\Model\Cache\Type as CacheType;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ protected function setUp()
*/
public function testAroundDispatchProcessIfCacheMissed($state)
{
$header = \Zend\Http\Header\GenericHeader::fromString('Cache-Control: no-cache');
$header = \Laminas\Http\Header\GenericHeader::fromString('Cache-Control: no-cache');
$this->configMock
->expects($this->once())
->method('getType')
Expand Down
Loading