From 793ff43de9b8b275947f0beac5f5ab6903731268 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 25 Jul 2025 16:37:19 +0200 Subject: [PATCH] NamingConventions/ValidPostTypeSlug: check token via code, not type The `'type'` index in the token array should generally only be used for PHPCS cross-version compatibility, where the token constant we are looking for may not be defined in all supported PHPCS versions. That's not the case for these. --- WordPress/Sniffs/NamingConventions/ValidPostTypeSlugSniff.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WordPress/Sniffs/NamingConventions/ValidPostTypeSlugSniff.php b/WordPress/Sniffs/NamingConventions/ValidPostTypeSlugSniff.php index 15d58edf9d..67c90225a4 100644 --- a/WordPress/Sniffs/NamingConventions/ValidPostTypeSlugSniff.php +++ b/WordPress/Sniffs/NamingConventions/ValidPostTypeSlugSniff.php @@ -172,8 +172,8 @@ public function process_parameters( $stackPtr, $group_name, $matched_content, $p ); // Warn for dynamic parts in the slug parameter. - if ( 'T_DOUBLE_QUOTED_STRING' === $this->tokens[ $string_pos ]['type'] - || ( 'T_HEREDOC' === $this->tokens[ $string_pos ]['type'] + if ( \T_DOUBLE_QUOTED_STRING === $this->tokens[ $string_pos ]['code'] + || ( \T_HEREDOC === $this->tokens[ $string_pos ]['code'] && strpos( $this->tokens[ $string_pos ]['content'], '$' ) !== false ) ) { $this->phpcsFile->addWarning(