Skip to content

Fixes some code that you'd expect to crash if left in its current state.#41

Open
hostep wants to merge 1 commit intoPayU-EMEA:masterfrom
baldwin-agency:fixes-some-code-that-youd-expect-to-crash-if-left-like-this
Open

Fixes some code that you'd expect to crash if left in its current state.#41
hostep wants to merge 1 commit intoPayU-EMEA:masterfrom
baldwin-agency:fixes-some-code-that-youd-expect-to-crash-if-left-like-this

Conversation

@hostep
Copy link

@hostep hostep commented Sep 17, 2025

We are strongly considering to use this module for a client of ours, usually I run some quick code analysis test (using phpstan and phpcompatibility checker for example) on a module to see if the module is in a good shape or not.

And phpstan found quite some disturbing issues. So here's a PR to fix some of those. I'm not sure if this code actually is being called, but I would expect some of this code to crash if this doesn't get fixed.

Disclaimer: I only changed the code to my best knowledge but didn't test any of this, so please double check all changes and test it to see if it works as expected.

The phpstan errors fixed here are:

 ------ ----------------------------------------------------------------------------------------------------------
  Line   Block/Order/Repay/PaymentMethods.php
 ------ ----------------------------------------------------------------------------------------------------------
  107    Access to an undefined property PayU\PaymentGateway\Block\Order\Repay\PaymentMethods::$secureFormConfig.
         🪪  property.notFound
         💡  Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property
  163    Access to an undefined property PayU\PaymentGateway\Block\Order\Repay\PaymentMethods::$secureFormConfig.
         🪪  property.notFound
         💡  Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property
  170    Access to an undefined property PayU\PaymentGateway\Block\Order\Repay\PaymentMethods::$secureFormConfig.
         🪪  property.notFound
         💡  Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property
 ------ ----------------------------------------------------------------------------------------------------------

 ------ ---------------------------------------------------------------------------------------------------
  Line   Controller/Data/GetPostPlaceOrderData.php
 ------ ---------------------------------------------------------------------------------------------------
  52     Access to an undefined property PayU\PaymentGateway\Controller\Data\GetPostPlaceOrderData::$_url.
         🪪  property.notFound
         💡  Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property
  57     Access to an undefined property PayU\PaymentGateway\Controller\Data\GetPostPlaceOrderData::$_url.
         🪪  property.notFound
         💡  Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property
 ------ ---------------------------------------------------------------------------------------------------

 ------ ------------------------------------------------------------------------------------
  Line   Model/Logger/Logger.php
 ------ ------------------------------------------------------------------------------------
  11     Class PayU\PaymentGateway\Model\Logger\Logger extends @final class Monolog\Logger.
         🪪  class.extendsFinalByPhpDoc
 ------ ------------------------------------------------------------------------------------

 ------ ---------------------------------------------------------------------------------------
  Line   lib/OpenPayU/Result.php
 ------ ---------------------------------------------------------------------------------------
  204    Access to an undefined property OpenPayU_Result::$name.
         🪪  property.notFound
         💡  Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property
 ------ ---------------------------------------------------------------------------------------

I think most of these don't need further explanation, but these 2 are probably good to explain:

  • in the GetPostPlaceOrderData controller, the extra $url private member is needed after the change in 0d883fa, where inheritance was changed from Magento\Framework\App\Action\Action to Magento\Framework\App\Action\HttpGetActionInterface, that change looses the protected $_url member, so I'm adding it back here
  • with the latest Magento version 2.4.8, the monolog/monolog package got upgraded to v3 and that marks that class as final so try to encourage people not to extend from it, so I extended it from Magento\Framework\Logger\Monolog instead (yes this is hypocritical, since that class also in its turn extends from the Monolog\Logger class, but at least the phpstan warning is gone now), if you disagree with this change, I understand and I can remove it again

Other then these errors I fixed, phpstan also found this, which I didn't fix, best is probably to check this yourself, in theory this code can't work without crashes, so maybe this code isn't being used anymore and can be removed?

 ------ ---------------------------------------------------------------------------------------------------------
  Line   Model/RepayOrderResolverAbstract.php
 ------ ---------------------------------------------------------------------------------------------------------
  57     Access to an undefined property PayU\PaymentGateway\Model\RepayOrderResolverAbstract::$customerSession.
         🪪  property.notFound
         💡  Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property
  58     Access to an undefined property PayU\PaymentGateway\Model\RepayOrderResolverAbstract::$urlBuilder.
         🪪  property.notFound
         💡  Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property
  64     Access to an undefined property PayU\PaymentGateway\Model\RepayOrderResolverAbstract::$urlBuilder.
         🪪  property.notFound
         💡  Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property
 ------ ---------------------------------------------------------------------------------------------------------

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant