Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Feb 23, 2023. It is now read-only.

Conversation

red-led
Copy link
Contributor

@red-led red-led commented Jan 16, 2016

Hi!
I had some free time today and started work on #58. #6 was created almost 5 years ago! : )

First of all about choosing lib:

  • ZendCode has all functionality, we need
  • TwigGenerator really looks more like simple templating
  • Using Ocramius/CodeGenerationUtils looks like overkill and it is still in alpha.

Secondly, this is work-in-progress PR. Code will be squashed/rebased after all. But I will really appreciate comments on this code, including even code style : )

@red-led
Copy link
Contributor Author

red-led commented Jan 16, 2016

ZendCode reqires "php": "^5.5 || ^7.0". So for using it we need to drop php 5.3 and php 5.4 support.

@red-led red-led changed the title First draft of useng ZendCode for codegeneration Useng ZendCode for codegeneration Jan 16, 2016
@red-led
Copy link
Contributor Author

red-led commented Jan 17, 2016

Tests are ok now, but output is not same. Some type hints were added. For example:

3.3.1:

    /**
     * @param Author $author
     * @return Author
     */
    public function echoLiteral(Author $author)
    {
      return $this->__soapCall('echoLiteral', array($author));
    }

PR:

    /**
     * @param Author $author
     * @return Author
     */
    public function echoLiteral($author)
    {
      return $this->__soapCall('echoLiteral', array($author));
    }

If somebody can test this on his code, it would be great! I have feeling, that we need lot more tests...

@red-led red-led changed the title Useng ZendCode for codegeneration Using ZendCode for codegeneration Jan 17, 2016
@kasperg
Copy link
Member

kasperg commented Jan 25, 2016

This looks awesome @red-led! I look forward to dig into this.

A couple of quick comments for now:

  • Updating to PHP >5.5 is OK. People should be upgrading by now anyway.
  • Regarding type hints I think that should be doable using ParameterGenerator.
  • We may end up in a situation where the output is not 100% the same. I am cool with that. I believe a proper code generation library provides a proper base going forward.

With that in mind this could be the basis for a new 4.x release (which would also include #245)

@red-led
Copy link
Contributor Author

red-led commented Jan 28, 2016

@kasperg: I think it's finally ready for your review! : )


use Zend\Code\Generator\DocBlock\Tag\ParamTag;

class VarTag extends ParamTag
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really sure this should be here. But there are multiple (ok, just two:) uses of this and I thought its better to have this, than not.

Copy link
Member

Choose a reason for hiding this comment

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

Have you considered submitting this as a pull request to zendframework/zend-code instead of having it as a custom class here?

);

self::addMethodParameter($setter, $name, $type, $typeHint, $nullable && !empty($typeHint));
$setter->getDocBlock()->setTag(new ReturnTag($this->phpNamespacedIdentifier));
Copy link
Member

Choose a reason for hiding this comment

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

Could we move this up around L268 along with the rest of the setters?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, but @return tag will be before all @param's. Not so important, but looks little dirty.

@kasperg
Copy link
Member

kasperg commented Feb 9, 2016

@red-led: I started going through the refactoring but I do not have the time to finish it now. I will return to this later.

@kasperg
Copy link
Member

kasperg commented Feb 24, 2016

With the latest comment in I consider this ready for merging. Thanks for all your work @red-led.

I will try to get this in and we can release 4.0 after #254 lands.

@red-led
Copy link
Contributor Author

red-led commented Feb 24, 2016

Thanks for review, @kasperg! Shold I squash all these commits?

@kasperg
Copy link
Member

kasperg commented Feb 26, 2016

@red-led: You are welcome to do so.

Bear in mind that there might land other changes in the master branch before we merge this so this might require further updates. I will try to help out with this. You have done a lot of work for this already.

red-led and others added 24 commits November 24, 2016 18:34
The maintains the coding style across the class.
These can be simplified to use the addMethodParameter method.

Refactor parent constructor calling.
The generate method is ment for method declaration - not method calling.
This results in invalid code when we use the returned ParameterGenerator
which may have the default null value set.
It is already generated when adding the parameter to the method.
This enforces the chainable code style of the class.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants