diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Grid.php b/app/code/core/Mage/Adminhtml/Block/Report/Grid.php
index d7f8eea89b2..45ad6efa19a 100644
--- a/app/code/core/Mage/Adminhtml/Block/Report/Grid.php
+++ b/app/code/core/Mage/Adminhtml/Block/Report/Grid.php
@@ -412,7 +412,7 @@ public function addGrandTotals($total)
* recalc totals if we have average
*/
foreach ($this->getColumns() as $key => $_column) {
- if (strpos($_column->getTotal(), '/') !== false) {
+ if (str_contains($_column->getTotal(), '/')) {
list($t1, $t2) = explode('/', $_column->getTotal());
if ($this->getGrandTotals()->getData($t2) != 0) {
$this->getGrandTotals()->setData(
diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Form/Account.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Form/Account.php
index 4c1185937b3..afe3f9914cd 100644
--- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Form/Account.php
+++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Form/Account.php
@@ -125,7 +125,7 @@ public function getFormValues()
{
$data = $this->getCustomer()->getData();
foreach ($this->getQuote()->getData() as $key => $value) {
- if (strpos($key, 'customer_') === 0) {
+ if (str_starts_with($key, 'customer_')) {
$data[substr($key, 9)] = $value;
}
}
diff --git a/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Edit.php b/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Edit.php
index 3fbed459334..fb0b747def3 100644
--- a/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Edit.php
+++ b/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Edit.php
@@ -195,7 +195,7 @@ public function getButtonsHtml($area = null)
if ($this->_buttonsHtml === null) {
$this->_buttonsHtml = parent::getButtonsHtml();
foreach ($this->_children as $alias => $child) {
- if (strpos($alias, '_button') !== false) {
+ if (str_contains($alias, '_button')) {
$this->unsetChild($alias);
}
}
diff --git a/app/code/core/Mage/Adminhtml/Helper/Js.php b/app/code/core/Mage/Adminhtml/Helper/Js.php
index bee3773a843..e48803d9955 100644
--- a/app/code/core/Mage/Adminhtml/Helper/Js.php
+++ b/app/code/core/Mage/Adminhtml/Helper/Js.php
@@ -43,7 +43,7 @@ class Mage_Adminhtml_Helper_Js extends Mage_Core_Helper_Js
*/
public function decodeGridSerializedInput($encoded)
{
- $isSimplified = (strpos($encoded, '=') === false);
+ $isSimplified = !str_contains($encoded, '=');
$result = [];
parse_str($encoded, $decoded);
foreach ($decoded as $key => $value) {
diff --git a/app/code/core/Mage/Adminhtml/Model/Sales/Order/Create.php b/app/code/core/Mage/Adminhtml/Model/Sales/Order/Create.php
index 8a665aad9f1..19b4ff2f398 100644
--- a/app/code/core/Mage/Adminhtml/Model/Sales/Order/Create.php
+++ b/app/code/core/Mage/Adminhtml/Model/Sales/Order/Create.php
@@ -903,7 +903,7 @@ protected function _parseOptions(Mage_Sales_Model_Quote_Item $item, $additionalO
foreach (explode("\n", $additionalOptions) as $_additionalOption) {
if (strlen(trim($_additionalOption))) {
try {
- if (strpos($_additionalOption, ':') === false) {
+ if (!str_contains($_additionalOption, ':')) {
Mage::throwException(
Mage::helper('adminhtml')->__('There is an error in one of the option rows.')
);
diff --git a/app/code/core/Mage/Adminhtml/controllers/Cms/Wysiwyg/ImagesController.php b/app/code/core/Mage/Adminhtml/controllers/Cms/Wysiwyg/ImagesController.php
index 7b0de5a7f17..6c0a7539878 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Cms/Wysiwyg/ImagesController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Cms/Wysiwyg/ImagesController.php
@@ -121,8 +121,8 @@ public function deleteFilesAction()
foreach ($files as $file) {
$file = $helper->idDecode($file);
$_filePath = realpath($path . DS . $file);
- if (strpos($_filePath, realpath($path)) === 0 &&
- strpos($_filePath, realpath($helper->getStorageRoot())) === 0
+ if (str_starts_with($_filePath, realpath($path)) &&
+ str_starts_with($_filePath, realpath($helper->getStorageRoot()))
) {
$this->getStorage()->deleteFile($path . DS . $file);
}
diff --git a/app/code/core/Mage/Adminhtml/controllers/Report/StatisticsController.php b/app/code/core/Mage/Adminhtml/controllers/Report/StatisticsController.php
index c0f2c4b9a16..2868dd1fc3d 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Report/StatisticsController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Report/StatisticsController.php
@@ -87,7 +87,7 @@ protected function _getCollectionNames()
throw new Exception(Mage::helper('adminhtml')->__('No report code specified.'));
}
- if (!is_array($codes) && strpos($codes, ',') === false) {
+ if (!is_array($codes) && !str_contains($codes, ',')) {
$codes = [$codes];
} elseif (!is_array($codes)) {
$codes = explode(',', $codes);
diff --git a/app/code/core/Mage/Adminhtml/controllers/System/Convert/GuiController.php b/app/code/core/Mage/Adminhtml/controllers/System/Convert/GuiController.php
index 18b9056d648..783a913fe29 100644
--- a/app/code/core/Mage/Adminhtml/controllers/System/Convert/GuiController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/System/Convert/GuiController.php
@@ -118,7 +118,7 @@ public function uploadPostAction()
public function downloadAction()
{
$filename = $this->getRequest()->getParam('filename');
- if (!$filename || strpos($filename, '..') !== false || $filename[0] === '.') {
+ if (!$filename || str_contains($filename, '..') || $filename[0] === '.') {
return;
}
$this->_initProfile();
diff --git a/app/code/core/Mage/Api/Model/Server/V2/Handler.php b/app/code/core/Mage/Api/Model/Server/V2/Handler.php
index 28ef615e8aa..ff6b769c275 100644
--- a/app/code/core/Mage/Api/Model/Server/V2/Handler.php
+++ b/app/code/core/Mage/Api/Model/Server/V2/Handler.php
@@ -38,7 +38,7 @@ public function __call($function, $args)
$nodes = Mage::getSingleton('api/config')->getNode('v2/resources_function_prefix')->children();
foreach ($nodes as $resource => $prefix) {
$prefix = $prefix->asArray();
- if (strpos($function, $prefix) !== false) {
+ if (str_contains($function, $prefix)) {
$method = substr($function, strlen($prefix));
$apiKey = $resource . '.' . strtolower($method[0]) . substr($method, 1);
}
diff --git a/app/code/core/Mage/Api/Model/Server/Wsi/Handler.php b/app/code/core/Mage/Api/Model/Server/Wsi/Handler.php
index ef64e02b048..4ec44b03f63 100644
--- a/app/code/core/Mage/Api/Model/Server/Wsi/Handler.php
+++ b/app/code/core/Mage/Api/Model/Server/Wsi/Handler.php
@@ -52,7 +52,7 @@ public function __call($function, $args)
$nodes = Mage::getSingleton('api/config')->getNode('v2/resources_function_prefix')->children();
foreach ($nodes as $resource => $prefix) {
$prefix = $prefix->asArray();
- if (strpos($function, $prefix) !== false) {
+ if (str_contains($function, $prefix)) {
$method = substr($function, strlen($prefix));
$apiKey = $resource . '.' . strtolower($method[0]) . substr($method, 1);
}
diff --git a/app/code/core/Mage/Api2/Model/Acl/Global/Rule/Tree.php b/app/code/core/Mage/Api2/Model/Acl/Global/Rule/Tree.php
index 29cdb2bda96..3f9b8b5e670 100644
--- a/app/code/core/Mage/Api2/Model/Acl/Global/Rule/Tree.php
+++ b/app/code/core/Mage/Api2/Model/Acl/Global/Rule/Tree.php
@@ -183,10 +183,10 @@ public function getPostResources()
$prefixPrivilege = self::NAME_PRIVILEGE . self::ID_SEPARATOR;
$nameResource = null;
foreach ($checkedResources as $i => $item) {
- if (strpos($item, $prefixResource) === 0) {
+ if (str_starts_with($item, $prefixResource)) {
$nameResource = substr($item, mb_strlen($prefixResource, 'UTF-8'));
$resources[$nameResource] = [];
- } elseif (strpos($item, $prefixPrivilege) === 0) {
+ } elseif (str_starts_with($item, $prefixPrivilege)) {
$name = substr($item, mb_strlen($prefixPrivilege, 'UTF-8'));
$namePrivilege = str_replace($nameResource . self::ID_SEPARATOR, '', $name);
$resources[$nameResource][$namePrivilege] = $allow;
@@ -201,14 +201,14 @@ public function getPostResources()
$prefixAttribute = self::NAME_ATTRIBUTE . self::ID_SEPARATOR;
$nameResource = null;
foreach ($checkedResources as $i => $item) {
- if (strpos($item, $prefixResource) === 0) {
+ if (str_starts_with($item, $prefixResource)) {
$nameResource = substr($item, mb_strlen($prefixResource, 'UTF-8'));
$resources[$nameResource] = [];
- } elseif (strpos($item, $prefixOperation) === 0) {
+ } elseif (str_starts_with($item, $prefixOperation)) {
$name = substr($item, mb_strlen($prefixOperation, 'UTF-8'));
$operationName = str_replace($nameResource . self::ID_SEPARATOR, '', $name);
$resources[$nameResource][$operationName] = [];
- } elseif (strpos($item, $prefixAttribute) === 0) {
+ } elseif (str_starts_with($item, $prefixAttribute)) {
$name = substr($item, mb_strlen($prefixOperation, 'UTF-8'));
$attributeName = str_replace(
$nameResource . self::ID_SEPARATOR . $operationName . self::ID_SEPARATOR,
diff --git a/app/code/core/Mage/Catalog/Model/Category/Api.php b/app/code/core/Mage/Catalog/Model/Category/Api.php
index 1de3778f97c..a56c4885759 100644
--- a/app/code/core/Mage/Catalog/Model/Category/Api.php
+++ b/app/code/core/Mage/Catalog/Model/Category/Api.php
@@ -354,7 +354,7 @@ public function move($categoryId, $parentId, $afterId = null)
$afterId = array_pop(explode(',', $parentChildren));
}
- if (strpos($parent_category->getPath(), $category->getPath()) === 0) {
+ if (str_starts_with($parent_category->getPath(), $category->getPath())) {
$this->_fault('not_moved', "Operation do not allow to move a parent category to any of children category");
}
diff --git a/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Media.php b/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Media.php
index 531b5711b22..8ee2ab0b3ab 100644
--- a/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Media.php
+++ b/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Media.php
@@ -273,7 +273,7 @@ public function addImage(
$move = false,
$exclude = true
) {
- if (strpos($file, chr(0)) !== false
+ if (str_contains($file, chr(0))
|| preg_match('#(^|[\\\\/])\.\.($|[\\\\/])#', $file)
) {
throw new Exception('Detected malicious path or filename input.');
diff --git a/app/code/core/Mage/Catalog/Model/Resource/Layer/Filter/Price.php b/app/code/core/Mage/Catalog/Model/Resource/Layer/Filter/Price.php
index 6390996e95a..5096858917f 100644
--- a/app/code/core/Mage/Catalog/Model/Resource/Layer/Filter/Price.php
+++ b/app/code/core/Mage/Catalog/Model/Resource/Layer/Filter/Price.php
@@ -112,7 +112,7 @@ protected function _getSelect($filter)
$wherePart = $select->getPart(Zend_Db_Select::WHERE);
$excludedWherePart = Mage_Catalog_Model_Resource_Product_Collection::MAIN_TABLE_ALIAS . '.status';
foreach ($wherePart as $key => $wherePartItem) {
- if (strpos($wherePartItem, $excludedWherePart) !== false) {
+ if (str_contains($wherePartItem, $excludedWherePart)) {
$wherePart[$key] = new Zend_Db_Expr('1=1');
continue;
}
@@ -121,7 +121,7 @@ protected function _getSelect($filter)
$select->setPart(Zend_Db_Select::WHERE, $wherePart);
$excludeJoinPart = Mage_Catalog_Model_Resource_Product_Collection::MAIN_TABLE_ALIAS . '.entity_id';
foreach ($priceIndexJoinConditions as $condition) {
- if (strpos($condition, $excludeJoinPart) !== false) {
+ if (str_contains($condition, $excludeJoinPart)) {
continue;
}
$select->where($this->_replaceTableAlias($condition));
diff --git a/app/code/core/Mage/Catalog/Model/Template/Filter.php b/app/code/core/Mage/Catalog/Model/Template/Filter.php
index e458eaf655f..d6f896dda05 100644
--- a/app/code/core/Mage/Catalog/Model/Template/Filter.php
+++ b/app/code/core/Mage/Catalog/Model/Template/Filter.php
@@ -104,7 +104,7 @@ public function storeDirective($construction)
$params['_query'] = [];
}
foreach ($params as $k => $v) {
- if (strpos($k, '_query_') === 0) {
+ if (str_starts_with($k, '_query_')) {
$params['_query'][substr($k, 7)] = $v;
unset($params[$k]);
}
diff --git a/app/code/core/Mage/Catalog/Model/Url.php b/app/code/core/Mage/Catalog/Model/Url.php
index fc2f1615f05..6779d540eb5 100644
--- a/app/code/core/Mage/Catalog/Model/Url.php
+++ b/app/code/core/Mage/Catalog/Model/Url.php
@@ -608,7 +608,7 @@ public function getUnusedPath($storeId, $requestPath, $idPath)
*/
public function getUnusedPathByUrlKey($storeId, $requestPath, $idPath, $urlKey)
{
- if (strpos($idPath, 'product') !== false) {
+ if (str_contains($idPath, 'product')) {
$suffix = $this->getProductUrlSuffix($storeId);
} else {
$suffix = $this->getCategoryUrlSuffix($storeId);
@@ -805,7 +805,7 @@ public function getProductRequestPath($product, $category)
* Check if existing request past can be used
*/
if ($product->getUrlKey() == '' && !empty($requestPath)
- && strpos($existingRequestPath, $requestPath) === 0
+ && str_starts_with($existingRequestPath, $requestPath)
) {
$existingRequestPath = preg_replace(
'/^' . preg_quote($requestPath, '/') . '/',
diff --git a/app/code/core/Mage/Cms/Model/Wysiwyg/Images/Storage.php b/app/code/core/Mage/Cms/Model/Wysiwyg/Images/Storage.php
index e2af8af723c..8340c4c2483 100644
--- a/app/code/core/Mage/Cms/Model/Wysiwyg/Images/Storage.php
+++ b/app/code/core/Mage/Cms/Model/Wysiwyg/Images/Storage.php
@@ -226,7 +226,7 @@ public function deleteDirectory($path)
$io->getFilteredPath($path)
));
}
- if (strpos($pathCmp, chr(0)) !== false
+ if (str_contains($pathCmp, chr(0))
|| preg_match('#(^|[\\\\/])\.\.($|[\\\\/])#', $pathCmp)
) {
throw new Exception('Detected malicious path or filename input.');
@@ -239,7 +239,7 @@ public function deleteDirectory($path)
Mage::throwException(Mage::helper('cms')->__('Cannot delete directory %s.', $io->getFilteredPath($path)));
}
- if (strpos($pathCmp, $rootCmp) === 0) {
+ if (str_starts_with($pathCmp, $rootCmp)) {
$io->rmdir($this->getThumbnailRoot() . DS . ltrim(substr($pathCmp, strlen($rootCmp)), '\\/'), true);
}
}
@@ -319,7 +319,7 @@ public function getThumbnailPath($filePath, $checkFile = false)
{
$mediaRootDir = $this->getHelper()->getStorageRoot();
- if (strpos($filePath, $mediaRootDir) === 0) {
+ if (str_starts_with($filePath, $mediaRootDir)) {
$thumbPath = $this->getThumbnailRoot() . DS . substr($filePath, strlen($mediaRootDir));
if (!$checkFile || is_readable($thumbPath)) {
@@ -340,7 +340,7 @@ public function getThumbnailPath($filePath, $checkFile = false)
public function getThumbnailUrl($filePath, $checkFile = false)
{
$mediaRootDir = Mage::getConfig()->getOptions()->getMediaDir() . DS;
- if (strpos($filePath, $mediaRootDir) === 0) {
+ if (str_starts_with($filePath, $mediaRootDir)) {
$thumbSuffix = self::THUMBS_DIRECTORY_NAME . DS . substr($filePath, strlen($mediaRootDir));
if (!$checkFile || is_readable($this->getHelper()->getStorageRoot() . $thumbSuffix)) {
$randomIndex = '?rand=' . time();
@@ -420,7 +420,7 @@ public function getThumbsPath($filePath = false)
$mediaRootDir = Mage::getConfig()->getOptions()->getMediaDir();
$thumbnailDir = $this->getThumbnailRoot();
- if ($filePath && strpos($filePath, $mediaRootDir) === 0) {
+ if ($filePath && str_starts_with($filePath, $mediaRootDir)) {
$thumbnailDir .= DS . dirname(substr($filePath, strlen($mediaRootDir)));
}
diff --git a/app/code/core/Mage/Core/Block/Template.php b/app/code/core/Mage/Core/Block/Template.php
index 26eb532787d..2a6457ee2e2 100644
--- a/app/code/core/Mage/Core/Block/Template.php
+++ b/app/code/core/Mage/Core/Block/Template.php
@@ -156,7 +156,7 @@ public function assign($key, $value = null)
*/
public function setScriptPath($dir)
{
- if (strpos($dir, '..') === false && ($dir === Mage::getBaseDir('design') || strpos(realpath($dir), realpath(Mage::getBaseDir('design'))) === 0)) {
+ if (!str_contains($dir, '..') && ($dir === Mage::getBaseDir('design') || str_starts_with(realpath($dir), realpath(Mage::getBaseDir('design'))))) {
$this->_viewDir = $dir;
} else {
Mage::log('Not valid script path:' . $dir, Zend_Log::CRIT, null, true);
@@ -245,7 +245,7 @@ public function fetchView($fileName)
try {
if (strpos($this->_viewDir . DS . $fileName, '..') === false
&&
- ($this->_viewDir == Mage::getBaseDir('design') || strpos(realpath($this->_viewDir), realpath(Mage::getBaseDir('design'))) === 0)
+ ($this->_viewDir == Mage::getBaseDir('design') || str_starts_with(realpath($this->_viewDir), realpath(Mage::getBaseDir('design'))))
) {
include $this->_viewDir . DS . $fileName;
} else {
diff --git a/app/code/core/Mage/Core/Controller/Request/Http.php b/app/code/core/Mage/Core/Controller/Request/Http.php
index be5ed7a6299..2544b451aab 100644
--- a/app/code/core/Mage/Core/Controller/Request/Http.php
+++ b/app/code/core/Mage/Core/Controller/Request/Http.php
@@ -329,7 +329,7 @@ public function getHttpHost($trimPort = true)
$host = $hostParts[0];
}
- if (strpos($host, ',') !== false || strpos($host, ';') !== false) {
+ if (str_contains($host, ',') || str_contains($host, ';')) {
$response = new Zend_Controller_Response_Http();
$response->setHttpResponseCode(400)->sendHeaders();
exit();
diff --git a/app/code/core/Mage/Core/Controller/Varien/Action.php b/app/code/core/Mage/Core/Controller/Varien/Action.php
index 464a75dbc57..efe4e775f06 100644
--- a/app/code/core/Mage/Core/Controller/Varien/Action.php
+++ b/app/code/core/Mage/Core/Controller/Varien/Action.php
@@ -805,12 +805,12 @@ protected function _getRefererUrl()
*/
protected function _isUrlInternal($url)
{
- if (strpos($url, 'http') !== false) {
+ if (str_contains($url, 'http')) {
/**
* Url must start from base secure or base unsecure url
*/
- if ((strpos($url, Mage::app()->getStore()->getBaseUrl()) === 0)
- || (strpos($url, Mage::app()->getStore()->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, true)) === 0)
+ if (str_starts_with($url, Mage::app()->getStore()->getBaseUrl())
+ || str_starts_with($url, Mage::app()->getStore()->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, true))
) {
return true;
}
diff --git a/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php b/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php
index e880215c7ec..d6db6172f4b 100644
--- a/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php
+++ b/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php
@@ -431,7 +431,7 @@ public function getControllerFileName($realModule, $controller)
*/
public function validateControllerFileName($fileName)
{
- if ($fileName && is_readable($fileName) && strpos($fileName, '//') === false) {
+ if ($fileName && is_readable($fileName) && !str_contains($fileName, '//')) {
return true;
}
return false;
diff --git a/app/code/core/Mage/Core/Helper/Http.php b/app/code/core/Mage/Core/Helper/Http.php
index de0913c1f3b..ec27336359b 100644
--- a/app/code/core/Mage/Core/Helper/Http.php
+++ b/app/code/core/Mage/Core/Helper/Http.php
@@ -134,7 +134,7 @@ public function getRemoteAddr($ipToLong = false)
return false;
}
- if (strpos($this->_remoteAddr, ',') !== false) {
+ if (str_contains($this->_remoteAddr, ',')) {
$ipList = explode(',', $this->_remoteAddr);
$this->_remoteAddr = trim(reset($ipList));
}
diff --git a/app/code/core/Mage/Core/Helper/String.php b/app/code/core/Mage/Core/Helper/String.php
index cfa14ff9d9b..80804850d94 100644
--- a/app/code/core/Mage/Core/Helper/String.php
+++ b/app/code/core/Mage/Core/Helper/String.php
@@ -337,7 +337,7 @@ public function parseQueryStr($str)
*/
protected function _validateQueryStr($str)
{
- if (!$str || (strpos($str, '=') === false)) {
+ if (!$str || !str_contains($str, '=')) {
return false;
}
return true;
diff --git a/app/code/core/Mage/Core/Helper/Url.php b/app/code/core/Mage/Core/Helper/Url.php
index 0f75022035d..a62a7c51e87 100644
--- a/app/code/core/Mage/Core/Helper/Url.php
+++ b/app/code/core/Mage/Core/Helper/Url.php
@@ -199,8 +199,8 @@ public function decodePunycode($url)
*/
private function _isPunycode($host)
{
- if (strpos($host, 'xn--') === 0 || strpos($host, '.xn--') !== false
- || strpos($host, 'XN--') === 0 || strpos($host, '.XN--') !== false
+ if (str_starts_with($host, 'xn--') || str_contains($host, '.xn--')
+ || str_starts_with($host, 'XN--') || str_contains($host, '.XN--')
) {
return true;
}
diff --git a/app/code/core/Mage/Core/Helper/Url/Rewrite.php b/app/code/core/Mage/Core/Helper/Url/Rewrite.php
index 152d0e62ffe..4c73d3b1474 100644
--- a/app/code/core/Mage/Core/Helper/Url/Rewrite.php
+++ b/app/code/core/Mage/Core/Helper/Url/Rewrite.php
@@ -51,7 +51,7 @@ protected function _validateRequestPath($requestPath)
$this->__('Request path length exceeds allowed %s symbols.', self::TARGET_PATH_ALLOWED_LENGTH)
);
}
- if (strpos($requestPath, '//') !== false) {
+ if (str_contains($requestPath, '//')) {
throw new Mage_Core_Exception(
$this->__('Two and more slashes together are not permitted in request path'),
self::VERR_MANYSLASHES
diff --git a/app/code/core/Mage/Core/Model/App.php b/app/code/core/Mage/Core/Model/App.php
index e6750cf4ace..9b0b96c9c3d 100644
--- a/app/code/core/Mage/Core/Model/App.php
+++ b/app/code/core/Mage/Core/Model/App.php
@@ -1310,7 +1310,7 @@ public function isCurrentlySecure()
$offloaderHeader = strtoupper(trim((string) Mage::getConfig()->getNode(Mage_Core_Model_Store::XML_PATH_OFFLOADER_HEADER, 'default')));
if ($offloaderHeader) {
$offloaderHeader = preg_replace('/[^A-Z]+/', '_', $offloaderHeader);
- $offloaderHeader = strpos($offloaderHeader, 'HTTP_') === 0 ? $offloaderHeader : 'HTTP_' . $offloaderHeader;
+ $offloaderHeader = str_starts_with($offloaderHeader, 'HTTP_') ? $offloaderHeader : 'HTTP_' . $offloaderHeader;
if (!empty($_SERVER[$offloaderHeader]) && $_SERVER[$offloaderHeader] !== 'http') {
return true;
}
diff --git a/app/code/core/Mage/Core/Model/Config.php b/app/code/core/Mage/Core/Model/Config.php
index 47d23deaf6b..b9e1228037a 100644
--- a/app/code/core/Mage/Core/Model/Config.php
+++ b/app/code/core/Mage/Core/Model/Config.php
@@ -1362,7 +1362,7 @@ public function getGroupedClassName($groupType, $classId, $groupRootNode = null)
*/
public function getBlockClassName($blockType)
{
- if (strpos($blockType, '/') === false) {
+ if (!str_contains($blockType, '/')) {
return $blockType;
}
return $this->getGroupedClassName('block', $blockType);
@@ -1376,7 +1376,7 @@ public function getBlockClassName($blockType)
*/
public function getHelperClassName($helperName)
{
- if (strpos($helperName, '/') === false) {
+ if (!str_contains($helperName, '/')) {
$helperName .= '/data';
}
return $this->getGroupedClassName('helper', $helperName);
@@ -1413,7 +1413,7 @@ public function getResourceHelper($moduleName)
public function getModelClassName($modelClass)
{
$modelClass = trim($modelClass);
- if (strpos($modelClass, '/') === false) {
+ if (!str_contains($modelClass, '/')) {
return $modelClass;
}
return $this->getGroupedClassName('model', $modelClass);
@@ -1583,7 +1583,7 @@ public function shouldUrlBeSecure($url)
}
// If unsecure base url is https, then all urls should be secure
- if (strpos(Mage::getStoreConfig(Mage_Core_Model_Store::XML_PATH_UNSECURE_BASE_URL), 'https://') === 0) {
+ if (str_starts_with(Mage::getStoreConfig(Mage_Core_Model_Store::XML_PATH_UNSECURE_BASE_URL), 'https://')) {
return true;
}
@@ -1591,7 +1591,7 @@ public function shouldUrlBeSecure($url)
$this->_secureUrlCache[$url] = false;
$secureUrls = $this->getNode('frontend/secure_url');
foreach ($secureUrls->children() as $match) {
- if (strpos($url, (string)$match) === 0) {
+ if (str_starts_with($url, (string)$match)) {
$this->_secureUrlCache[$url] = true;
break;
}
diff --git a/app/code/core/Mage/Core/Model/Convert.php b/app/code/core/Mage/Core/Model/Convert.php
index 9d2901d8241..5b5977f21c7 100644
--- a/app/code/core/Mage/Core/Model/Convert.php
+++ b/app/code/core/Mage/Core/Model/Convert.php
@@ -40,7 +40,7 @@ public function __construct()
*/
public function getClassNameByType($type)
{
- if (strpos($type, '/') !== false) {
+ if (str_contains($type, '/')) {
return Mage::getConfig()->getModelClassName($type);
}
return parent::getClassNameByType($type);
diff --git a/app/code/core/Mage/Core/Model/Design/Package.php b/app/code/core/Mage/Core/Model/Design/Package.php
index d276084c3e0..721c5bb4a30 100644
--- a/app/code/core/Mage/Core/Model/Design/Package.php
+++ b/app/code/core/Mage/Core/Model/Design/Package.php
@@ -456,7 +456,7 @@ public function getFilename($file, array $params)
Varien_Profiler::start(__METHOD__);
// Prevent reading files outside of the proper directory while still allowing symlinked files
- if (strpos($file, '..') !== false) {
+ if (str_contains($file, '..')) {
Mage::log(sprintf('Invalid path requested: %s (params: %s)', $file, json_encode($params)), Zend_Log::ERR);
throw new Exception('Invalid path requested.');
}
@@ -521,7 +521,7 @@ public function getSkinUrl($file = null, array $params = [])
Varien_Profiler::start(__METHOD__);
// Prevent reading files outside of the proper directory while still allowing symlinked files
- if (strpos((string)$file, '..') !== false) {
+ if (str_contains((string)$file, '..')) {
Mage::log(sprintf('Invalid path requested: %s (params: %s)', $file, json_encode($params)), Zend_Log::ERR);
throw new Exception('Invalid path requested.');
}
diff --git a/app/code/core/Mage/Core/Model/Email/Template/Filter.php b/app/code/core/Mage/Core/Model/Email/Template/Filter.php
index cfdf2ede252..7d4897b6f65 100644
--- a/app/code/core/Mage/Core/Model/Email/Template/Filter.php
+++ b/app/code/core/Mage/Core/Model/Email/Template/Filter.php
@@ -302,7 +302,7 @@ public function storeDirective($construction)
$params['_query'] = [];
}
foreach ($params as $k => $v) {
- if (strpos($k, '_query_') === 0) {
+ if (str_starts_with($k, '_query_')) {
$params['_query'][substr($k, 7)] = $v;
unset($params[$k]);
}
diff --git a/app/code/core/Mage/Core/Model/Layout.php b/app/code/core/Mage/Core/Model/Layout.php
index 833958481d5..f1dd83f0629 100644
--- a/app/code/core/Mage/Core/Model/Layout.php
+++ b/app/code/core/Mage/Core/Model/Layout.php
@@ -500,7 +500,7 @@ public function addBlock($block, $blockName)
protected function _getBlockInstance($block, array $attributes = [])
{
if (is_string($block)) {
- if (strpos($block, '/') !== false) {
+ if (str_contains($block, '/')) {
if (!$block = Mage::getConfig()->getBlockClassName($block)) {
Mage::throwException(Mage::helper('core')->__('Invalid block type: %s', $block));
}
diff --git a/app/code/core/Mage/Core/Model/Resource.php b/app/code/core/Mage/Core/Model/Resource.php
index eb69aeac8ae..6e843ce8de5 100644
--- a/app/code/core/Mage/Core/Model/Resource.php
+++ b/app/code/core/Mage/Core/Model/Resource.php
@@ -194,7 +194,7 @@ protected function _newConnection($type, $config)
*/
protected function _getDefaultConnection($requiredConnectionName)
{
- if (strpos($requiredConnectionName, 'read') !== false) {
+ if (str_contains($requiredConnectionName, 'read')) {
return $this->getConnection(self::DEFAULT_READ_RESOURCE);
}
return $this->getConnection(self::DEFAULT_WRITE_RESOURCE);
diff --git a/app/code/core/Mage/Core/Model/Resource/Db/Collection/Abstract.php b/app/code/core/Mage/Core/Model/Resource/Db/Collection/Abstract.php
index 5da86165218..64a62148df8 100644
--- a/app/code/core/Mage/Core/Model/Resource/Db/Collection/Abstract.php
+++ b/app/code/core/Mage/Core/Model/Resource/Db/Collection/Abstract.php
@@ -152,7 +152,7 @@ public function getMainTable()
*/
public function setMainTable($table)
{
- if (strpos($table, '/') !== false) {
+ if (str_contains($table, '/')) {
$table = $this->getTable($table);
}
diff --git a/app/code/core/Mage/Core/Model/Resource/Helper/Mysql4.php b/app/code/core/Mage/Core/Model/Resource/Helper/Mysql4.php
index b99c8c01fd6..6b0316b6926 100644
--- a/app/code/core/Mage/Core/Model/Resource/Helper/Mysql4.php
+++ b/app/code/core/Mage/Core/Model/Resource/Helper/Mysql4.php
@@ -129,7 +129,7 @@ protected function _prepareOrder(Varien_Db_Select $select, $autoReset = false)
protected function _truncateAliasName($field, $reverse = false)
{
$string = $field;
- if (!is_numeric($field) && (strpos($field, '.') !== false)) {
+ if (!is_numeric($field) && (str_contains($field, '.'))) {
$size = strpos($field, '.');
if ($reverse) {
$string = substr($field, 0, $size);
@@ -191,7 +191,7 @@ protected function _prepareHaving(Varien_Db_Select $select, $autoReset = false)
/**
* Looking for column expression in the having clause
*/
- if (strpos($having, $correlationName) !== false) {
+ if (str_contains($having, $correlationName)) {
if (is_string($column)) {
/**
* Replace column expression to column alias in having clause
diff --git a/app/code/core/Mage/Core/Model/Resource/Setup.php b/app/code/core/Mage/Core/Model/Resource/Setup.php
index 6f5d06aa149..e1c50b0533e 100644
--- a/app/code/core/Mage/Core/Model/Resource/Setup.php
+++ b/app/code/core/Mage/Core/Model/Resource/Setup.php
@@ -707,7 +707,7 @@ protected function _getModifySqlFiles($actionType, $fromVersion, $toVersion, $ar
*/
public function getTableRow($table, $idField, $id, $field = null, $parentField = null, $parentId = 0)
{
- if (strpos($table, '/') !== false) {
+ if (str_contains($table, '/')) {
$table = $this->getTable($table);
}
@@ -742,7 +742,7 @@ public function getTableRow($table, $idField, $id, $field = null, $parentField =
*/
public function deleteTableRow($table, $idField, $id, $parentField = null, $parentId = 0)
{
- if (strpos($table, '/') !== false) {
+ if (str_contains($table, '/')) {
$table = $this->getTable($table);
}
@@ -775,7 +775,7 @@ public function deleteTableRow($table, $idField, $id, $parentField = null, $pare
*/
public function updateTableRow($table, $idField, $id, $field, $value = null, $parentField = null, $parentId = 0)
{
- if (strpos($table, '/') !== false) {
+ if (str_contains($table, '/')) {
$table = $this->getTable($table);
}
@@ -813,7 +813,7 @@ public function updateTableRow($table, $idField, $id, $field, $value = null, $pa
*/
public function updateTable($table, $conditionExpr, $valueExpr)
{
- if (strpos($table, '/') !== false) {
+ if (str_contains($table, '/')) {
$table = $this->getTable($table);
}
$query = sprintf(
@@ -836,7 +836,7 @@ public function updateTable($table, $conditionExpr, $valueExpr)
*/
public function tableExists($table)
{
- if (strpos($table, '/') !== false) {
+ if (str_contains($table, '/')) {
$table = $this->getTable($table);
}
diff --git a/app/code/core/Mage/Core/Model/Resource/Translate/String.php b/app/code/core/Mage/Core/Model/Resource/Translate/String.php
index c3426f4f142..cd24f87a757 100644
--- a/app/code/core/Mage/Core/Model/Resource/Translate/String.php
+++ b/app/code/core/Mage/Core/Model/Resource/Translate/String.php
@@ -209,7 +209,7 @@ public function saveTranslate($string, $translate, $locale = null, $storeId = nu
if ($row = $write->fetchRow($select, $bind)) {
$original = $string;
- if (strpos($original, '::') !== false) {
+ if (str_contains($original, '::')) {
list($scope, $original) = explode('::', $original);
}
if ($original == $translate) {
diff --git a/app/code/core/Mage/Core/Model/Session/Abstract.php b/app/code/core/Mage/Core/Model/Session/Abstract.php
index bc15d9696d5..4e59592dd64 100644
--- a/app/code/core/Mage/Core/Model/Session/Abstract.php
+++ b/app/code/core/Mage/Core/Model/Session/Abstract.php
@@ -484,7 +484,7 @@ public function isValidForPath($path)
$urlPath = trim($path, '/') . '/';
- return strpos($urlPath, $cookiePath) === 0;
+ return str_starts_with($urlPath, $cookiePath);
}
/**
diff --git a/app/code/core/Mage/Core/Model/Url.php b/app/code/core/Mage/Core/Model/Url.php
index e2e46f03607..942c6172995 100644
--- a/app/code/core/Mage/Core/Model/Url.php
+++ b/app/code/core/Mage/Core/Model/Url.php
@@ -1138,7 +1138,7 @@ public function getDirectUrl($url, $params = [])
*/
public function sessionUrlVar($html)
{
- if (strpos($html, '__SID') === false) {
+ if (!str_contains($html, '__SID')) {
return $html;
} else {
return preg_replace_callback(
diff --git a/app/code/core/Mage/Core/functions.php b/app/code/core/Mage/Core/functions.php
index 7a75e8275a6..b34344301c1 100644
--- a/app/code/core/Mage/Core/functions.php
+++ b/app/code/core/Mage/Core/functions.php
@@ -107,7 +107,7 @@ function mageFindClassFile($class)
*/
function mageCoreErrorHandler($errno, $errstr, $errfile, $errline)
{
- if (strpos($errstr, 'DateTimeZone::__construct') !== false) {
+ if (str_contains($errstr, 'DateTimeZone::__construct')) {
// there's no way to distinguish between caught system exceptions and warnings
return false;
}
diff --git a/app/code/core/Mage/Cron/Model/Schedule.php b/app/code/core/Mage/Cron/Model/Schedule.php
index 4932fb92762..f869c806cb3 100644
--- a/app/code/core/Mage/Cron/Model/Schedule.php
+++ b/app/code/core/Mage/Cron/Model/Schedule.php
@@ -120,7 +120,7 @@ public function matchCronExpression($expr, $num)
}
// handle multiple options
- if (strpos($expr, ',') !== false) {
+ if (str_contains($expr, ',')) {
foreach (explode(',', $expr) as $e) {
if ($this->matchCronExpression($e, $num)) {
return true;
@@ -130,7 +130,7 @@ public function matchCronExpression($expr, $num)
}
// handle modulus
- if (strpos($expr, '/') !== false) {
+ if (str_contains($expr, '/')) {
$e = explode('/', $expr);
if (count($e) !== 2) {
throw Mage::exception('Mage_Cron', "Invalid cron expression, expecting 'match/modulus': " . $expr);
@@ -148,7 +148,7 @@ public function matchCronExpression($expr, $num)
if ($expr === '*') {
$from = 0;
$to = 60;
- } elseif (strpos($expr, '-') !== false) { // handle range
+ } elseif (str_contains($expr, '-')) { // handle range
$e = explode('-', $expr);
if (count($e) !== 2) {
throw Mage::exception('Mage_Cron', "Invalid cron expression, expecting 'from-to' structure: " . $expr);
diff --git a/app/code/core/Mage/Dataflow/Model/Convert/Parser/Csv.php b/app/code/core/Mage/Dataflow/Model/Convert/Parser/Csv.php
index 3e22843fb74..a8d11090464 100644
--- a/app/code/core/Mage/Dataflow/Model/Convert/Parser/Csv.php
+++ b/app/code/core/Mage/Dataflow/Model/Convert/Parser/Csv.php
@@ -237,9 +237,9 @@ public function getCsvString($fields = [])
$escapedValue = Mage::helper("core")->getEscapedCSVData([$value]);
$value = $escapedValue[0];
- if (strpos($value, $delimiter) !== false ||
+ if (str_contains($value, $delimiter) ||
empty($enclosure) ||
- strpos($value, $enclosure) !== false ||
+ str_contains($value, $enclosure) ||
strpos($value, "\n") !== false ||
strpos($value, "\r") !== false ||
strpos($value, "\t") !== false ||
diff --git a/app/code/core/Mage/Eav/Model/Attribute/Data/Abstract.php b/app/code/core/Mage/Eav/Model/Attribute/Data/Abstract.php
index c360025dd0e..0e29ab491cd 100644
--- a/app/code/core/Mage/Eav/Model/Attribute/Data/Abstract.php
+++ b/app/code/core/Mage/Eav/Model/Attribute/Data/Abstract.php
@@ -478,7 +478,7 @@ protected function _getRequestValue(Zend_Controller_Request_Http $request)
{
$attrCode = $this->getAttribute()->getAttributeCode();
if ($this->_requestScope) {
- if (strpos($this->_requestScope, '/') !== false) {
+ if (str_contains($this->_requestScope, '/')) {
$params = $request->getParams();
$parts = explode('/', $this->_requestScope);
foreach ($parts as $part) {
diff --git a/app/code/core/Mage/Eav/Model/Attribute/Data/File.php b/app/code/core/Mage/Eav/Model/Attribute/Data/File.php
index a2b81837f91..189929bcca3 100644
--- a/app/code/core/Mage/Eav/Model/Attribute/Data/File.php
+++ b/app/code/core/Mage/Eav/Model/Attribute/Data/File.php
@@ -45,7 +45,7 @@ public function extractValue(Zend_Controller_Request_Http $request)
$attrCode = $this->getAttribute()->getAttributeCode();
if ($this->_requestScope) {
$value = [];
- if (strpos($this->_requestScope, '/') !== false) {
+ if (str_contains($this->_requestScope, '/')) {
$scopes = explode('/', $this->_requestScope);
$mainScope = array_shift($scopes);
} else {
diff --git a/app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php b/app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php
index 1f880eb6c06..a0eb7ec0fdd 100644
--- a/app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php
+++ b/app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php
@@ -692,7 +692,7 @@ public function joinField($alias, $table, $field, $bind, $cond = null, $joinType
}
// validate table
- if (strpos($table, '/') !== false) {
+ if (str_contains($table, '/')) {
$table = Mage::getSingleton('core/resource')->getTableName($table);
}
$tableAlias = $this->_getAttributeTableAlias($alias);
@@ -759,7 +759,7 @@ public function joinTable($table, $bind, $fields = null, $cond = null, $joinType
}
// validate table
- if (is_string($tableName) && strpos($tableName, '/') !== false) {
+ if (is_string($tableName) && str_contains($tableName, '/')) {
$tableName = Mage::getSingleton('core/resource')->getTableName($tableName);
}
if (empty($tableAlias)) {
diff --git a/app/code/core/Mage/Eav/Model/Entity/Increment/Alphanum.php b/app/code/core/Mage/Eav/Model/Entity/Increment/Alphanum.php
index 971b3f2984e..eba5bdcc621 100644
--- a/app/code/core/Mage/Eav/Model/Entity/Increment/Alphanum.php
+++ b/app/code/core/Mage/Eav/Model/Entity/Increment/Alphanum.php
@@ -35,7 +35,7 @@ public function getNextId()
{
$lastId = $this->getLastId();
- if (strpos($lastId, $this->getPrefix()) === 0) {
+ if (str_starts_with($lastId, $this->getPrefix())) {
$lastId = substr($lastId, strlen($this->getPrefix()));
}
diff --git a/app/code/core/Mage/Eav/Model/Entity/Increment/Numeric.php b/app/code/core/Mage/Eav/Model/Entity/Increment/Numeric.php
index f8c208635f2..8bc1065ca3e 100644
--- a/app/code/core/Mage/Eav/Model/Entity/Increment/Numeric.php
+++ b/app/code/core/Mage/Eav/Model/Entity/Increment/Numeric.php
@@ -28,7 +28,7 @@ public function getNextId()
if (empty($last)) {
$last = 0;
- } elseif (!empty($prefix = (string)$this->getPrefix()) && strpos($last, $prefix) === 0) {
+ } elseif (!empty($prefix = (string)$this->getPrefix()) && str_starts_with($last, $prefix)) {
$last = (int)substr($last, strlen($prefix));
} else {
$last = (int)$last;
diff --git a/app/code/core/Mage/Index/Model/Resource/Lock/Resource.php b/app/code/core/Mage/Index/Model/Resource/Lock/Resource.php
index 29f0271ffc8..219ccc1dabd 100644
--- a/app/code/core/Mage/Index/Model/Resource/Lock/Resource.php
+++ b/app/code/core/Mage/Index/Model/Resource/Lock/Resource.php
@@ -103,7 +103,7 @@ public function getConnection($name, $extendConfigWith = '')
*/
protected function _getDefaultConnection($requiredConnectionName, $extendConfigWith = '')
{
- if (strpos($requiredConnectionName, 'read') !== false) {
+ if (str_contains($requiredConnectionName, 'read')) {
return $this->getConnection(self::DEFAULT_READ_RESOURCE, $extendConfigWith);
}
return $this->getConnection(self::DEFAULT_WRITE_RESOURCE, $extendConfigWith);
diff --git a/app/code/core/Mage/Media/Model/Image.php b/app/code/core/Mage/Media/Model/Image.php
index 698198b0dd7..2258e0fbd52 100644
--- a/app/code/core/Mage/Media/Model/Image.php
+++ b/app/code/core/Mage/Media/Model/Image.php
@@ -250,7 +250,7 @@ public function getSpecialLink($file, $size, $extension = null, $watermark = nul
$this->addParam('extension', $extension);
if (!$this->hasSpecialImage()) {
- if (strpos($size, 'x') !== false) {
+ if (str_contains($size, 'x')) {
list($width, $height) = explode('x', $size);
} else {
$width = $size;
diff --git a/app/code/core/Mage/Newsletter/Model/Resource/Subscriber/Collection.php b/app/code/core/Mage/Newsletter/Model/Resource/Subscriber/Collection.php
index 1dbf6f7de6e..94d5a24e8ab 100644
--- a/app/code/core/Mage/Newsletter/Model/Resource/Subscriber/Collection.php
+++ b/app/code/core/Mage/Newsletter/Model/Resource/Subscriber/Collection.php
@@ -177,7 +177,7 @@ public function showStoreInfo()
*/
public function _getFieldTableAlias($field)
{
- if (strpos($field, 'customer') === 0) {
+ if (str_starts_with($field, 'customer')) {
return $field . '_table.value';
}
diff --git a/app/code/core/Mage/Oauth/Model/Server.php b/app/code/core/Mage/Oauth/Model/Server.php
index b8cee834648..e629bbb5afb 100644
--- a/app/code/core/Mage/Oauth/Model/Server.php
+++ b/app/code/core/Mage/Oauth/Model/Server.php
@@ -219,7 +219,7 @@ protected function _fetchParams()
}
$contentTypeHeader = $this->_request->getHeader(Zend_Http_Client::CONTENT_TYPE);
- if ($contentTypeHeader && strpos($contentTypeHeader, Zend_Http_Client::ENC_URLENCODED) === 0) {
+ if ($contentTypeHeader && str_starts_with($contentTypeHeader, Zend_Http_Client::ENC_URLENCODED)) {
$protocolParamsNotSet = !$this->_protocolParams;
parse_str($this->_request->getRawBody(), $bodyParams);
diff --git a/app/code/core/Mage/Page/Block/Html/Topmenu/Renderer.php b/app/code/core/Mage/Page/Block/Html/Topmenu/Renderer.php
index d0769e14396..c23b5bc4d24 100644
--- a/app/code/core/Mage/Page/Block/Html/Topmenu/Renderer.php
+++ b/app/code/core/Mage/Page/Block/Html/Topmenu/Renderer.php
@@ -41,7 +41,7 @@ protected function _toHtml()
}
$includeFilePath = realpath(Mage::getBaseDir('design') . DS . $this->getTemplateFile());
- if (strpos($this->getTemplateFile(), '..') === false) {
+ if (!str_contains($this->getTemplateFile(), '..')) {
$this->_templateFile = $includeFilePath;
} else {
throw new Exception('Not valid template file:' . $this->_templateFile);
diff --git a/app/code/core/Mage/ProductAlert/Helper/Data.php b/app/code/core/Mage/ProductAlert/Helper/Data.php
index cd0b6b604de..a82cdde1472 100644
--- a/app/code/core/Mage/ProductAlert/Helper/Data.php
+++ b/app/code/core/Mage/ProductAlert/Helper/Data.php
@@ -93,7 +93,7 @@ public function createBlock($block)
{
$error = Mage::helper('core')->__('Invalid block type: %s', $block);
if (is_string($block)) {
- if (strpos($block, '/') !== false) {
+ if (str_contains($block, '/')) {
if (!$block = Mage::getConfig()->getBlockClassName($block)) {
Mage::throwException($error);
}
diff --git a/app/code/core/Mage/Rule/Model/Condition/Abstract.php b/app/code/core/Mage/Rule/Model/Condition/Abstract.php
index 2cd594eee09..46a6f10d4d8 100644
--- a/app/code/core/Mage/Rule/Model/Condition/Abstract.php
+++ b/app/code/core/Mage/Rule/Model/Condition/Abstract.php
@@ -577,7 +577,7 @@ public function getValueElementType()
*/
public function getValueElementRenderer()
{
- if (strpos($this->getValueElementType(), '/') !== false) {
+ if (str_contains($this->getValueElementType(), '/')) {
return Mage::getBlockSingleton($this->getValueElementType());
}
return Mage::getBlockSingleton('rule/editable');
diff --git a/app/code/core/Mage/Sales/Block/Adminhtml/Report/Filter/Form.php b/app/code/core/Mage/Sales/Block/Adminhtml/Report/Filter/Form.php
index b59f807ecae..2d2f0f702d6 100644
--- a/app/code/core/Mage/Sales/Block/Adminhtml/Report/Filter/Form.php
+++ b/app/code/core/Mage/Sales/Block/Adminhtml/Report/Filter/Form.php
@@ -38,7 +38,7 @@ protected function _prepareForm()
$statuses = Mage::getModel('sales/order_config')->getStatuses();
$values = [];
foreach ($statuses as $code => $label) {
- if (strpos($code, 'pending') === false) {
+ if (!str_contains($code, 'pending')) {
$values[] = [
'label' => Mage::helper('reports')->__($label),
'value' => $code
diff --git a/app/code/core/Mage/Sales/controllers/DownloadController.php b/app/code/core/Mage/Sales/controllers/DownloadController.php
index 89c39a4583c..95a6cdd6312 100644
--- a/app/code/core/Mage/Sales/controllers/DownloadController.php
+++ b/app/code/core/Mage/Sales/controllers/DownloadController.php
@@ -160,7 +160,7 @@ public function downloadCustomOptionAction()
}
$optionId = null;
- if (strpos($option->getCode(), Mage_Catalog_Model_Product_Type_Abstract::OPTION_PREFIX) === 0) {
+ if (str_starts_with($option->getCode(), Mage_Catalog_Model_Product_Type_Abstract::OPTION_PREFIX)) {
$optionId = str_replace(Mage_Catalog_Model_Product_Type_Abstract::OPTION_PREFIX, '', $option->getCode());
if (!is_numeric($optionId)) {
$optionId = null;
diff --git a/app/code/core/Mage/SalesRule/Model/Rule/Condition/Product/Combine.php b/app/code/core/Mage/SalesRule/Model/Rule/Condition/Product/Combine.php
index 5283bef0fdf..4b48c3ba993 100644
--- a/app/code/core/Mage/SalesRule/Model/Rule/Condition/Product/Combine.php
+++ b/app/code/core/Mage/SalesRule/Model/Rule/Condition/Product/Combine.php
@@ -56,7 +56,7 @@ protected function _getHelper()
*/
protected function _getIsQuoteItemAttribute($attributeCode)
{
- return strpos($attributeCode, 'quote_item_') === 0;
+ return str_starts_with($attributeCode, 'quote_item_');
}
/**
diff --git a/app/code/core/Mage/Widget/Block/Adminhtml/Widget/Options.php b/app/code/core/Mage/Widget/Block/Adminhtml/Widget/Options.php
index 57593e17a98..c84bd080220 100644
--- a/app/code/core/Mage/Widget/Block/Adminhtml/Widget/Options.php
+++ b/app/code/core/Mage/Widget/Block/Adminhtml/Widget/Options.php
@@ -168,7 +168,7 @@ protected function _addField($parameter)
// hidden element
if (!$parameter->getVisible()) {
$fieldType = 'hidden';
- } elseif (strpos($fieldType, '/') !== false) { // just an element renderer
+ } elseif (str_contains($fieldType, '/')) { // just an element renderer
$fieldRenderer = $this->getLayout()->createBlock($fieldType);
$fieldType = $this->_defaultElementType;
}
diff --git a/app/code/core/Mage/Widget/Model/Widget/Instance.php b/app/code/core/Mage/Widget/Model/Widget/Instance.php
index da6a0eac52a..39512094197 100644
--- a/app/code/core/Mage/Widget/Model/Widget/Instance.php
+++ b/app/code/core/Mage/Widget/Model/Widget/Instance.php
@@ -222,7 +222,7 @@ public function getType()
*/
protected function _prepareType()
{
- if (strpos((string)$this->_getData('type'), '-') !== false) {
+ if (str_contains((string)$this->_getData('type'), '-')) {
$this->setData('type', str_replace('-', '/', $this->_getData('type')));
}
return $this;
diff --git a/app/code/core/Mage/Wishlist/controllers/IndexController.php b/app/code/core/Mage/Wishlist/controllers/IndexController.php
index d021467a559..426d18832e5 100644
--- a/app/code/core/Mage/Wishlist/controllers/IndexController.php
+++ b/app/code/core/Mage/Wishlist/controllers/IndexController.php
@@ -721,7 +721,7 @@ public function downloadCustomOptionAction()
}
$optionId = null;
- if (strpos($option->getCode(), Mage_Catalog_Model_Product_Type_Abstract::OPTION_PREFIX) === 0) {
+ if (str_starts_with($option->getCode(), Mage_Catalog_Model_Product_Type_Abstract::OPTION_PREFIX)) {
$optionId = str_replace(Mage_Catalog_Model_Product_Type_Abstract::OPTION_PREFIX, '', $option->getCode());
if (!is_numeric($optionId)) {
return $this->_forward('noRoute');
diff --git a/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Page.php b/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Page.php
index e5d1649c522..4752212d0e5 100644
--- a/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Page.php
+++ b/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Page.php
@@ -177,10 +177,10 @@ protected function generatePageClassBlock($blockName, array $params, $indent = '
*/
protected function getParentPage($folderPath, $mca, $area)
{
- if (strpos($folderPath, 'Adminhtml') !== false && $area === 'Adminhtml') {
+ if (str_contains($folderPath, 'Adminhtml') && $area === 'Adminhtml') {
$areaMtfPage = 'BackendPage';
} else {
- if (strpos($mca, 'http') === false) {
+ if (!str_contains($mca, 'http')) {
$areaMtfPage = 'FrontendPage';
} else {
$areaMtfPage = 'ExternalPage';
diff --git a/dev/tests/functional/tests/app/Mage/Admin/Test/Constraint/AssertUserWithRestrictedResources.php b/dev/tests/functional/tests/app/Mage/Admin/Test/Constraint/AssertUserWithRestrictedResources.php
index 9cd305a5925..10489ca9561 100644
--- a/dev/tests/functional/tests/app/Mage/Admin/Test/Constraint/AssertUserWithRestrictedResources.php
+++ b/dev/tests/functional/tests/app/Mage/Admin/Test/Constraint/AssertUserWithRestrictedResources.php
@@ -67,7 +67,7 @@ public function processAssert(User $user, AdminAuthLogin $adminAuthLogin, Dashbo
$browser->open($_ENV['app_backend_url'] . $this->manageProductsUrl);
\PHPUnit_Framework_Assert::assertTrue(
- strpos($dashboard->getMainBlock()->getMainBlockText(), self::ACCESS_DENIED) !== false,
+ str_contains($dashboard->getMainBlock()->getMainBlockText(), self::ACCESS_DENIED),
self::ACCESS_DENIED . " text is not visible on dashboard page.");
}
diff --git a/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Catalog/Product/Attribute/CustomAttribute.php b/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Catalog/Product/Attribute/CustomAttribute.php
index 8d6556536a2..d6a4c6b34c6 100644
--- a/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Catalog/Product/Attribute/CustomAttribute.php
+++ b/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Catalog/Product/Attribute/CustomAttribute.php
@@ -155,7 +155,7 @@ protected function getElementByClass($class)
{
$element = null;
foreach ($this->classReference as $key => $reference) {
- if (strpos($class, $key) !== false) {
+ if (str_contains($class, $key)) {
$element = $reference;
}
}
diff --git a/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Sales/Order/Comments.php b/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Sales/Order/Comments.php
index e6cce43d9b4..9e1c8334974 100644
--- a/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Sales/Order/Comments.php
+++ b/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Sales/Order/Comments.php
@@ -56,7 +56,7 @@ public function isCommentPresent($commentText)
{
$comments = $this->getCommentsElements();
foreach ($comments as $comment) {
- if (strpos($comment->getText(), $commentText) !== false) {
+ if (str_contains($comment->getText(), $commentText)) {
return true;
}
}
diff --git a/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Widget/FormTabs.php b/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Widget/FormTabs.php
index 478e5de95a1..b6595a9143a 100644
--- a/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Widget/FormTabs.php
+++ b/dev/tests/functional/tests/app/Mage/Adminhtml/Test/Block/Widget/FormTabs.php
@@ -80,7 +80,7 @@ protected function getPaths()
{
$realPath = str_replace('\\', '/', get_class($this)) . '.xml';
$paths = glob(MTF_TESTS_PATH . preg_replace('/Mage\/\w+/', '*/*', $realPath));
- if (strpos($realPath, 'Adminhtml') !== false) {
+ if (str_contains($realPath, 'Adminhtml')) {
$paths = array_merge(
$paths,
glob(MTF_TESTS_PATH . preg_replace('/Mage\/(\w+)(\/.*Block\/)/', '*/*$2$1/', $realPath)),
diff --git a/dev/tests/functional/tests/app/Mage/Catalog/Test/Constraint/AssertProductCompareItemsLink.php b/dev/tests/functional/tests/app/Mage/Catalog/Test/Constraint/AssertProductCompareItemsLink.php
index b57c0a14ace..4b1ad8865f4 100644
--- a/dev/tests/functional/tests/app/Mage/Catalog/Test/Constraint/AssertProductCompareItemsLink.php
+++ b/dev/tests/functional/tests/app/Mage/Catalog/Test/Constraint/AssertProductCompareItemsLink.php
@@ -50,7 +50,7 @@ public function processAssert(CmsIndex $cmsIndex, array $products)
);
\PHPUnit_Framework_Assert::assertTrue(
- strpos($cmsIndex->getCompareBlock()->getCompareLinkUrl(), $this->compareProductUrl) !== false,
+ str_contains($cmsIndex->getCompareBlock()->getCompareLinkUrl(), $this->compareProductUrl),
'Compare product link isn\'t lead to Compare Product Page.'
);
}
diff --git a/dev/tests/functional/tests/app/Mage/Install/Test/Constraint/AssertCurrencySelected.php b/dev/tests/functional/tests/app/Mage/Install/Test/Constraint/AssertCurrencySelected.php
index b75b89271b3..feaca10fd16 100644
--- a/dev/tests/functional/tests/app/Mage/Install/Test/Constraint/AssertCurrencySelected.php
+++ b/dev/tests/functional/tests/app/Mage/Install/Test/Constraint/AssertCurrencySelected.php
@@ -33,7 +33,7 @@ public function processAssert(Dashboard $dashboard, $currencySymbol)
{
$dashboard->open();
\PHPUnit_Framework_Assert::assertTrue(
- strpos($dashboard->getMainBlock()->getRevenuePrice(), $currencySymbol) !== false,
+ str_contains($dashboard->getMainBlock()->getRevenuePrice(), $currencySymbol),
'Selected currency symbol not displays on dashboard.'
);
}
diff --git a/dev/tests/functional/tests/app/Mage/Install/Test/Constraint/AssertRewritesEnabled.php b/dev/tests/functional/tests/app/Mage/Install/Test/Constraint/AssertRewritesEnabled.php
index 79bfa1481fa..a0cac979165 100644
--- a/dev/tests/functional/tests/app/Mage/Install/Test/Constraint/AssertRewritesEnabled.php
+++ b/dev/tests/functional/tests/app/Mage/Install/Test/Constraint/AssertRewritesEnabled.php
@@ -37,7 +37,7 @@ public function processAssert(CatalogCategory $category, CmsIndex $homePage, Bro
$homePage->open();
$homePage->getTopmenu()->selectCategory($category->getName());
\PHPUnit_Framework_Assert::assertTrue(
- strpos($browser->getUrl(), 'index.php') === false,
+ !str_contains($browser->getUrl(), 'index.php'),
'Apache redirect for category does not work.'
);
}
diff --git a/dev/tests/functional/tests/app/Mage/Install/Test/Constraint/AssertSecureUrlEnabled.php b/dev/tests/functional/tests/app/Mage/Install/Test/Constraint/AssertSecureUrlEnabled.php
index e9e183ef684..e29b59716ec 100644
--- a/dev/tests/functional/tests/app/Mage/Install/Test/Constraint/AssertSecureUrlEnabled.php
+++ b/dev/tests/functional/tests/app/Mage/Install/Test/Constraint/AssertSecureUrlEnabled.php
@@ -34,7 +34,7 @@ public function processAssert(BrowserInterface $browser, Dashboard $dashboard)
{
$dashboard->open();
\PHPUnit_Framework_Assert::assertTrue(
- strpos($browser->getUrl(), 'https://') !== false,
+ str_contains($browser->getUrl(), 'https://'),
'Secure Url is not displayed on backend.'
);
}
diff --git a/dev/tests/functional/tests/app/Mage/Sitemap/Test/Constraint/AssertSitemapContent.php b/dev/tests/functional/tests/app/Mage/Sitemap/Test/Constraint/AssertSitemapContent.php
index b95bfad7756..c95f76e03bc 100644
--- a/dev/tests/functional/tests/app/Mage/Sitemap/Test/Constraint/AssertSitemapContent.php
+++ b/dev/tests/functional/tests/app/Mage/Sitemap/Test/Constraint/AssertSitemapContent.php
@@ -79,7 +79,7 @@ public function processAssert(
protected function checkContent($content, $urls)
{
foreach ($urls as $url) {
- if (strpos($content, $url) === false) {
+ if (!str_contains($content, $url)) {
return false;
}
}
diff --git a/lib/Magento/Profiler.php b/lib/Magento/Profiler.php
index 2f03c38ede2..b708a817275 100644
--- a/lib/Magento/Profiler.php
+++ b/lib/Magento/Profiler.php
@@ -151,7 +151,7 @@ public static function start($timerName)
return;
}
- if (strpos($timerName, self::NESTING_SEPARATOR) !== false) {
+ if (str_contains($timerName, self::NESTING_SEPARATOR)) {
throw new Varien_Exception('Timer name must not contain a nesting separator.');
}
diff --git a/lib/Varien/Data/Collection.php b/lib/Varien/Data/Collection.php
index b1aa787dfd8..4ce6e69b7ff 100644
--- a/lib/Varien/Data/Collection.php
+++ b/lib/Varien/Data/Collection.php
@@ -440,7 +440,7 @@ public function clear()
public function walk($callback, array $args = [])
{
$results = [];
- $useItemCallback = is_string($callback) && strpos($callback, '::') === false;
+ $useItemCallback = is_string($callback) && !str_contains($callback, '::');
foreach ($this->getItems() as $id => $item) {
if ($useItemCallback) {
$cb = [$item, $callback];
diff --git a/lib/Varien/Db/Adapter/Pdo/Mysql.php b/lib/Varien/Db/Adapter/Pdo/Mysql.php
index f750420563b..9b2de2e7868 100644
--- a/lib/Varien/Db/Adapter/Pdo/Mysql.php
+++ b/lib/Varien/Db/Adapter/Pdo/Mysql.php
@@ -305,7 +305,7 @@ protected function _getHostInfo($hostName)
{
$hostInfo = new Varien_Object();
$matches = [];
- if (strpos($hostName, '/') !== false) {
+ if (str_contains($hostName, '/')) {
$hostInfo->setAddressType(self::ADDRESS_TYPE_UNIX_SOCKET)
->setUnixSocket($hostName);
} elseif (preg_match('/^\[(([0-9a-f]{1,4})?(:([0-9a-f]{1,4})?){1,}:([0-9a-f]{1,4}))(%[0-9a-z]+)?\](:([0-9]+))?$/i', $hostName, $matches)) {
@@ -319,7 +319,7 @@ protected function _getHostInfo($hostName)
!is_null($hostName) && isset($matches[6]) && ($hostName .= $matches[6]);
$hostInfo->setAddressType(self::ADDRESS_TYPE_IPV6_ADDRESS)
->setHostName($hostName);
- } elseif (strpos($hostName, ':') !== false) {
+ } elseif (str_contains($hostName, ':')) {
list($hostAddress, $hostPort) = explode(':', $hostName);
$hostInfo->setAddressType(
filter_var($hostAddress, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)
diff --git a/lib/Varien/Event/Observer/Cron.php b/lib/Varien/Event/Observer/Cron.php
index a687f14fa49..87a753939d9 100644
--- a/lib/Varien/Event/Observer/Cron.php
+++ b/lib/Varien/Event/Observer/Cron.php
@@ -73,7 +73,7 @@ public function matchCronExpression($expr, $num)
}
// handle multiple options
- if (strpos($expr, ',') !== false) {
+ if (str_contains($expr, ',')) {
foreach (explode(',', $expr) as $e) {
if ($this->matchCronExpression($e, $num)) {
return true;
@@ -83,7 +83,7 @@ public function matchCronExpression($expr, $num)
}
// handle modulus
- if (strpos($expr, '/') !== false) {
+ if (str_contains($expr, '/')) {
$e = explode('/', $expr);
if (count($e) !== 2) {
return false;
@@ -98,7 +98,7 @@ public function matchCronExpression($expr, $num)
}
// handle range
- if (strpos($expr, '-') !== false) {
+ if (str_contains($expr, '-')) {
$e = explode('-', $expr);
if (count($e) !== 2) {
return false;
diff --git a/lib/Varien/File/Csv.php b/lib/Varien/File/Csv.php
index 35299e0c1d3..0a26bb438da 100644
--- a/lib/Varien/File/Csv.php
+++ b/lib/Varien/File/Csv.php
@@ -126,8 +126,8 @@ public function fputcsv(&$handle, $fields = [], $delimiter = ',', $enclosure = '
$str = '';
$escape_char = '\\';
foreach ($fields as $value) {
- if (strpos($value, $delimiter) !== false ||
- strpos($value, $enclosure) !== false ||
+ if (str_contains($value, $delimiter) ||
+ str_contains($value, $enclosure) ||
strpos($value, "\n") !== false ||
strpos($value, "\r") !== false ||
strpos($value, "\t") !== false ||
diff --git a/lib/Varien/Io/File.php b/lib/Varien/Io/File.php
index c2aec9e59a1..4bb1c0462a3 100644
--- a/lib/Varien/Io/File.php
+++ b/lib/Varien/Io/File.php
@@ -486,7 +486,7 @@ public function read($filename, $dest = null)
*/
public function write($filename, $src, $mode = null)
{
- if (strpos($filename, chr(0)) !== false
+ if (str_contains($filename, chr(0))
|| preg_match('#(^|[\\\\/])\.\.($|[\\\\/])#', $filename)
) {
throw new Exception('Detected malicious path or filename input.');
@@ -525,7 +525,7 @@ protected function _isValidSource($src)
if (is_string($src)) {
// If its a file we check for null byte
// If it's not a valid path, file_exists() will return a falsey value, and the @ will keep it from complaining about the bad string.
- return !(@file_exists($src) && strpos($src, chr(0)) !== false);
+ return !(@file_exists($src) && str_contains($src, chr(0)));
} elseif (is_resource($src)) {
return true;
}