You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -326,3 +327,35 @@ function first_class_six_min_schedule( $schedules ) {
326
327
}
327
328
add_filter( 'cron_schedules', first_class_six_min_schedule(...)); // Warning: 6 min.
328
329
add_filter( 'cron_schedules', 'first_class_six_min_schedule'(...)); // Warning: 6 min.
330
+
add_filter( 'cron_schedules', \first_class_six_min_schedule(...)); // Warning: 6 min.
331
+
add_filter( 'cron_schedules', namespace\first_class_six_min_schedule(...)); // Warning: 6 min.
332
+
333
+
/*
334
+
* The tests below document the current behavior of the sniff, even though they are false negatives. The sniff treats
335
+
* the first-class callable examples below as if referencing the global function first_class_six_min_schedule()
336
+
* and not a namespaced function with the same name.
337
+
*
338
+
* Related to: https://github.com/WordPress/WordPress-Coding-Standards/issues/2644.
339
+
*/
340
+
add_filter( 'cron_schedules', MyNamespace\first_class_weekly_schedule(...)); // False negative - Ok: > 15 min, but should be marked `ChangeDetected`.
341
+
add_filter( 'cron_schedules', \MyNamespace\first_class_weekly_schedule(...)); // False negative - Ok: > 15 min, but should be marked `ChangeDetected`.
342
+
add_filter( 'cron_schedules', namespace\Sub\first_class_weekly_schedule(...)); // False negative - Ok: > 15 min, but should be marked `ChangeDetected`.
343
+
344
+
/*
345
+
* The tests below document the current behavior of the sniff, even though they are false positives. The sniff treats
346
+
* the first-class callable examples below as if referencing the global function first_class_six_min_schedule()
347
+
* and not a namespaced function with the same name. Fixing this incorrect behavior is not trivial.
348
+
*
349
+
* Related to: https://github.com/WordPress/WordPress-Coding-Standards/issues/2644.
350
+
*/
351
+
add_filter( 'cron_schedules', MyNamespace\first_class_six_min_schedule(...)); // False positive - `CronSchedulesInterval` warning (6 min), but should be `ChangeDetected`.
352
+
add_filter( 'cron_schedules', \MyNamespace\first_class_six_min_schedule(...)); // False positive - `CronSchedulesInterval` warning (6 min), but should be `ChangeDetected`.
353
+
add_filter( 'cron_schedules', namespace\Sub\first_class_six_min_schedule(...)); // False positive - `CronSchedulesInterval` warning (6 min), but should be `ChangeDetected`.
354
+
355
+
/*
356
+
* Safeguard correct handling of all types of namespaced function calls (except FQN global function call which is
357
+
* handled above).
358
+
*/
359
+
MyNamespace\add_filter( 'cron_schedules', 'unknown_callback' ); // Ok.
360
+
\MyNamespace\add_filter( 'cron_schedules', 'unknown_callback' ); // Ok.
361
+
namespace\add_filter( 'cron_schedules', 'unknown_callback' ); // Ok. The sniff should start flagging this once it can resolve relative namespaces.
0 commit comments