xsd2php
xsd2php copied to clipboard
Add nullable strict types for native and simple arguments
Just wanted to discuss this with you.. I have had a fork of this repo for a long time, with below addition. It forces strict types for scalar and simple arguments, which is way cleaner for my static analyser etc. I did, however, add a nullable default type for all values, as I don't know exactly how to determine if a value should be nullable or not.
What do you think about this? Have you tried to add strict types before or do you still want to be BC with php < 7?
hmm, this is not a bad idea TBH. it requires php 7 (but nowadays everyone should be on php7).
regarding the NULL option, it makes sense too. for some cases it should possible to detect if NULL is allowed but IMO is not particularly worth. the only possible improvements i could have in mind is to make this an opt-in feature via some config parameter
You mean something like this? I don't have time to dive into the tests right now, but it's a start.
@rvdbogerd yea, that was the idea
Apologies for the late answer, if you are still working on this, i'm happy to continue reviewing it
@rvdbogerd this looks good to me. is it ready? if yes, i can merge it right away
@rvdbogerd this looks good to me. is it ready? if yes, i can merge it right away
Yes, please do! I've been running it in production for years, so should be working :)
Hi @goetas! Could you merge this please?
looks good, thanks!
sorry for the dumb question but how to enable strict types in configuration?
sorry for the dumb question but how to enable strict types in configuration?
You can initialize the ClassGenerator like this:
$generator = new ClassGenerator(true);