Skip to content

Commit 2e8a98b

Browse files
committed
Fixed coding standard violation in the Framework namespace, so that it will be checked bij PHP CS and no longer be ignored while doing CI checks. Made the following changes:
- Removed the @codingStandardsIgnoreFile from the head of the file. - Fixed line length (expect command in the Url class where the comment is to long, so ignoring that specific line) - Fixed identation - Changed all is_null functions to a === null compare.
1 parent e3fc5b7 commit 2e8a98b

File tree

3 files changed

+23
-19
lines changed

3 files changed

+23
-19
lines changed

lib/internal/Magento/Framework/CurrencyFactory.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
// @codingStandardsIgnoreFile
8-
97
namespace Magento\Framework;
108

119
class CurrencyFactory
@@ -24,8 +22,10 @@ class CurrencyFactory
2422
* @param ObjectManagerInterface $objectManager
2523
* @param string $instanceName
2624
*/
27-
public function __construct(ObjectManagerInterface $objectManager, $instanceName = CurrencyInterface::class)
28-
{
25+
public function __construct(
26+
ObjectManagerInterface $objectManager,
27+
$instanceName = CurrencyInterface::class
28+
) {
2929
$this->_objectManager = $objectManager;
3030
$this->_instanceName = $instanceName;
3131
}

lib/internal/Magento/Framework/Url.php

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
// @codingStandardsIgnoreFile
8-
97
namespace Magento\Framework;
108

119
use Magento\Framework\App\ObjectManager;
@@ -43,13 +41,15 @@
4341
* - query_array: array('param1'=>'value1', 'param2'=>'value2')
4442
* - fragment: (#)'fragment-anchor'
4543
*
44+
* @codingStandardsIgnoreStart
4645
* URL structure:
4746
*
4847
* https://user:password@host:443/base_path/[base_script][scopeview_path]route_name/controller_name/action_name/param1/value1?query_param=query_value#fragment
4948
* \__________A___________/\____________________________________B_____________________________________/
5049
* \__________________C___________________/ \__________________D_________________/ \_____E_____/
5150
* \_____________F______________/ \___________________________G______________________/
5251
* \___________________________________________________H____________________________________________________/
52+
* @codingStandardsIgnoreEnd
5353
*
5454
* - A: authority
5555
* - B: path
@@ -145,6 +145,7 @@ class Url extends \Magento\Framework\DataObject implements \Magento\Framework\Ur
145145
* @var \Magento\Framework\Url\RouteParamsResolverFactory
146146
*/
147147
private $_routeParamsResolverFactory;
148+
148149
/**
149150
* @var \Magento\Framework\Url\ScopeResolverInterface
150151
*/
@@ -290,7 +291,7 @@ public function setUseSession($useSession)
290291
*/
291292
public function getUseSession()
292293
{
293-
if (is_null($this->_useSession)) {
294+
if ($this->_useSession === null) {
294295
$this->_useSession = $this->_sidResolver->getUseSessionInUrl();
295296
}
296297
return $this->_useSession;
@@ -305,7 +306,7 @@ public function getUseSession()
305306
*/
306307
public function getConfigData($key, $prefix = null)
307308
{
308-
if (is_null($prefix)) {
309+
if ($prefix === null) {
309310
$prefix = 'web/' . ($this->_isSecure() ? 'secure' : 'unsecure') . '/';
310311
}
311312
$path = $prefix . $key;
@@ -583,7 +584,7 @@ protected function _getRoutePath($routeParams = [])
583584
$routePath = $this->_getActionPath();
584585
if ($this->_getRouteParams()) {
585586
foreach ($this->_getRouteParams() as $key => $value) {
586-
if (is_null($value) || false === $value || '' === $value || !is_scalar($value)) {
587+
if ($value === null || false === $value || '' === $value || !is_scalar($value)) {
587588
continue;
588589
}
589590
$routePath .= $key . '/' . $value . '/';
@@ -855,7 +856,7 @@ function ($item) use (&$isCached) {
855856
);
856857
}
857858

858-
if(!$isCached) {
859+
if (!$isCached) {
859860
return $this->getUrlModifier()->execute(
860861
$this->createUrl($routePath, $routeParams)
861862
);
@@ -953,7 +954,7 @@ private function createUrl($routePath = null, array $routeParams = null)
953954
$this->_queryParamsResolver->unsetData('query_params');
954955
}
955956

956-
if (!is_null($fragment)) {
957+
if ($fragment !== null) {
957958
$url .= '#' . $this->getEscaper()->encodeUrlParam($fragment);
958959
}
959960
$this->getRouteParamsResolver()->unsetData('secure');
@@ -1065,7 +1066,7 @@ public function sessionUrlVar($html)
10651066
function ($match) {
10661067
if ($this->useSessionIdForUrl($match[2] == 'S' ? true : false)) {
10671068
return $match[1] . $this->_sidResolver->getSessionIdQueryParam($this->_session) . '='
1068-
. $this->_session->getSessionId() . (isset($match[3]) ? $match[3] : '');
1069+
. $this->_session->getSessionId() . (isset($match[3]) ? $match[3] : '');
10691070
} else {
10701071
if ($match[1] == '?') {
10711072
return isset($match[3]) ? '?' : '';
@@ -1087,9 +1088,12 @@ function ($match) {
10871088
public function useSessionIdForUrl($secure = false)
10881089
{
10891090
$key = 'use_session_id_for_url_' . (int)$secure;
1090-
if (is_null($this->getData($key))) {
1091+
if ($this->getData($key) === null) {
10911092
$httpHost = $this->_request->getHttpHost();
1092-
$urlHost = parse_url($this->_getScope()->getBaseUrl(UrlInterface::URL_TYPE_LINK, $secure), PHP_URL_HOST);
1093+
$urlHost = parse_url(
1094+
$this->_getScope()->getBaseUrl(UrlInterface::URL_TYPE_LINK, $secure),
1095+
PHP_URL_HOST
1096+
);
10931097

10941098
if ($httpHost != $urlHost) {
10951099
$this->setData($key, true);
@@ -1192,7 +1196,7 @@ private function getEscaper()
11921196
{
11931197
if ($this->escaper == null) {
11941198
$this->escaper = \Magento\Framework\App\ObjectManager::getInstance()
1195-
->get(\Magento\Framework\Escaper::class);
1199+
->get(\Magento\Framework\Escaper::class);
11961200
}
11971201
return $this->escaper;
11981202
}

lib/internal/Magento/Framework/UrlFactory.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
// @codingStandardsIgnoreFile
8-
97
namespace Magento\Framework;
108

119
class UrlFactory
@@ -24,8 +22,10 @@ class UrlFactory
2422
* @param ObjectManagerInterface $objectManager
2523
* @param string $instanceName
2624
*/
27-
public function __construct(ObjectManagerInterface $objectManager, $instanceName = UrlInterface::class)
28-
{
25+
public function __construct(
26+
ObjectManagerInterface $objectManager,
27+
$instanceName = UrlInterface::class
28+
) {
2929
$this->_objectManager = $objectManager;
3030
$this->_instanceName = $instanceName;
3131
}

0 commit comments

Comments
 (0)