[Validator] Fixed: The state of the XML/YAML loaders was changed even if an exception was thrown upon loading

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #12158
| License       | MIT
| Doc PR        | -
Then, it would be a matter of improving Sami instead rather than forcing to put obvious phpdoc IMO. Improving the generator is better than asking for devs to do more work (which then needs to be maintained when changes are done)