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

PHP7 Typehinting support #8

Open
captn3m0 opened this issue Nov 16, 2016 · 4 comments
Open

PHP7 Typehinting support #8

captn3m0 opened this issue Nov 16, 2016 · 4 comments

Comments

@captn3m0
Copy link

For something like:

<?php
/**
     * Sets a new verifiedName
     *
     * @param string $verifiedName
     * @return self
     */
    public function setVerifiedName($verifiedName)
    {
        $this->verifiedName = $verifiedName;
        return $this;
    }

Makes sense to use php7 scalar typehints here. Could be hidden behind a flag in config.yml. I'll try to work on a PR if this sounds helpful?

@goetas
Copy link
Member

goetas commented Nov 16, 2016

Hi, tanks for the suggestion.
The feature proposal looks nice. Currently there are some issues with it:

  • i'm not sure that the 2.x version of the zend code generator supports scalar type hinting
    -- (of course i will be happy to upgrade it)
  • im not sure how php will behave with objects having the "toString" method. in many places, objects are use as value objects to represent strings
  • of course this should be a configurable option for those that do not have php 7

What are your opinions?

@captn3m0
Copy link
Author

  1. Just noticed that zend-code now supports php7 scalar typehinting in v3: [3.0] #29 - PHP7 compliance zendframework/zend-code#30
  2. Scalar typehinting would break with toString() I think. I'll check and update again.
  3. Agree on it being configurable as an option.

@goetas
Copy link
Member

goetas commented Dec 23, 2016

I agree for all your points.

toString can be easily fixed doing some string casting inside.

I'm only worried for the works that needs to be done to port the code to use zend-code v3...

@allcode
Copy link
Contributor

allcode commented Nov 14, 2017

In the last few days, I've had to modify this project to use zend-code 3.3 and generate classes with PHP7.1 parameter and return types for a project I'm working on.

The amount of work to update this project to use zend-code v3 is quite little (see commit).

I've sadly not yet had time to convert my changes into bite-sized pull requests. You might want to have a look at the commits to see whether any of the changes are interesting for this project, so I can perhaps extract them to PRs later on.

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

No branches or pull requests

3 participants