diff --git a/.github/workflows/php-cs-fixer.yml b/.github/workflows/php-cs-fixer.yml index c340b673359..9da34839476 100644 --- a/.github/workflows/php-cs-fixer.yml +++ b/.github/workflows/php-cs-fixer.yml @@ -14,7 +14,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: 7.4 + php-version: 8.1 - name: Checkout code uses: actions/checkout@v4 diff --git a/.github/workflows/phpcs.yml b/.github/workflows/phpcs.yml index 669c4276c7c..b118cc8f66d 100644 --- a/.github/workflows/phpcs.yml +++ b/.github/workflows/phpcs.yml @@ -14,7 +14,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: 7.4 + php-version: 8.1 - name: Checkout code uses: actions/checkout@v4 diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index c61af98f42f..570bdc49075 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -14,7 +14,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: 7.4 + php-version: 8.1 - uses: actions/checkout@v4 diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index cbec9b75674..19bca6b856c 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -14,7 +14,7 @@ jobs: strategy: matrix: operating-system: [ubuntu-latest] - php-versions: ['7.4', '8.4'] + php-versions: ['8.1', '8.4'] mysql-version: ['5.7', '8.0', '8.4'] services: diff --git a/.github/workflows/rector.yml b/.github/workflows/rector.yml index 032a17702a9..f71000bb32d 100644 --- a/.github/workflows/rector.yml +++ b/.github/workflows/rector.yml @@ -14,7 +14,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: 7.4 + php-version: 8.1 - name: Checkout code uses: actions/checkout@v4 diff --git a/.github/workflows/syntax-php.yml b/.github/workflows/syntax-php.yml index 689a191b7ea..3336b3fef95 100644 --- a/.github/workflows/syntax-php.yml +++ b/.github/workflows/syntax-php.yml @@ -14,7 +14,7 @@ jobs: strategy: matrix: - php: ['7.4', '8.4'] + php: ['8.1', '8.4'] name: PHP Syntax ${{ matrix.php }} diff --git a/.phpstan.dist.baseline.neon b/.phpstan.dist.baseline.neon index 3bbf3a121dd..88e4a34d42d 100644 --- a/.phpstan.dist.baseline.neon +++ b/.phpstan.dist.baseline.neon @@ -451,7 +451,7 @@ parameters: path: app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tab/Wizard.php - - message: '#^Parameter \#2 \$character_mask of function rtrim expects string, int given\.$#' + message: '#^Parameter \#2 \$characters of function rtrim expects string, int given\.$#' identifier: argument.type count: 1 path: app/code/core/Mage/Adminhtml/Block/System/Currency/Rate/Matrix.php @@ -691,7 +691,7 @@ parameters: path: app/code/core/Mage/Adminhtml/controllers/Customer/Wishlist/Product/Composite/WishlistController.php - - message: '#^Parameter \#2 \$timestamp of function date expects int, array\|bool given\.$#' + message: '#^Parameter \#2 \$timestamp of function date expects int\|null, array\|bool given\.$#' identifier: argument.type count: 1 path: app/code/core/Mage/Adminhtml/controllers/CustomerController.php @@ -798,6 +798,12 @@ parameters: count: 2 path: app/code/core/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php + - + message: '#^Parameter \#2 \$enable of function imageinterlace expects bool\|null, int given\.$#' + identifier: argument.type + count: 1 + path: app/code/core/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php + - message: '#^Method Mage_Adminhtml_Controller_Action\:\:_setForcedFormKeyActions\(\) invoked with 2 parameters, 1 required\.$#' identifier: arguments.count @@ -919,7 +925,7 @@ parameters: path: app/code/core/Mage/Api/Model/Server/Adapter/Soap.php - - message: '#^Parameter \#1 \$code of class SoapFault constructor expects string, int given\.$#' + message: '#^Parameter \#1 \$code of class SoapFault constructor expects array\|string\|null, int given\.$#' identifier: argument.type count: 1 path: app/code/core/Mage/Api/Model/Server/Adapter/Soap.php @@ -973,7 +979,7 @@ parameters: path: app/code/core/Mage/Api/Model/Server/V2/Handler.php - - message: '#^Parameter \#2 \$needle of function str_contains expects string\|null, array given\.$#' + message: '#^Parameter \#2 \$needle of function str_contains expects string, array given\.$#' identifier: argument.type count: 1 path: app/code/core/Mage/Api/Model/Server/V2/Handler.php @@ -1003,7 +1009,7 @@ parameters: path: app/code/core/Mage/Api/Model/Server/Wsi/Handler.php - - message: '#^Parameter \#2 \$needle of function str_contains expects string\|null, array given\.$#' + message: '#^Parameter \#2 \$needle of function str_contains expects string, array given\.$#' identifier: argument.type count: 1 path: app/code/core/Mage/Api/Model/Server/Wsi/Handler.php @@ -1044,6 +1050,12 @@ parameters: count: 1 path: app/code/core/Mage/Api/Model/Wsdl/Config/Element.php + - + message: '#^Return type \(array\) of method Mage_Api_Model_Wsdl_Config_Element\:\:getChildren\(\) should be compatible with return type \(RecursiveIterator\|null\) of method RecursiveIterator\\:\:getChildren\(\)$#' + identifier: method.childReturnType + count: 1 + path: app/code/core/Mage/Api/Model/Wsdl/Config/Element.php + - message: '#^Parameter \#1 \$collection of method Mage_Adminhtml_Block_Widget_Grid\:\:setCollection\(\) expects Varien_Data_Collection_Db, Varien_Data_Collection given\.$#' identifier: argument.type @@ -1183,7 +1195,7 @@ parameters: path: app/code/core/Mage/Api2/Model/Resource/Validator/Eav.php - - message: '#^Parameter \#2 \.\.\.\$args of function array_merge expects array, false given\.$#' + message: '#^Parameter \#2 \.\.\.\$arrays of function array_merge expects array, false given\.$#' identifier: argument.type count: 1 path: app/code/core/Mage/Api2/Model/Resource/Validator/Eav.php @@ -2839,7 +2851,7 @@ parameters: path: app/code/core/Mage/ConfigurableSwatches/Model/Resource/Catalog/Product/Type/Configurable/Product/Collection.php - - message: '#^Parameter \#1 \$stack of function array_unshift expects array, null given\.$#' + message: '#^Parameter \#1 \$array of function array_unshift expects array, null given\.$#' identifier: argument.type count: 1 path: app/code/core/Mage/ConfigurableSwatches/Model/System/Config/Source/Catalog/Product/Configattribute/Select.php @@ -3810,12 +3822,6 @@ parameters: count: 1 path: app/code/core/Mage/Dataflow/Model/Convert/Profile/Abstract.php - - - message: '#^Parameter \#2 \$class_name of function simplexml_load_string expects string, null given\.$#' - identifier: argument.type - count: 1 - path: app/code/core/Mage/Dataflow/Model/Profile.php - - message: '#^Right side of && is always true\.$#' identifier: booleanAnd.rightAlwaysTrue @@ -3870,12 +3876,6 @@ parameters: count: 1 path: app/code/core/Mage/Directory/Model/Currency/Import/Webservicex.php - - - message: '#^Parameter \#2 \$class_name of function simplexml_load_string expects string, null given\.$#' - identifier: argument.type - count: 1 - path: app/code/core/Mage/Directory/Model/Currency/Import/Webservicex.php - - message: '#^Parameter \#1 \$modelClass of static method Mage\:\:getModel\(\) expects string, array given\.$#' identifier: argument.type @@ -3907,7 +3907,7 @@ parameters: path: app/code/core/Mage/Downloadable/Helper/Download.php - - message: '#^Parameter \#1 \$str of function strtolower expects string, bool given\.$#' + message: '#^Parameter \#1 \$string of function strtolower expects string, bool given\.$#' identifier: argument.type count: 2 path: app/code/core/Mage/Downloadable/Helper/Download.php @@ -4075,7 +4075,7 @@ parameters: path: app/code/core/Mage/Eav/Model/Convert/Adapter/Grid.php - - message: '#^Parameter \#2 \$str of function explode expects string, array given\.$#' + message: '#^Parameter \#2 \$string of function explode expects string, array given\.$#' identifier: argument.type count: 1 path: app/code/core/Mage/Eav/Model/Convert/Parser/Abstract.php @@ -4351,7 +4351,7 @@ parameters: path: app/code/core/Mage/Eav/Model/Form.php - - message: '#^Parameter \#2 \.\.\.\$args of function array_merge expects array, false given\.$#' + message: '#^Parameter \#2 \.\.\.\$arrays of function array_merge expects array, false given\.$#' identifier: argument.type count: 1 path: app/code/core/Mage/Eav/Model/Form.php @@ -4464,12 +4464,6 @@ parameters: count: 1 path: app/code/core/Mage/ImportExport/Block/Adminhtml/Export/Filter.php - - - message: '#^Parameter \#2 \$fields of function fputcsv expects array\, null given\.$#' - identifier: argument.type - count: 1 - path: app/code/core/Mage/ImportExport/Model/Export/Adapter/Abstract.php - - message: '#^Method Mage_Eav_Model_Entity_Attribute_Source_Interface\:\:getAllOptions\(\) invoked with 1 parameter, 0 required\.$#' identifier: arguments.count @@ -4656,6 +4650,60 @@ parameters: count: 2 path: app/code/core/Mage/Log/Model/Resource/Log.php + - + message: '#^Method Mage_Media_Model_File_Image\:\:getImage\(\) should return bool\|resource but returns GdImage\.$#' + identifier: return.type + count: 1 + path: app/code/core/Mage/Media/Model/File/Image.php + + - + message: '#^Method Mage_Media_Model_File_Image\:\:getTmpImage\(\) should return resource but returns \(GdImage\|false\)\.$#' + identifier: return.type + count: 1 + path: app/code/core/Mage/Media/Model/File/Image.php + + - + message: '#^Parameter \#1 \$dst_image of function imagecopyresampled expects GdImage, resource given\.$#' + identifier: argument.type + count: 1 + path: app/code/core/Mage/Media/Model/File/Image.php + + - + message: '#^Parameter \#1 \$image of function imagedestroy expects GdImage, resource given\.$#' + identifier: argument.type + count: 1 + path: app/code/core/Mage/Media/Model/File/Image.php + + - + message: '#^Parameter \#1 \$image of function imagegif expects GdImage, resource given\.$#' + identifier: argument.type + count: 1 + path: app/code/core/Mage/Media/Model/File/Image.php + + - + message: '#^Parameter \#1 \$image of function imagejpeg expects GdImage, resource given\.$#' + identifier: argument.type + count: 1 + path: app/code/core/Mage/Media/Model/File/Image.php + + - + message: '#^Parameter \#1 \$image of function imagepng expects GdImage, resource given\.$#' + identifier: argument.type + count: 1 + path: app/code/core/Mage/Media/Model/File/Image.php + + - + message: '#^Parameter \#1 \$image of function imagewebp expects GdImage, resource given\.$#' + identifier: argument.type + count: 1 + path: app/code/core/Mage/Media/Model/File/Image.php + + - + message: '#^Parameter \#2 \$src_image of function imagecopyresampled expects GdImage, resource given\.$#' + identifier: argument.type + count: 1 + path: app/code/core/Mage/Media/Model/File/Image.php + - message: '#^Call to function is_null\(\) with bool will always evaluate to false\.$#' identifier: function.impossibleType @@ -4932,12 +4980,6 @@ parameters: count: 1 path: app/code/core/Mage/Paypal/Model/Payflowlink.php - - - message: '#^Loose comparison using \!\= between float and \(float\|false\) will always evaluate to false\.$#' - identifier: notEqual.alwaysFalse - count: 1 - path: app/code/core/Mage/Paypal/Model/Payflowpro.php - - message: '#^Parameter \#1 \$payment of method Mage_Paypal_Model_Payflowpro\:\:_buildBasicRequest\(\) expects Mage_Sales_Model_Order_Payment, Mage_Payment_Model_Info given\.$#' identifier: argument.type @@ -5244,12 +5286,6 @@ parameters: count: 1 path: app/code/core/Mage/Reports/Model/Resource/Review/Collection.php - - - message: '#^Call to an undefined static method Mage_Review_Model_Resource_Review_Collection\:\:resetSelect\(\)\.$#' - identifier: staticMethod.notFound - count: 1 - path: app/code/core/Mage/Reports/Model/Resource/Review/Collection.php - - message: '#^Call to an undefined method Mage_Eav_Model_Entity_Abstract\:\:setStore\(\)\.$#' identifier: method.notFound @@ -5437,7 +5473,7 @@ parameters: path: app/code/core/Mage/Sales/Model/Order/Api.php - - message: '#^Parameter \#1 \$str of function trim expects string, float given\.$#' + message: '#^Parameter \#1 \$string of function trim expects string, float given\.$#' identifier: argument.type count: 2 path: app/code/core/Mage/Sales/Model/Order/Creditmemo.php @@ -6331,7 +6367,7 @@ parameters: path: app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Abstract.php - - message: '#^Parameter \#2 \$str of function explode expects string, array given\.$#' + message: '#^Parameter \#2 \$string of function explode expects string, array given\.$#' identifier: argument.type count: 1 path: app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Abstract.php @@ -6366,12 +6402,6 @@ parameters: count: 1 path: app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International.php - - - message: '#^Parameter \#1 \$array_arg of function sort contains unresolvable type\.$#' - identifier: argument.unresolvableType - count: 1 - path: app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International.php - - message: '#^Call to an undefined method Zend_Pdf_Page\:\:drawLines\(\)\.$#' identifier: method.notFound @@ -6463,7 +6493,7 @@ parameters: path: app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups.php - - message: '#^Parameter \#2 \$value of method SimpleXMLElement\:\:addChild\(\) expects string\|null, \(float\|false\) given\.$#' + message: '#^Parameter \#2 \$value of method SimpleXMLElement\:\:addChild\(\) expects string\|null, float given\.$#' identifier: argument.type count: 1 path: app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups.php @@ -6493,7 +6523,7 @@ parameters: path: app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups.php - - message: '#^Parameter \#1 \$code of function curl_strerror expects int, \(resource\|false\) given\.$#' + message: '#^Parameter \#1 \$error_code of function curl_strerror expects int, \(CurlHandle\|false\) given\.$#' identifier: argument.type count: 1 path: app/code/core/Mage/Usa/Model/Shipping/Carrier/UpsAuth.php @@ -8070,6 +8100,18 @@ parameters: count: 1 path: lib/Mage/DB/Mysqli.php + - + message: '#^Parameter \#1 \$handle of function curl_setopt expects CurlHandle, resource\|false given\.$#' + identifier: argument.type + count: 1 + path: lib/Mage/HTTP/Client/Curl.php + + - + message: '#^Parameter \#1 \$handle of function curl_setopt_array expects CurlHandle, resource\|false given\.$#' + identifier: argument.type + count: 1 + path: lib/Mage/HTTP/Client/Curl.php + - message: '#^Property Mage_HTTP_Client_Socket\:\:\$_postFields is never read, only written\.$#' identifier: property.onlyWritten @@ -8089,11 +8131,95 @@ parameters: path: lib/Mage/System/Ftp.php - - message: '#^Parameter \#1 \$input of function array_sum expects an array of values castable to number, list\ given\.$#' + message: '#^Parameter \#1 \$array of function array_sum expects an array of values castable to number, list\ given\.$#' + identifier: argument.type + count: 3 + path: lib/Mage/System/Ftp.php + + - + message: '#^Parameter \#1 \$ftp of function ftp_cdup expects FTP\\Connection, resource\|false given\.$#' + identifier: argument.type + count: 1 + path: lib/Mage/System/Ftp.php + + - + message: '#^Parameter \#1 \$ftp of function ftp_chdir expects FTP\\Connection, resource\|false given\.$#' identifier: argument.type count: 3 path: lib/Mage/System/Ftp.php + - + message: '#^Parameter \#1 \$ftp of function ftp_chmod expects FTP\\Connection, resource\|false given\.$#' + identifier: argument.type + count: 2 + path: lib/Mage/System/Ftp.php + + - + message: '#^Parameter \#1 \$ftp of function ftp_close expects FTP\\Connection, resource given\.$#' + identifier: argument.type + count: 1 + path: lib/Mage/System/Ftp.php + + - + message: '#^Parameter \#1 \$ftp of function ftp_delete expects FTP\\Connection, resource\|false given\.$#' + identifier: argument.type + count: 1 + path: lib/Mage/System/Ftp.php + + - + message: '#^Parameter \#1 \$ftp of function ftp_fput expects FTP\\Connection, resource\|false given\.$#' + identifier: argument.type + count: 1 + path: lib/Mage/System/Ftp.php + + - + message: '#^Parameter \#1 \$ftp of function ftp_get expects FTP\\Connection, resource\|false given\.$#' + identifier: argument.type + count: 1 + path: lib/Mage/System/Ftp.php + + - + message: '#^Parameter \#1 \$ftp of function ftp_login expects FTP\\Connection, resource\|false given\.$#' + identifier: argument.type + count: 1 + path: lib/Mage/System/Ftp.php + + - + message: '#^Parameter \#1 \$ftp of function ftp_mkdir expects FTP\\Connection, resource\|false given\.$#' + identifier: argument.type + count: 2 + path: lib/Mage/System/Ftp.php + + - + message: '#^Parameter \#1 \$ftp of function ftp_nlist expects FTP\\Connection, resource\|false given\.$#' + identifier: argument.type + count: 1 + path: lib/Mage/System/Ftp.php + + - + message: '#^Parameter \#1 \$ftp of function ftp_pasv expects FTP\\Connection, resource\|false given\.$#' + identifier: argument.type + count: 1 + path: lib/Mage/System/Ftp.php + + - + message: '#^Parameter \#1 \$ftp of function ftp_put expects FTP\\Connection, resource\|false given\.$#' + identifier: argument.type + count: 1 + path: lib/Mage/System/Ftp.php + + - + message: '#^Parameter \#1 \$ftp of function ftp_raw expects FTP\\Connection, resource\|false given\.$#' + identifier: argument.type + count: 1 + path: lib/Mage/System/Ftp.php + + - + message: '#^Parameter \#1 \$ftp of function ftp_rawlist expects FTP\\Connection, resource\|false given\.$#' + identifier: argument.type + count: 1 + path: lib/Mage/System/Ftp.php + - message: '#^Parameter \#4 \$mode of function ftp_fput expects 1\|2, int given\.$#' identifier: argument.type @@ -8263,13 +8389,13 @@ parameters: path: lib/Varien/Data/Form/Element/Multiline.php - - message: '#^Parameter \#1 \$input of function str_pad expects string, int\<0, 23\> given\.$#' + message: '#^Parameter \#1 \$string of function str_pad expects string, int\<0, 23\> given\.$#' identifier: argument.type count: 1 path: lib/Varien/Data/Form/Element/Time.php - - message: '#^Parameter \#1 \$input of function str_pad expects string, int\<0, 59\> given\.$#' + message: '#^Parameter \#1 \$string of function str_pad expects string, int\<0, 59\> given\.$#' identifier: argument.type count: 2 path: lib/Varien/Data/Form/Element/Time.php @@ -8292,6 +8418,12 @@ parameters: count: 1 path: lib/Varien/Data/Tree/Node/Collection.php + - + message: '#^Parameter \#2 \$value of method mysqli\:\:options\(\) expects int\|string, true given\.$#' + identifier: argument.type + count: 1 + path: lib/Varien/Db/Adapter/Mysqli.php + - message: '#^Variable \$result might not be defined\.$#' identifier: variable.undefined @@ -8382,12 +8514,6 @@ parameters: count: 1 path: lib/Varien/Filter/Template/Tokenizer/Variable.php - - - message: '#^Method Varien_Http_Adapter_Curl\:\:_getResource\(\) has invalid return type CurlHandle\.$#' - identifier: class.notFound - count: 1 - path: lib/Varien/Http/Adapter/Curl.php - - message: '#^Parameter \#3 \$value of function curl_setopt expects bool, int given\.$#' identifier: argument.type @@ -8395,19 +8521,19 @@ parameters: path: lib/Varien/Http/Adapter/Curl.php - - message: '#^Property Varien_Http_Adapter_Curl\:\:\$_resource has unknown class CurlHandle as its type\.$#' - identifier: class.notFound + message: '#^Parameter \#2 \$enable of function imageinterlace expects bool\|null, int given\.$#' + identifier: argument.type count: 1 - path: lib/Varien/Http/Adapter/Curl.php + path: lib/Varien/Image/Adapter/Gd2.php - - message: '#^Property Varien_Image_Adapter_Abstract\:\:\$_imageHandler has unknown class GdImage as its type\.$#' - identifier: class.notFound + message: '#^Comparison operation "\<" between int\<80100, 80499\> and 80100 is always false\.$#' + identifier: smaller.alwaysFalse count: 1 - path: lib/Varien/Image/Adapter/Abstract.php + path: lib/Varien/Io/File.php - - message: '#^Parameter \#1 \$groupname of function posix_getgrnam expects string, int\|false given\.$#' + message: '#^Parameter \#1 \$name of function posix_getgrnam expects string, int\|false given\.$#' identifier: argument.type count: 1 path: lib/Varien/Io/File.php @@ -8418,6 +8544,12 @@ parameters: count: 1 path: lib/Varien/Io/File.php + - + message: '#^Result of && is always false\.$#' + identifier: booleanAnd.alwaysFalse + count: 1 + path: lib/Varien/Io/File.php + - message: '#^Parameter \#1 \$prefix of function uniqid expects string, int\<0, max\> given\.$#' identifier: argument.type @@ -8483,3 +8615,9 @@ parameters: identifier: argument.type count: 1 path: lib/Varien/Simplexml/Element.php + + - + message: '#^Comparison operation "\>\=" between int\<80100, 80499\> and 80000 is always true\.$#' + identifier: greaterOrEqual.alwaysTrue + count: 1 + path: tests/unit/Mage/Core/Model/LayoutTest.php diff --git a/.phpstan.dist.neon b/.phpstan.dist.neon index 4684698a9e6..70710d0ba4b 100644 --- a/.phpstan.dist.neon +++ b/.phpstan.dist.neon @@ -4,7 +4,7 @@ includes: - phar://phpstan.phar/conf/bleedingEdge.neon parameters: phpVersion: - min: 70433 + min: 80100 max: 80499 magentoRootPath: %currentWorkingDirectory% fileExtensions: diff --git a/.rector.php b/.rector.php index 72d497bbe6a..4abc1fd3e9e 100644 --- a/.rector.php +++ b/.rector.php @@ -1,45 +1,78 @@ withPaths([ - __DIR__, - ]) - ->withSkipPath(__DIR__ . '/vendor') - ->withSkip([ - CodeQuality\BooleanNot\SimplifyDeMorganBinaryRector::class, - CodeQuality\If_\SimplifyIfReturnBoolRector::class, - __DIR__ . '/shell/translations.php', - __DIR__ . '/shell/update-copyright.php.php', - __DIR__ . '/tests/unit/Mage/Reports/Model/Resource/Report/CollectionTest.php', - ]) - ->withSets([ - PHPUnitSetList::PHPUNIT_90, - SetList::PRIVATIZATION, - SetList::PHP_52, - ]) - ->withRules([ - CodeQuality\BooleanNot\ReplaceMultipleBooleanNotRector::class, - CodeQuality\Foreach_\UnusedForeachValueToArrayKeysRector::class, - CodeQuality\FuncCall\ChangeArrayPushToArrayAssignRector::class, - CodeQuality\FuncCall\CompactToVariablesRector::class, - CodeQuality\FunctionLike\SimplifyUselessVariableRector::class, - CodeQuality\Identical\SimplifyArraySearchRector::class, - CodeQuality\Identical\SimplifyConditionsRector::class, - CodeQuality\Identical\StrlenZeroToIdenticalEmptyStringRector::class, - CodeQuality\NotEqual\CommonNotEqualRector::class, - CodeQuality\LogicalAnd\LogicalToBooleanRector::class, - CodeQuality\Ternary\SimplifyTautologyTernaryRector::class, - DeadCode\ClassMethod\RemoveUselessParamTagRector::class, - DeadCode\ClassMethod\RemoveUselessReturnTagRector::class, - DeadCode\Property\RemoveUselessVarTagRector::class, - TypeDeclaration\ClassMethod\ReturnNeverTypeRector::class, - ]); +try { + return RectorConfig::configure() + ->withPaths([ + __DIR__, + ]) + ->withSkipPath(__DIR__ . '/vendor') + ->withSkip([ + CodeQuality\BooleanNot\SimplifyDeMorganBinaryRector::class, + CodeQuality\If_\SimplifyIfReturnBoolRector::class, + Php53\Ternary\TernaryToElvisRector::class, + Php70\FuncCall\RandomFunctionRector::class, + Php71\FuncCall\RemoveExtraParametersRector::class, + Php73\FuncCall\RegexDashEscapeRector::class, + Php80\Class_\AnnotationToAttributeRector::class, + Php80\Class_\ClassPropertyAssignToConstructorPromotionRector::class, + Php80\Class_\StringableForToStringRector::class, + Php80\FunctionLike\MixedTypeRector::class, + Php80\Identical\StrEndsWithRector::class, + Php80\Identical\StrStartsWithRector::class, + Php80\NotIdentical\StrContainsRector::class, + TypeDeclaration\ClassMethod\ReturnNeverTypeRector::class, + __DIR__ . '/shell/translations.php', + __DIR__ . '/shell/update-copyright.php', + ]) + ->withRules([ + CodeQuality\BooleanNot\ReplaceMultipleBooleanNotRector::class, + CodeQuality\Foreach_\UnusedForeachValueToArrayKeysRector::class, + CodeQuality\FuncCall\ChangeArrayPushToArrayAssignRector::class, + CodeQuality\FuncCall\CompactToVariablesRector::class, + CodeQuality\Identical\SimplifyArraySearchRector::class, + CodeQuality\Identical\SimplifyConditionsRector::class, + CodeQuality\Identical\StrlenZeroToIdenticalEmptyStringRector::class, + CodeQuality\NotEqual\CommonNotEqualRector::class, + CodeQuality\LogicalAnd\LogicalToBooleanRector::class, + CodeQuality\Ternary\SimplifyTautologyTernaryRector::class, + #CodingStyle\FuncCall\ConsistentImplodeRector::class, + DeadCode\ClassMethod\RemoveUselessParamTagRector::class, + DeadCode\ClassMethod\RemoveUselessReturnTagRector::class, + DeadCode\Property\RemoveUselessVarTagRector::class, + DeadCode\StaticCall\RemoveParentCallWithoutParentRector::class, + ]) + ->withPreparedSets( + deadCode: false, + codeQuality: false, + codingStyle: false, + typeDeclarations: false, + privatization: true, + naming: false, + instanceOf: false, + earlyReturn: false, + strictBooleans: false, + carbon: false, + rectorPreset: false, + phpunitCodeQuality: true, + doctrineCodeQuality: false, + symfonyCodeQuality: false, + symfonyConfigs: false, + ); +} catch (InvalidConfigurationException $exception) { + echo $exception->getMessage(); + exit(1); +} \ No newline at end of file diff --git a/app/code/core/Mage/Api2/Model/Request/Interpreter/Xml.php b/app/code/core/Mage/Api2/Model/Request/Interpreter/Xml.php index b49873c4308..d4bb286d1ff 100644 --- a/app/code/core/Mage/Api2/Model/Request/Interpreter/Xml.php +++ b/app/code/core/Mage/Api2/Model/Request/Interpreter/Xml.php @@ -50,13 +50,9 @@ public function interpret($body) } $body = strpos($body, '' . PHP_EOL . $body; - // disable external entity loading to prevent possible vulnerability - libxml_disable_entity_loader(true); set_error_handler([$this, '_loadErrorHandler']); // Warnings and errors are suppressed $config = simplexml_load_string($body); restore_error_handler(); - // restore default behavior to make possible to load external entities - libxml_disable_entity_loader(false); // Check if there was a error while loading file if ($this->_loadErrorStr !== null) { diff --git a/app/code/core/Mage/Core/Block/Html/Date.php b/app/code/core/Mage/Core/Block/Html/Date.php index b075ce37376..03d75617abb 100644 --- a/app/code/core/Mage/Core/Block/Html/Date.php +++ b/app/code/core/Mage/Core/Block/Html/Date.php @@ -85,7 +85,7 @@ protected function _toHtml() public function getEscapedValue($index = null) { if ($this->getFormat() && $this->getValue()) { - return strftime($this->getFormat(), strtotime($this->getValue())); + return date($this->getFormat(), strtotime($this->getValue())); } return htmlspecialchars($this->getValue()); diff --git a/app/code/core/Mage/Install/etc/install.xml b/app/code/core/Mage/Install/etc/install.xml index 0e40c028fbd..4c19ab2c660 100644 --- a/app/code/core/Mage/Install/etc/install.xml +++ b/app/code/core/Mage/Install/etc/install.xml @@ -69,6 +69,7 @@ + diff --git a/app/code/core/Mage/Reports/Model/Resource/Review/Collection.php b/app/code/core/Mage/Reports/Model/Resource/Review/Collection.php index 125751e9e26..edeef00a3c2 100644 --- a/app/code/core/Mage/Reports/Model/Resource/Review/Collection.php +++ b/app/code/core/Mage/Reports/Model/Resource/Review/Collection.php @@ -45,7 +45,6 @@ public function addProductFilter($productId) */ public function resetSelect() { - parent::resetSelect(); $this->_joinFields(); return $this; } diff --git a/composer.json b/composer.json index 0a3f18db4d2..37e85799a38 100644 --- a/composer.json +++ b/composer.json @@ -1,13 +1,14 @@ { "name": "openmage/magento-lts", "description": "A fork of Magento-1 that is accepting bug fixes (backward compatible, drop in replacement for official Magento)", + "homepage": "https://www.openmage.org/", "license": [ "OSL-3.0", "AFL-3.0" ], "type": "magento-source", "require": { - "php": ">=7.4 <8.5", + "php": ">=8.1 <8.5", "ext-ctype": "*", "ext-curl": "*", "ext-dom": "*", @@ -32,19 +33,16 @@ "flowjs/flowjs": "dev-master", "magento-hackathon/magento-composer-installer": "^3.1 || ^2.1 || ^4.0", "mklkj/tinymce-i18n": "^25.2", - "nnnick/chartjs": "^4.4.7", + "nnnick/chartjs": "^4.4", "openmage/composer-plugin": "^3.0", "pelago/emogrifier": "^7.0", "phpseclib/mcrypt_compat": "^2.0.3", "phpseclib/phpseclib": "^3.0.14", "shardj/zf1-future": "^1.24.1", - "symfony/polyfill-php74": "^1.31", - "symfony/polyfill-php80": "^1.31", - "symfony/polyfill-php81": "^1.31", "symfony/polyfill-php82": "^1.31", "symfony/polyfill-php83": "^1.31", "symfony/polyfill-php84": "^1.31", - "symfony/string": "^5.4", + "symfony/string": "^6.4", "symfony/translation-contracts": "^2.5", "tinymce/tinymce": "^7.5" }, @@ -142,7 +140,7 @@ "phpstan/extension-installer": true }, "platform": { - "php": "7.4" + "php": "8.1" }, "sort-packages": true }, diff --git a/composer.lock b/composer.lock index e175842a5c1..59c2145a6be 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "db13f706ae8852602f4561fd4dc5f89a", + "content-hash": "f3c8fd16d6968b2261fe8ed244faa49b", "packages": [ { "name": "colinmollenhour/cache-backend-redis", @@ -2057,83 +2057,6 @@ ], "time": "2024-09-09T11:45:10+00:00" }, - { - "name": "symfony/polyfill-php74", - "version": "v1.31.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php74.git", - "reference": "9589537d05325fb5d88a20d8926823e5b827a43e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php74/zipball/9589537d05325fb5d88a20d8926823e5b827a43e", - "reference": "9589537d05325fb5d88a20d8926823e5b827a43e", - "shasum": "" - }, - "require": { - "php": ">=7.2" - }, - "type": "library", - "extra": { - "thanks": { - "url": "https://github.com/symfony/polyfill", - "name": "symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Php74\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ion Bazan", - "email": "ion.bazan@gmail.com" - }, - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 7.4+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php74/tree/v1.31.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-09-09T11:45:10+00:00" - }, { "name": "symfony/polyfill-php80", "version": "v1.31.0", @@ -2603,34 +2526,34 @@ }, { "name": "symfony/string", - "version": "v5.4.47", + "version": "v6.4.15", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "136ca7d72f72b599f2631aca474a4f8e26719799" + "reference": "73a5e66ea2e1677c98d4449177c5a9cf9d8b4c6f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/136ca7d72f72b599f2631aca474a4f8e26719799", - "reference": "136ca7d72f72b599f2631aca474a4f8e26719799", + "url": "https://api.github.com/repos/symfony/string/zipball/73a5e66ea2e1677c98d4449177c5a9cf9d8b4c6f", + "reference": "73a5e66ea2e1677c98d4449177c5a9cf9d8b4c6f", "shasum": "" }, "require": { - "php": ">=7.2.5", + "php": ">=8.1", "symfony/polyfill-ctype": "~1.8", "symfony/polyfill-intl-grapheme": "~1.0", "symfony/polyfill-intl-normalizer": "~1.0", - "symfony/polyfill-mbstring": "~1.0", - "symfony/polyfill-php80": "~1.15" + "symfony/polyfill-mbstring": "~1.0" }, "conflict": { - "symfony/translation-contracts": ">=3.0" + "symfony/translation-contracts": "<2.5" }, "require-dev": { - "symfony/error-handler": "^4.4|^5.0|^6.0", - "symfony/http-client": "^4.4|^5.0|^6.0", - "symfony/translation-contracts": "^1.1|^2", - "symfony/var-exporter": "^4.4|^5.0|^6.0" + "symfony/error-handler": "^5.4|^6.0|^7.0", + "symfony/http-client": "^5.4|^6.0|^7.0", + "symfony/intl": "^6.2|^7.0", + "symfony/translation-contracts": "^2.5|^3.0", + "symfony/var-exporter": "^5.4|^6.0|^7.0" }, "type": "library", "autoload": { @@ -2669,7 +2592,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v5.4.47" + "source": "https://github.com/symfony/string/tree/v6.4.15" }, "funding": [ { @@ -2685,7 +2608,7 @@ "type": "tidelift" } ], - "time": "2024-11-10T20:33:58+00:00" + "time": "2024-11-13T13:31:12+00:00" }, { "name": "symfony/translation-contracts", @@ -7103,7 +7026,7 @@ "prefer-stable": true, "prefer-lowest": false, "platform": { - "php": ">=7.4 <8.5", + "php": ">=8.1 <8.5", "ext-ctype": "*", "ext-curl": "*", "ext-dom": "*", @@ -7126,7 +7049,7 @@ "ext-xmlreader": "*" }, "platform-overrides": { - "php": "7.4" + "php": "8.1" }, "plugin-api-version": "2.6.0" } diff --git a/lib/Varien/Io/Ftp.php b/lib/Varien/Io/Ftp.php index 4f128910fb7..24c613dd02a 100644 --- a/lib/Varien/Io/Ftp.php +++ b/lib/Varien/Io/Ftp.php @@ -40,7 +40,7 @@ class Varien_Io_Ftp extends Varien_Io_Abstract /** * An FTP connection * - * @var resource + * @var FTP\Connection|false */ protected $_conn; diff --git a/tests/unit/Mage/Catalog/Helper/Product/UrlTest.php b/tests/unit/Mage/Catalog/Helper/Product/UrlTest.php index 992482f4b53..6ea1ee24d9b 100644 --- a/tests/unit/Mage/Catalog/Helper/Product/UrlTest.php +++ b/tests/unit/Mage/Catalog/Helper/Product/UrlTest.php @@ -51,7 +51,7 @@ public function testGetConvertTable(): void public function testGetConvertTableCustom(): void { $result = $this->subject->getConvertTableCustom(); - $this->assertCount(0, $result); + $this->assertEmpty($result); } /** diff --git a/tests/unit/Mage/Catalog/Model/CategoryTest.php b/tests/unit/Mage/Catalog/Model/CategoryTest.php index 8735898b686..28ecb29f624 100644 --- a/tests/unit/Mage/Catalog/Model/CategoryTest.php +++ b/tests/unit/Mage/Catalog/Model/CategoryTest.php @@ -119,7 +119,7 @@ public function testGetUrlModel(): void * @group Mage_Catalog * @group Mage_Catalog_Model */ - public function testFormatUrlKey($expectedResult, ?string $locale): void + public function testFormatUrlKey($expectedResult, string $locale): void { $this->subject->setLocale($locale); $this->assertSame($expectedResult, $this->subject->formatUrlKey($this->getTestString())); diff --git a/tests/unit/Mage/Catalog/Model/ProductTest.php b/tests/unit/Mage/Catalog/Model/ProductTest.php index 5bc6d03b502..e0f088acc6d 100644 --- a/tests/unit/Mage/Catalog/Model/ProductTest.php +++ b/tests/unit/Mage/Catalog/Model/ProductTest.php @@ -166,7 +166,7 @@ public function testAfterCommitCallback(): void * @group Mage_Catalog * @group Mage_Catalog_Model */ - public function testFormatUrlKey($expectedResult, ?string $locale): void + public function testFormatUrlKey($expectedResult, string $locale): void { $this->subject->setLocale($locale); $this->assertSame($expectedResult, $this->subject->formatUrlKey($this->getTestString())); diff --git a/tests/unit/Mage/Catalog/Model/UrlTest.php b/tests/unit/Mage/Catalog/Model/UrlTest.php index cba60ca6dae..305b6a2dabc 100644 --- a/tests/unit/Mage/Catalog/Model/UrlTest.php +++ b/tests/unit/Mage/Catalog/Model/UrlTest.php @@ -129,7 +129,7 @@ public function provideGeneratePathData(): Generator * @group Mage_Catalog * @group Mage_Catalog_Model */ - public function testFormatUrlKey($expectedResult, ?string $locale): void + public function testFormatUrlKey($expectedResult, string $locale): void { $this->subject->setLocale($locale); $this->assertSame($expectedResult, $this->subject->formatUrlKey($this->getTestString())); @@ -140,10 +140,10 @@ public function testFormatUrlKey($expectedResult, ?string $locale): void * @group Mage_Catalog_Model * @doesNotPerformAssertions */ - public function testGetSlugger(): void - { - $this->subject->getSlugger(); - } + // public function testGetSlugger(): void + // { + // $this->subject->getSlugger(); + // } /** * @dataProvider provideGetSluggerConfig diff --git a/tests/unit/Mage/Core/Helper/EnvironmentConfigLoaderTest.php b/tests/unit/Mage/Core/Helper/EnvironmentConfigLoaderTest.php index d0cb54d4ba2..cfb4c1b4ac3 100644 --- a/tests/unit/Mage/Core/Helper/EnvironmentConfigLoaderTest.php +++ b/tests/unit/Mage/Core/Helper/EnvironmentConfigLoaderTest.php @@ -222,7 +222,7 @@ public function testEnvDoesNotOverrideForInvalidConfigKeys(array $config): void } // assert - $this->assertFalse(str_contains('value_will_not_be_changed', (string) $valueAfterCheck), 'Default value was wrongfully overridden.'); + $this->assertStringNotContainsString((string) $valueAfterCheck, 'value_will_not_be_changed', 'Default value was wrongfully overridden.'); } public function envDoesNotOverrideOnWrongConfigKeysDataProvider(): Generator diff --git a/tests/unit/Mage/Reports/Model/Resource/Report/CollectionTest.php b/tests/unit/Mage/Reports/Model/Resource/Report/CollectionTest.php index 37d842f74d9..2d57109d708 100644 --- a/tests/unit/Mage/Reports/Model/Resource/Report/CollectionTest.php +++ b/tests/unit/Mage/Reports/Model/Resource/Report/CollectionTest.php @@ -143,8 +143,7 @@ public function testInitReport($modelClass = ''): void public function testGetReportFull(): void { $this->markTestIncomplete(self::SKIP_INCOMPLETE_MESSAGE); - // @phpstan-ignore-next-line - $this->assertInstanceOf(Mage_Reports_Model_Report::class, $this->subject->getReportFull(1, 1)); + # $this->assertInstanceOf(Mage_Reports_Model_Report::class, $this->subject->getReportFull(1, 1)); } /** @@ -154,8 +153,7 @@ public function testGetReportFull(): void public function testGetReport(): void { $this->markTestIncomplete(self::SKIP_INCOMPLETE_MESSAGE); - // @phpstan-ignore-next-line - $this->assertInstanceOf(Mage_Reports_Model_Report::class, $this->subject->getReport(1, 1)); + # $this->assertInstanceOf(Mage_Reports_Model_Report::class, $this->subject->getReport(1, 1)); } /** @@ -165,7 +163,6 @@ public function testGetReport(): void public function testTimeShift(): void { $this->markTestIncomplete(self::SKIP_INCOMPLETE_MESSAGE); - // @phpstan-ignore-next-line - $this->assertSame($this->subject->timeShift('')); + # $this->assertSame($this->subject->timeShift('')); } } diff --git a/tests/unit/Traits/DataProvider/Mage/Catalog/CatalogTrait.php b/tests/unit/Traits/DataProvider/Mage/Catalog/CatalogTrait.php index 0c9ad67bd6e..939c93d4c86 100644 --- a/tests/unit/Traits/DataProvider/Mage/Catalog/CatalogTrait.php +++ b/tests/unit/Traits/DataProvider/Mage/Catalog/CatalogTrait.php @@ -25,10 +25,6 @@ trait CatalogTrait public function provideFormatUrlKey(): Generator { - yield 'null locale' => [ - 'a-b-x-a-o-u-tm', - null, - ]; yield 'de_DE' => [ 'a-und-b-x-prozent-at-ae-oe-ue-tm', 'de_DE',