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

[Backport] Adding support for variadic arguments' method in generated proxy c… #31

Merged
merged 13 commits into from
Jun 13, 2018

Conversation

gelanivishal
Copy link
Owner

Original Pull Request

magento#15177
Proxy for class with variadic argument method

Pull request fixes proxy class generation, so class with method with variadic arguments can be also used in proxy class.

Description

In Magento/Framework/ObjectManager/Code/Generator/Proxy (lines 158, 159) I added check if parameter is variadic and if so its name is suffixed by '...', so then in method _getMethodBody() proxy method body is generated properly.

Fixed Issues (if relevant)

Extends fixes from magento@27065cf

Manual testing scenarios

  1. Create class, containing method, which as last argument takes variadic argument.
  2. Declare in di.xml proxy for this class.
  3. Let Magento generate it.
  4. Test if using class is possible and there are no errors. Moreover check manually content of generated proxy in /generated/code.

I was trying to extend unit test for modified class (Magento\Framework\ObjectManager\Test\Unit\Code\Generator), so it also would generate and test class with method with variadic argument, but with no success. Test broke on (mocked) method - generateResultFileName(). Actually, I only tried to edit fixtures files for test, not test itself:

Magento\Framework\ObjectManager\Code\Generator\Sample, adding method like:

/**
     * @param int $int
     * @param Sample[] ...$samples
     * @return int
     */
    public function takeVariadicObjectArguments(int $int, Sample ...$samples) : int
    {
        return (int) count($samples);
    }

And Magento\Framework\ObjectManager\Code\Generator\Sample_Proxy.txt, adding generated method like this:

/**
     * {@inheritdoc}
     */
    public function takeVariadicObjectArguments(int $int, \Magento\Framework\ObjectManager\Code\Generator\Sample ... $samples) : int
    {
        return $this->_getSubject()->takeVariadicObjectArguments($int, ... $samples);
    }

Maybe someone else would be able to extend unit test for this class. If we don't change anything in case of unit tests, test is green.

rogyar and others added 13 commits June 7, 2018 14:12
…agento#15933

 - Merge Pull Request magento#15933 from rogyar/magento2:2.1-empty-anchors-fix
 - Merged commits:
   1. 4caef44
Accepted Public Pull Requests:
 - magento#15933: Do not display anchor if admin submenu has no children (by @rogyar)
…inition does not requir… magento#15949

 - Merge Pull Request magento#15949 from saurabh-aureate/magento2:2.1-develop-PR-port-15891
 - Merged commits:
   1. 063840f
…chCriteria - added zero … magento#15945

 - Merge Pull Request magento#15945 from vgelani/magento2:2.1-develop-PR-port-15322
 - Merged commits:
   1. f3108a3
…rnal\Magento\Framework\D… magento#15943

 - Merge Pull Request magento#15943 from vgelani/magento2:2.1-develop-PR-port-15892
 - Merged commits:
   1. 63ebb61
   2. 3c58390
Accepted Public Pull Requests:
 - magento#15943: [Backport] Wrong annotation in _toOptionArray : lib\internal\Magento\Framework\D� (by @vgelani)
 - magento#15945: [Backport] ISSUE-11477 - fixed Swagger response for searchCriteria - added zero � (by @vgelani)
 - magento#15949: [Backport]No need to pass method parameter as method definition does not requir� (by @saurabh-aureate)


Fixed GitHub Issues:
 - magento#11477: Magento REST API Schema (Swagger) is not compatible with Search Criteria (reported by @careys7) has been fixed in magento#15945 by @vgelani in 2.1-develop branch
   Related commits:
     1. f3108a3
@gelanivishal gelanivishal merged commit 4fce90c into 2.1-develop Jun 13, 2018
@gelanivishal gelanivishal deleted the 2.1-develop-PR-port-15177 branch June 15, 2018 15:26
@gelanivishal gelanivishal restored the 2.1-develop-PR-port-15177 branch June 15, 2018 15:26
gelanivishal pushed a commit that referenced this pull request Oct 17, 2018
 - Merge Pull Request magento/bulk-api-ce#31 from magento/bulk-api-ce:async-delete
 - Merged commits:
   1. 069aa1c
   2. 694d219
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.

3 participants