Make sure a datetime instance is valid to avoid fatal errors.
Fix types in docblocks.
Don't do assignments inside conditionals.
Merge pull request #2869 from jalbertocr/master

FormHelper - Check DateTime instances to avoid fatal errors