Skip to content

Commit dd5057d

Browse files
committed
NOTES/LATER LowExpiryCacheTimeSniff
1 parent 298a17f commit dd5057d

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

WordPressVIPMinimum/Sniffs/Performance/LowExpiryCacheTimeSniff.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424
*/
2525
class LowExpiryCacheTimeSniff extends AbstractFunctionParameterSniff {
2626

27+
// TODO: switch to PHPCSUtils version of AbstractFunctionParameterSniff once available.
28+
// Have the namespace + use tracker available for the constant check
29+
// Also for the function check as per #408
30+
// Use Collections::nameTokens() to handle constant better for PHP 8.0/PHPCS 4.0.
31+
2732
/**
2833
* The group name for this group of functions.
2934
*

WordPressVIPMinimum/Tests/Performance/LowExpiryCacheTimeUnitTest.1.inc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,9 @@ wp_cache_replace($key, expire: 400, group: $group, data: 100,); // OK.
159159

160160
wp_cache_replace($key, $data, expire: 100 ); // Bad.
161161
wp_cache_replace(expire: 100, data: $data, key: $group); // Bad.
162+
163+
// Test with constants for which the value is known.
164+
wp_cache_set( 'test', $data, $group, PHP_INT_MAX ); // OK.
165+
wp_cache_set( 'test', $data, $group, PHP_INT_MIN ); // Bad.
166+
wp_cache_set( 'test', $data, $group, PHP_FLOAT_MAX ); // OK.
167+
wp_cache_set( 'test', $data, $group, PHP_FLOAT_MIN ); // Bad.

0 commit comments

Comments
 (0)