Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Type casting and minor fixes in preparation for declare strict_types=1 #3648

Merged
merged 15 commits into from
May 6, 2024
Merged

Type casting and minor fixes in preparation for declare strict_types=1 #3648

merged 15 commits into from
May 6, 2024

Conversation

luigifab
Copy link
Contributor

@luigifab luigifab commented Nov 12, 2023

Description

This PR allow to add <?php declare(strict_types=1); in all files of OpenMage (@sreichel in #3647). This is only the beginning.

To add it in all files, run find app/ shell/ lib/Mage/ lib/Magento/ lib/Varien/ -name "*.ph*" -type f -exec sed -i '1s/<?php/<?php declare(strict_types=1);/' {} +

Apply this PR and enjoy backend.

To cancel changes: find app/ shell/ lib/Mage/ lib/Magento/ lib/Varien/ -name "*.ph*" -type f -exec sed -i '1s/<?php declare(strict_types=1);/<?php/' {} +

OpenMage 20.2.0, PHP 7.2 / 8.3.

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All automated tests passed successfully (all builds are green)
  • Add yourself to contributors list

@github-actions github-actions bot added Component: Core Relates to Mage_Core Component: Catalog Relates to Mage_Catalog Component: Cms Relates to Mage_Cms Component: lib/Varien Relates to lib/Varien Component: Customer Relates to Mage_Customer Component: Eav Relates to Mage_Eav Template : rwd Relates to rwd template Component: Adminhtml Relates to Mage_Adminhtml Mage.php Relates to app/Mage.php Component: lib/* Relates to lib/* labels Nov 12, 2023
@Flyingmana
Copy link
Contributor

you need to be very careful with this, there are several situations where it changes the behavior of the code

@luigifab
Copy link
Contributor Author

Yes, I'm not sure to understand all possible impacts, but, for localhost it looks good!
And, with them, I found some critical fails of the life!

@sreichel
Copy link
Contributor

there are several situations where it changes the behavior of the code

I did not see any changes in code behavoir during my tests. (not finished, but 80%) Either it works, or you see a fatal error. I think its not that hard to add strict types, its just a lot of work and manual testing. (unit tests would be nice here)

@luigifab luigifab marked this pull request as ready for review November 30, 2023 18:07
@luigifab
Copy link
Contributor Author

Looks good, perhaps extract enhancement for error message in another PR, and add Mage::logException().
Else we can close it.

fballiano
fballiano previously approved these changes Feb 6, 2024
Copy link
Contributor

@fballiano fballiano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've read all the changes and, although some of them don't seem related to the PR to me (adding details on log exception) I think they could be merged, especially because this PR is not enforcing the strict_types, but it's only preparation work.

@fballiano
Copy link
Contributor

Agree with @kiatng, to speed things up I've removed from this PR the code that was not related to the strict_types thing.

Co-authored-by: Ng Kiat Siong <kiatsiong.ng@gmail.com>
app/code/core/Mage/Customer/Model/Address/Config.php Outdated Show resolved Hide resolved
@fballiano
Copy link
Contributor

There's only one point open to fix for this PR.

@fballiano fballiano dismissed ADDISON74’s stale review May 2, 2024 21:25

it was solved ;-)

@fballiano fballiano changed the title Prepare declare strict_types=1 Type casting and minor fixes in preparation for declare strict_types=1` May 3, 2024
@fballiano fballiano changed the title Type casting and minor fixes in preparation for declare strict_types=1` Type casting and minor fixes in preparation for declare strict_types=1 May 4, 2024
@fballiano fballiano requested a review from kiatng May 5, 2024 13:09
@fballiano
Copy link
Contributor

since all the comments and subsequent modification, I think this is mergeable

@fballiano fballiano merged commit b98ed7a into OpenMage:main May 6, 2024
17 checks passed
@luigifab luigifab deleted the strict1 branch May 6, 2024 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Adminhtml Relates to Mage_Adminhtml Component: Catalog Relates to Mage_Catalog Component: Cms Relates to Mage_Cms Component: Core Relates to Mage_Core Component: Customer Relates to Mage_Customer Component: Eav Relates to Mage_Eav Component: lib/Varien Relates to lib/Varien Component: lib/* Relates to lib/* Mage.php Relates to app/Mage.php Template : rwd Relates to rwd template
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants