xsd2php
xsd2php copied to clipboard
PHP7 Typehinting support
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?
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?
- Just noticed that zend-code now supports php7 scalar typehinting in v3: https://github.com/zendframework/zend-code/pull/30
- Scalar typehinting would break with
toString()I think. I'll check and update again. - Agree on it being configurable as an option.
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...
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.