[wp-trac] [WordPress Trac] #53946: Improve return types for sanitizing/escaping functions

WordPress Trac noreply at wordpress.org
Thu Aug 19 09:27:34 UTC 2021


#53946: Improve return types for sanitizing/escaping functions
-------------------------+------------------------------
 Reporter:  malthert     |       Owner:  (none)
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Security     |     Version:
 Severity:  normal       |  Resolution:
 Keywords:               |     Focuses:  docs
-------------------------+------------------------------
Changes (by johnbillion):

 * keywords:  reporter-feedback =>


Comment:

 Thanks for the link!

 This syntax appears to be [https://psalm.dev/articles/conditional-love
 specific to Psalm] and it [https://phpstan.org/r/027716b7-052d-
 4e01-a9e3-b1d79771edf3 isn't supported by PHPStan] (although it's
 [https://github.com/phpstan/phpstan/issues/3853 on the roadmap]),
 [https://docs.phpdoc.org/latest/guide/references/phpdoc/tags/return.html
 nor is it supported by phpDocumentor], so I'm inclined to say that as much
 as it would be great to have machine-readable conditional return types I
 don't think we should introduce a syntax which breaks existing tooling
 that isn't Psalm.

 We could use the Psalm-specific `@psalm-return` tag but that would imply
 some level of support for Psalm in core which there isn't. There's some
 discussion on whether we should introduce PHPStan-specific syntax and
 configuration in #52217 and the same would apply to Psalm.

 I think this is a wontfix, unfortunately, but I would welcome a patch
 which improves the descriptions of these functions in order to better
 explain the possible return types.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/53946#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list