Skip to content

Commit 40e3a5d

Browse files
committed
[PHPStan]: typehint esc_* functions
1 parent 72677bc commit 40e3a5d

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

src/wp-includes/formatting.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -938,6 +938,8 @@ function seems_utf8( $str ) {
938938
* @param false|string $charset Optional. The character encoding of the string. Default false.
939939
* @param bool $double_encode Optional. Whether to encode existing HTML entities. Default false.
940940
* @return string The encoded text with HTML entities.
941+
*
942+
* @phpstan-param scalar $text
941943
*/
942944
function _wp_specialchars( $text, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false ) {
943945
$text = (string) $text;
@@ -1008,6 +1010,8 @@ function _wp_specialchars( $text, $quote_style = ENT_NOQUOTES, $charset = false,
10081010
* double if set to 'double' or both if otherwise set.
10091011
* Default is ENT_NOQUOTES.
10101012
* @return string The decoded text without HTML entities.
1013+
*
1014+
* @phpstan-param scalar $text
10111015
*/
10121016
function wp_specialchars_decode( $text, $quote_style = ENT_NOQUOTES ) {
10131017
$text = (string) $text;
@@ -1091,6 +1095,8 @@ function wp_specialchars_decode( $text, $quote_style = ENT_NOQUOTES ) {
10911095
* @param string $text The text which is to be checked.
10921096
* @param bool $strip Optional. Whether to attempt to strip out invalid UTF8. Default false.
10931097
* @return string The checked text.
1098+
*
1099+
* @phpstan-param scalar $text
10941100
*/
10951101
function wp_check_invalid_utf8( $text, $strip = false ) {
10961102
$text = (string) $text;
@@ -4656,6 +4662,8 @@ function htmlentities2( $text ) {
46564662
*
46574663
* @param string $text The text to be escaped.
46584664
* @return string Escaped text.
4665+
*
4666+
* @phpstan-param scalar $text
46594667
*/
46604668
function esc_js( $text ) {
46614669
$safe_text = wp_check_invalid_utf8( $text );
@@ -4684,6 +4692,8 @@ function esc_js( $text ) {
46844692
*
46854693
* @param string $text
46864694
* @return string
4695+
*
4696+
* @phpstan-param scalar $text
46874697
*/
46884698
function esc_html( $text ) {
46894699
$safe_text = wp_check_invalid_utf8( $text );
@@ -4707,8 +4717,10 @@ function esc_html( $text ) {
47074717
*
47084718
* @since 2.8.0
47094719
*
4710-
* @param string $text
4720+
* @param string $text . Non-string values will be cast to string.
47114721
* @return string
4722+
*
4723+
* @phpstan-param scalar $text
47124724
*/
47134725
function esc_attr( $text ) {
47144726
$safe_text = wp_check_invalid_utf8( $text );
@@ -4723,6 +4735,8 @@ function esc_attr( $text ) {
47234735
*
47244736
* @param string $safe_text The text after it has been escaped.
47254737
* @param string $text The text prior to being escaped.
4738+
*
4739+
* @phpstan-param scalar $text
47264740
*/
47274741
return apply_filters( 'attribute_escape', $safe_text, $text );
47284742
}
@@ -4755,6 +4769,8 @@ function esc_textarea( $text ) {
47554769
*
47564770
* @param string $text Text to escape.
47574771
* @return string Escaped text.
4772+
*
4773+
* @phpstan-param scalar $text
47584774
*/
47594775
function esc_xml( $text ) {
47604776
$safe_text = wp_check_invalid_utf8( $text );

0 commit comments

Comments
 (0)