Merge branch 'cs/#6948-improve-hydrator-type-hints'

Close #6948
use hydrator variable only when hydrator variable is assigned
added testcase and reverted changes and prevent the php notice
#6949 - explicit `setExpectedException` usage
#6949 - adding missing `@group` annotation for newly introduced tests in this PR
#6949 - minor CS fixes (spacing)
Merge branch 'hotfix/#6949-form-factory-undefined-hydrator' into develop

Close #6949
Forward port #6949