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

Fix phpdoc for saveAttribute() #2320

Merged
merged 1 commit into from
Jul 16, 2022

Conversation

Caprico85
Copy link
Contributor

Description (*)

saveAttribute() in Mage_Sales_Model_Resource_Order_Abstract only specifies string as type for $attribute. As you can see a few lines later, it also takes string arrays.

public function saveAttribute(Mage_Core_Model_Abstract $object, $attribute)
{
    if ($attribute instanceof Mage_Eav_Model_Entity_Attribute_Abstract) {
        $attribute = $attribute->getAttributeCode();
    }

    if (is_string($attribute)) {
        $attribute = array($attribute);
    }

    if (is_array($attribute) && !empty($attribute)) {                    // <-- see the is_array() here
        $this->beginTransaction();

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 the Component: Sales Relates to Mage_Sales label Jul 15, 2022
@elidrissidev
Copy link
Member

This change also happens to solve a phpstan error that was previously ignored so we need to remove it from the baseline file below:

-
message: "#^Variable \\$attribute in empty\\(\\) always exists and is not falsy\\.$#"
count: 1
path: ../app/code/core/Mage/Sales/Model/Resource/Order/Abstract.php

@Caprico85
Copy link
Contributor Author

You're right. I updated my PR to include Mage_Eav_Model_Entity_Attribute_Abstract as additional type and remove the phpstan ignore.

@elidrissidev elidrissidev merged commit 31c8018 into OpenMage:1.9.4.x Jul 16, 2022
@github-actions
Copy link
Contributor

Unit Test Results

1 files  ±0  1 suites  ±0   0s ⏱️ ±0s
0 tests ±0  0 ✔️ ±0  0 💤 ±0  0 ❌ ±0 
7 runs  ±0  5 ✔️ ±0  2 💤 ±0  0 ❌ ±0 

Results for commit 31c8018. ± Comparison against base commit 0d99717.

elidrissidev pushed a commit to elidrissidev/magento-lts that referenced this pull request Jul 22, 2022
@Caprico85 Caprico85 deleted the saveAttribute-phpdoc branch May 28, 2024 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Sales Relates to Mage_Sales environment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants