Skip to content

Conversation

@ProkopovVitaliy
Copy link
Contributor

Description (*)

Fixed deprecated getClass() reflection method according to php update notes.

Related Pull Requests

Fixed Issues (if relevant)

  1. Fixes PHP 8: Deprecated Functionality: Method ReflectionParameter::getClass() is deprecated in /lib/internal/Magento/Framework/Code/Reader/ClassReader.php on line 34 #31600

Manual testing scenarios (*)

  1. Enable php 8
  2. composer install
  3. Try to install magento by "sudo php bin/magento setup:install"

Questions or comments

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

@m2-assistant
Copy link

m2-assistant bot commented Jan 27, 2021

Hi @ProkopovVitaliy. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me php8-develop instance - deploy vanilla Magento instance

❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names. Allowed build names are:

  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE,
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here

ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review.

For more details, please, review the Magento Contributor Guide documentation.

⚠️ According to the Magento Contribution requirements, all Pull Requests must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.

🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@ProkopovVitaliy
Copy link
Contributor Author

ProkopovVitaliy commented Jan 27, 2021

@coderimus @sivaschenko unfortunately i can't test my fix because we have a lot of modules that outdated relatively php8.
When i run composer install i get errors:

Screenshot 2021-01-27 at 13 58 53

@coderimus
Copy link
Contributor

@sivaschenko can you please, review provided solution for the deprecated functionality replacement?Reflection depricated funcitonality: https://php.watch/versions/8.0/deprecated-reflectionparameter-methods

@coderimus coderimus added the Partner: Atwix Pull Request is created by partner Atwix label Feb 1, 2021
Copy link
Member

@sivaschenko sivaschenko left a comment

Choose a reason for hiding this comment

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

Thanks for the fix @ProkopovVitaliy ! Please see my comments.

It's ok to test the fix on PHP 7.4 for now (the approach itself can be tested in isolation separately from Magento framework on PHP 8)
Also, the method is covered with \Magento\Framework\Code\Test\Unit\Reader\ClassReaderTest::testGetConstructor

@ProkopovVitaliy
Copy link
Contributor Author

ProkopovVitaliy commented Feb 2, 2021

@sivaschenko Hi, i found 10 classes where are using deprecated getClass() method and changed on actually alternative.
For some classes there are unit tests so i was running there all separately from each other.

All of them successfully finished.

Class - lib/internal/Magento/Framework/Code/Reader/ArgumentsReader.php
Test class - lib/internal/Magento/Framework/Code/Test/Unit/Reader/ArgumentsReaderTest.php
Screenshot 2021-02-02 at 14 21 56

Class - lib/internal/Magento/Framework/Code/Generator/EntityAbstract.php
Test class - lib/internal/Magento/Framework/Code/Test/Unit/Generator/EntityAbstractTest.php
Screenshot 2021-02-02 at 14 22 26

Class - lib/internal/Magento/Framework/Code/Reader/ClassReader.php
Test class - lib/internal/Magento/Framework/Code/Test/Unit/Reader/ClassReaderTest.php
Screenshot 2021-02-02 at 14 22 38

Class - lib/internal/Magento/Framework/Interception/Code/InterfaceValidator.php
Test class - lib/internal/Magento/Framework/Interception/Test/Unit/Code/InterfaceValidatorTest.php
Screenshot 2021-02-02 at 14 24 29

@sivaschenko also i found other deprecated functions isArray() and isCallable().
isArray() - 6 usages and isCallable()- 1 usages.
What about those functions ? Will you open new issues and assign to me ?

Thanks!

@coderimus coderimus added the Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests label Feb 8, 2021
@coderimus
Copy link
Contributor

Hello @sivaschenko
According to the previous comment seems we need to have a separate task for make mentioned classes compatible with the PHP 8. What do you think?

@sivaschenko
Copy link
Member

Hi @ProkopovVitaliy @coderimus , yes, please create a new issue for these

Copy link
Member

@sivaschenko sivaschenko left a comment

Choose a reason for hiding this comment

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

Thanks for the updates @ProkopovVitaliy ! Please see my comments

@sivaschenko
Copy link
Member

@magento run all tests

@ProkopovVitaliy
Copy link
Contributor Author

@magento run Unit Tests, Functional Tests CE, Functional Tests B2B

@m2-assistant
Copy link

m2-assistant bot commented Mar 5, 2021

Hi @ProkopovVitaliy, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

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

Labels

Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests Partner: Atwix Pull Request is created by partner Atwix Progress: ready for testing Project: PHP8

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants