Commit f116911cc4 for woocommerce
commit f116911cc45034d508c147197a470a28a9a5dca5
Author: Rostislav Wolný <1082140+costasovo@users.noreply.github.com>
Date: Tue Jan 20 11:04:28 2026 +0100
PHPStan - add Action Scheduler to scanned directories (#62858)
* Add scanning of Action Scheduler files
* Remove unnecessary phpstan-ignore comments
* Fix newly found type issues
* Update phpstan baseline - remove ignored errors
* Add changefile(s) from automation for the following project(s): woocommerce
* Revert changing arguments in as_unschedule_action
---------
Co-authored-by: woocommercebot <woocommercebot@users.noreply.github.com>
diff --git a/plugins/woocommerce/changelog/62858-phpstan-add-action-scheduler b/plugins/woocommerce/changelog/62858-phpstan-add-action-scheduler
new file mode 100644
index 0000000000..e5c73ee7bd
--- /dev/null
+++ b/plugins/woocommerce/changelog/62858-phpstan-add-action-scheduler
@@ -0,0 +1,4 @@
+Significance: patch
+Type: dev
+Comment: Added Action Scheduler's code to the scanned directories in PHPStan
+
diff --git a/plugins/woocommerce/includes/class-woocommerce.php b/plugins/woocommerce/includes/class-woocommerce.php
index 257e53834f..8d61cbdfba 100644
--- a/plugins/woocommerce/includes/class-woocommerce.php
+++ b/plugins/woocommerce/includes/class-woocommerce.php
@@ -1547,6 +1547,9 @@ final class WooCommerce {
// Schedule daily sales event at midnight tomorrow.
$scheduled_sales_time = strtotime( '00:00 tomorrow ' . $offset_hours );
+ if ( false === $scheduled_sales_time ) {
+ $scheduled_sales_time = strtotime( '00:00 tomorrow' );
+ }
as_schedule_recurring_action( $scheduled_sales_time, DAY_IN_SECONDS, 'woocommerce_scheduled_sales', array(), 'woocommerce', true );
@@ -1565,7 +1568,13 @@ final class WooCommerce {
}
$tomorrow_3am = strtotime( 'tomorrow 03:00 am ' . $offset_hours );
+ if ( false === $tomorrow_3am ) {
+ $tomorrow_3am = strtotime( 'tomorrow 03:00 am' );
+ }
$tomorrow_6am = strtotime( 'tomorrow 06:00 am ' . $offset_hours );
+ if ( false === $tomorrow_6am ) {
+ $tomorrow_6am = strtotime( 'tomorrow 06:00 am' );
+ }
// Delay the first run of `woocommerce_cleanup_personal_data` by 10 seconds
// so it doesn't occur in the same request. WooCommerce Admin also schedules
diff --git a/plugins/woocommerce/includes/interfaces/class-wc-queue-interface.php b/plugins/woocommerce/includes/interfaces/class-wc-queue-interface.php
index c4e3ef442e..8c3be66d19 100644
--- a/plugins/woocommerce/includes/interfaces/class-wc-queue-interface.php
+++ b/plugins/woocommerce/includes/interfaces/class-wc-queue-interface.php
@@ -21,7 +21,7 @@ interface WC_Queue_Interface {
* @param string $hook The hook to trigger.
* @param array $args Arguments to pass when the hook triggers.
* @param string $group The group to assign this job to.
- * @return string The action ID
+ * @return int The action ID
*/
public function add( $hook, $args = array(), $group = '' );
@@ -32,7 +32,7 @@ interface WC_Queue_Interface {
* @param string $hook The hook to trigger.
* @param array $args Arguments to pass when the hook triggers.
* @param string $group The group to assign this job to.
- * @return string The action ID
+ * @return int The action ID
*/
public function schedule_single( $timestamp, $hook, $args = array(), $group = '' );
@@ -44,7 +44,7 @@ interface WC_Queue_Interface {
* @param string $hook The hook to trigger.
* @param array $args Arguments to pass when the hook triggers.
* @param string $group The group to assign this job to.
- * @return string The action ID
+ * @return int The action ID
*/
public function schedule_recurring( $timestamp, $interval_in_seconds, $hook, $args = array(), $group = '' );
@@ -66,7 +66,7 @@ interface WC_Queue_Interface {
* @param string $hook The hook to trigger.
* @param array $args Arguments to pass when the hook triggers.
* @param string $group The group to assign this job to.
- * @return string The action ID
+ * @return int The action ID
*/
public function schedule_cron( $timestamp, $cron_schedule, $hook, $args = array(), $group = '' );
diff --git a/plugins/woocommerce/includes/queue/class-wc-action-queue.php b/plugins/woocommerce/includes/queue/class-wc-action-queue.php
index 069e27053d..261ea03b50 100644
--- a/plugins/woocommerce/includes/queue/class-wc-action-queue.php
+++ b/plugins/woocommerce/includes/queue/class-wc-action-queue.php
@@ -25,7 +25,7 @@ class WC_Action_Queue implements WC_Queue_Interface {
* @param string $hook The hook to trigger.
* @param array $args Arguments to pass when the hook triggers.
* @param string $group The group to assign this job to.
- * @return string The action ID.
+ * @return int The action ID.
*/
public function add( $hook, $args = array(), $group = '' ) {
return $this->schedule_single( time(), $hook, $args, $group );
@@ -38,7 +38,7 @@ class WC_Action_Queue implements WC_Queue_Interface {
* @param string $hook The hook to trigger.
* @param array $args Arguments to pass when the hook triggers.
* @param string $group The group to assign this job to.
- * @return string The action ID.
+ * @return int The action ID.
*/
public function schedule_single( $timestamp, $hook, $args = array(), $group = '' ) {
return as_schedule_single_action( $timestamp, $hook, $args, $group );
@@ -52,7 +52,7 @@ class WC_Action_Queue implements WC_Queue_Interface {
* @param string $hook The hook to trigger.
* @param array $args Arguments to pass when the hook triggers.
* @param string $group The group to assign this job to.
- * @return string The action ID.
+ * @return int The action ID.
*/
public function schedule_recurring( $timestamp, $interval_in_seconds, $hook, $args = array(), $group = '' ) {
return as_schedule_recurring_action( $timestamp, $interval_in_seconds, $hook, $args, $group );
@@ -76,7 +76,7 @@ class WC_Action_Queue implements WC_Queue_Interface {
* @param string $hook The hook to trigger.
* @param array $args Arguments to pass when the hook triggers.
* @param string $group The group to assign this job to.
- * @return string The action ID
+ * @return int The action ID
*/
public function schedule_cron( $timestamp, $cron_schedule, $hook, $args = array(), $group = '' ) {
return as_schedule_cron_action( $timestamp, $cron_schedule, $hook, $args, $group );
diff --git a/plugins/woocommerce/includes/react-admin/wc-admin-update-functions.php b/plugins/woocommerce/includes/react-admin/wc-admin-update-functions.php
index 433e5c0985..390bfcff32 100644
--- a/plugins/woocommerce/includes/react-admin/wc-admin-update-functions.php
+++ b/plugins/woocommerce/includes/react-admin/wc-admin-update-functions.php
@@ -55,8 +55,8 @@ function wc_admin_update_0230_rename_gross_total() {
* Remove the note unsnoozing scheduled action.
*/
function wc_admin_update_0251_remove_unsnooze_action() {
- as_unschedule_action( Notes::UNSNOOZE_HOOK, null, 'wc-admin-data' );
- as_unschedule_action( Notes::UNSNOOZE_HOOK, null, 'wc-admin-notes' );
+ as_unschedule_action( Notes::UNSNOOZE_HOOK, null, 'wc-admin-data' ); // @phpstan-ignore-line argument.type We want to use null. With null we clean any action with the given hook. Passing array would only clean actions with the given args.
+ as_unschedule_action( Notes::UNSNOOZE_HOOK, null, 'wc-admin-notes' ); // @phpstan-ignore-line argument.type
}
/**
diff --git a/plugins/woocommerce/includes/wc-product-functions.php b/plugins/woocommerce/includes/wc-product-functions.php
index e4cc65cdd4..c13c023339 100644
--- a/plugins/woocommerce/includes/wc-product-functions.php
+++ b/plugins/woocommerce/includes/wc-product-functions.php
@@ -566,7 +566,7 @@ function wc_schedule_product_sale_events( WC_Product $product ): void {
if ( $date_from ) {
$start_ts = $date_from->getTimestamp();
if ( $start_ts > time() ) {
- as_schedule_single_action( // @phpstan-ignore function.notFound
+ as_schedule_single_action(
$start_ts,
'wc_product_start_scheduled_sale',
array( 'product_id' => $product_id ),
@@ -578,7 +578,7 @@ function wc_schedule_product_sale_events( WC_Product $product ): void {
if ( $date_to ) {
$end_ts = $date_to->getTimestamp();
if ( $end_ts > time() ) {
- as_schedule_single_action( // @phpstan-ignore function.notFound
+ as_schedule_single_action(
$end_ts,
'wc_product_end_scheduled_sale',
array( 'product_id' => $product_id ),
@@ -734,8 +734,8 @@ function wc_maybe_schedule_product_sale_events( $product_id, $product = null ):
$product_id = $product->get_id();
// Always clear existing events first.
- as_unschedule_all_actions( 'wc_product_start_scheduled_sale', array( 'product_id' => $product_id ), 'woocommerce-sales' ); // @phpstan-ignore function.notFound
- as_unschedule_all_actions( 'wc_product_end_scheduled_sale', array( 'product_id' => $product_id ), 'woocommerce-sales' ); // @phpstan-ignore function.notFound
+ as_unschedule_all_actions( 'wc_product_start_scheduled_sale', array( 'product_id' => $product_id ), 'woocommerce-sales' );
+ as_unschedule_all_actions( 'wc_product_end_scheduled_sale', array( 'product_id' => $product_id ), 'woocommerce-sales' );
$date_from = $product->get_date_on_sale_from( 'edit' );
$date_to = $product->get_date_on_sale_to( 'edit' );
diff --git a/plugins/woocommerce/includes/wc-update-functions.php b/plugins/woocommerce/includes/wc-update-functions.php
index 88b3a29714..29edcdf547 100644
--- a/plugins/woocommerce/includes/wc-update-functions.php
+++ b/plugins/woocommerce/includes/wc-update-functions.php
@@ -2120,7 +2120,7 @@ function wc_update_400_increase_size_of_column() {
function wc_update_400_reset_action_scheduler_migration_status() {
if (
class_exists( 'ActionScheduler_DataController' ) &&
- method_exists( 'ActionScheduler_DataController', 'mark_migration_incomplete' )
+ method_exists( 'ActionScheduler_DataController', 'mark_migration_incomplete' ) // @phpstan-ignore function.alreadyNarrowedType
) {
\ActionScheduler_DataController::mark_migration_incomplete();
}
diff --git a/plugins/woocommerce/phpstan-baseline.neon b/plugins/woocommerce/phpstan-baseline.neon
index 2814e85bf3..fb1be5cf94 100644
--- a/plugins/woocommerce/phpstan-baseline.neon
+++ b/plugins/woocommerce/phpstan-baseline.neon
@@ -14280,24 +14280,12 @@ parameters:
count: 1
path: includes/class-wc-download-handler.php
- -
- message: '#^Call to static method instance\(\) on an unknown class ActionScheduler_Versions\.$#'
- identifier: class.notFound
- count: 1
- path: includes/class-wc-download-handler.php
-
-
message: '#^Cannot call method get_file_download_path\(\) on WC_Product\|false\|null\.$#'
identifier: method.nonObject
count: 1
path: includes/class-wc-download-handler.php
- -
- message: '#^Function as_schedule_single_action not found\.$#'
- identifier: function.notFound
- count: 1
- path: includes/class-wc-download-handler.php
-
-
message: '#^Method WC_Download_Handler\:\:check_download_expiry\(\) has no return type specified\.$#'
identifier: missingType.return
@@ -15264,12 +15252,6 @@ parameters:
count: 2
path: includes/class-wc-install.php
- -
- message: '#^Function as_schedule_single_action not found\.$#'
- identifier: function.notFound
- count: 2
- path: includes/class-wc-install.php
-
-
message: '#^Method WC_Install\:\:add_coming_soon_option\(\) has no return type specified\.$#'
identifier: missingType.return
@@ -16998,12 +16980,6 @@ parameters:
count: 1
path: includes/class-wc-post-data.php
- -
- message: '#^Function as_next_scheduled_action not found\.$#'
- identifier: function.notFound
- count: 1
- path: includes/class-wc-post-data.php
-
-
message: '#^Method WC_Post_Data\:\:before_delete_order\(\) has no return type specified\.$#'
identifier: missingType.return
@@ -20202,24 +20178,6 @@ parameters:
count: 1
path: includes/class-woocommerce.php
- -
- message: '#^Function as_next_scheduled_action not found\.$#'
- identifier: function.notFound
- count: 1
- path: includes/class-woocommerce.php
-
- -
- message: '#^Function as_schedule_recurring_action not found\.$#'
- identifier: function.notFound
- count: 1
- path: includes/class-woocommerce.php
-
- -
- message: '#^Function as_unschedule_all_actions not found\.$#'
- identifier: function.notFound
- count: 6
- path: includes/class-woocommerce.php
-
-
message: '#^Method WooCommerce\:\:activated_plugin\(\) has no return type specified\.$#'
identifier: missingType.return
@@ -27150,48 +27108,6 @@ parameters:
count: 1
path: includes/product-usage/class-wc-product-usage.php
- -
- message: '#^Function as_get_scheduled_actions not found\.$#'
- identifier: function.notFound
- count: 1
- path: includes/queue/class-wc-action-queue.php
-
- -
- message: '#^Function as_next_scheduled_action not found\.$#'
- identifier: function.notFound
- count: 1
- path: includes/queue/class-wc-action-queue.php
-
- -
- message: '#^Function as_schedule_cron_action not found\.$#'
- identifier: function.notFound
- count: 1
- path: includes/queue/class-wc-action-queue.php
-
- -
- message: '#^Function as_schedule_recurring_action not found\.$#'
- identifier: function.notFound
- count: 1
- path: includes/queue/class-wc-action-queue.php
-
- -
- message: '#^Function as_schedule_single_action not found\.$#'
- identifier: function.notFound
- count: 1
- path: includes/queue/class-wc-action-queue.php
-
- -
- message: '#^Function as_unschedule_action not found\.$#'
- identifier: function.notFound
- count: 1
- path: includes/queue/class-wc-action-queue.php
-
- -
- message: '#^Function as_unschedule_all_actions not found\.$#'
- identifier: function.notFound
- count: 1
- path: includes/queue/class-wc-action-queue.php
-
-
message: '#^Method WC_Action_Queue\:\:cancel\(\) has no return type specified\.$#'
identifier: missingType.return
@@ -27306,12 +27222,6 @@ parameters:
count: 2
path: includes/react-admin/wc-admin-update-functions.php
- -
- message: '#^Function as_unschedule_action not found\.$#'
- identifier: function.notFound
- count: 2
- path: includes/react-admin/wc-admin-update-functions.php
-
-
message: '#^Function wc_admin_update_0201_order_status_index\(\) has no return type specified\.$#'
identifier: missingType.return
@@ -42285,12 +42195,6 @@ parameters:
count: 1
path: includes/wc-update-functions.php
- -
- message: '#^Call to function method_exists\(\) with ''ActionScheduler…'' and ''mark_migration…'' will always evaluate to false\.$#'
- identifier: function.impossibleType
- count: 1
- path: includes/wc-update-functions.php
-
-
message: '#^Cannot access offset 0 on non\-empty\-array\|true\.$#'
identifier: offsetAccess.nonOffsetAccessible
@@ -42333,12 +42237,6 @@ parameters:
count: 1
path: includes/wc-update-functions.php
- -
- message: '#^Function as_unschedule_all_actions not found\.$#'
- identifier: function.notFound
- count: 1
- path: includes/wc-update-functions.php
-
-
message: '#^Function filter_created_pages\(\) has no return type specified\.$#'
identifier: missingType.return
@@ -54987,12 +54885,6 @@ parameters:
count: 1
path: src/Admin/PluginsHelper.php
- -
- message: '#^Call to method get_status\(\) on an unknown class ActionScheduler_DBStore\.$#'
- identifier: class.notFound
- count: 1
- path: src/Admin/PluginsHelper.php
-
-
message: '#^Cannot access property \$download_link on array\|object\.$#'
identifier: property.nonObject
@@ -55011,12 +54903,6 @@ parameters:
count: 1
path: src/Admin/PluginsHelper.php
- -
- message: '#^Instantiated class ActionScheduler_DBStore not found\.$#'
- identifier: class.notFound
- count: 1
- path: src/Admin/PluginsHelper.php
-
-
message: '#^Method Automattic\\WooCommerce\\Admin\\PluginsHelper\:\:init\(\) has no return type specified\.$#'
identifier: missingType.return
@@ -55893,12 +55779,6 @@ parameters:
count: 1
path: src/Admin/RemoteSpecs/RuleProcessors/StoredStateSetupForProducts.php
- -
- message: '#^Function as_enqueue_async_action not found\.$#'
- identifier: function.notFound
- count: 1
- path: src/Admin/RemoteSpecs/RuleProcessors/StoredStateSetupForProducts.php
-
-
message: '#^Method Automattic\\WooCommerce\\Admin\\RemoteSpecs\\RuleProcessors\\StoredStateSetupForProducts\:\:admin_init\(\) has no return type specified\.$#'
identifier: missingType.return
@@ -56217,12 +56097,6 @@ parameters:
count: 1
path: src/Admin/ReportExporter.php
- -
- message: '#^Call to method get_schedule\(\) on an unknown class ActionScheduler_Action\.$#'
- identifier: class.notFound
- count: 3
- path: src/Admin/ReportExporter.php
-
-
message: '#^Call to method schedule_single\(\) on an unknown class Automattic\\WooCommerce\\Admin\\Schedulers\\WC_Queue_Interface\.$#'
identifier: class.notFound
@@ -56235,18 +56109,6 @@ parameters:
count: 2
path: src/Admin/ReportExporter.php
- -
- message: '#^Call to static method instance\(\) on an unknown class ActionScheduler_Versions\.$#'
- identifier: class.notFound
- count: 1
- path: src/Admin/ReportExporter.php
-
- -
- message: '#^Call to static method store\(\) on an unknown class ActionScheduler\.$#'
- identifier: class.notFound
- count: 1
- path: src/Admin/ReportExporter.php
-
-
message: '#^Expected 3 @param tags, found 2\.$#'
identifier: paramTag.count
@@ -56367,12 +56229,6 @@ parameters:
count: 1
path: src/Admin/ReportExporter.php
- -
- message: '#^Parameter \$action of method Automattic\\WooCommerce\\Admin\\ReportExporter\:\:get_next_action_time\(\) has invalid type ActionScheduler_Action\.$#'
- identifier: class.notFound
- count: 1
- path: src/Admin/ReportExporter.php
-
-
message: '#^Parameter \$queue of method Automattic\\WooCommerce\\Admin\\ReportExporter\:\:set_queue\(\) has invalid type Automattic\\WooCommerce\\Admin\\Schedulers\\WC_Queue_Interface\.$#'
identifier: class.notFound
@@ -56721,12 +56577,6 @@ parameters:
count: 1
path: src/Blocks/BlockPatterns.php
- -
- message: '#^Parameter \#1 \$function of function call_user_func expects callable\(\)\: mixed, ''as_has_scheduled…''\|''as_next_scheduled…'' given\.$#'
- identifier: argument.type
- count: 1
- path: src/Blocks/BlockPatterns.php
-
-
message: '#^Parameter \#1 \$str of function ucfirst expects string, array\<string\>\|string given\.$#'
identifier: argument.type
@@ -61659,12 +61509,6 @@ parameters:
count: 1
path: src/Blocks/Domain/Services/DraftOrders.php
- -
- message: '#^Function as_schedule_recurring_action not found\.$#'
- identifier: function.notFound
- count: 1
- path: src/Blocks/Domain/Services/DraftOrders.php
-
-
message: '#^Method Automattic\\WooCommerce\\Blocks\\Domain\\Services\\DraftOrders\:\:assert_order_results\(\) has no return type specified\.$#'
identifier: missingType.return
@@ -61707,12 +61551,6 @@ parameters:
count: 1
path: src/Blocks/Domain/Services/DraftOrders.php
- -
- message: '#^Parameter \#1 \$function of function call_user_func expects callable\(\)\: mixed, ''as_has_scheduled…''\|''as_next_scheduled…'' given\.$#'
- identifier: argument.type
- count: 1
- path: src/Blocks/Domain/Services/DraftOrders.php
-
-
message: '#^Parameter \#1 \$order_results of method Automattic\\WooCommerce\\Blocks\\Domain\\Services\\DraftOrders\:\:assert_order_results\(\) expects array\<WC_Order\>, array\<WC_Order\>\|stdClass given\.$#'
identifier: argument.type
@@ -61953,18 +61791,6 @@ parameters:
count: 3
path: src/Blocks/Patterns/PTKPatternsStore.php
- -
- message: '#^Function as_has_scheduled_action not found\.$#'
- identifier: function.notFound
- count: 1
- path: src/Blocks/Patterns/PTKPatternsStore.php
-
- -
- message: '#^Function as_schedule_recurring_action not found\.$#'
- identifier: function.notFound
- count: 1
- path: src/Blocks/Patterns/PTKPatternsStore.php
-
-
message: '#^Parameter \#1 \$input of function array_filter expects array, list\<string\>\|false given\.$#'
identifier: argument.type
@@ -62889,12 +62715,6 @@ parameters:
count: 1
path: src/Caches/OrderCountCache.php
- -
- message: '#^Function as_schedule_recurring_action not found\.$#'
- identifier: function.notFound
- count: 1
- path: src/Caches/OrderCountCacheService.php
-
-
message: '#^Method Automattic\\WooCommerce\\Caches\\OrderCountCacheService\:\:init\(\) has no return type specified\.$#'
identifier: missingType.return
@@ -67365,12 +67185,6 @@ parameters:
count: 1
path: src/Internal/Admin/Schedulers/ImportScheduler.php
- -
- message: '#^Call to method get_schedule\(\) on an unknown class ActionScheduler_Action\.$#'
- identifier: class.notFound
- count: 3
- path: src/Internal/Admin/Schedulers/ImportScheduler.php
-
-
message: '#^Call to method schedule_single\(\) on an unknown class Automattic\\WooCommerce\\Admin\\Schedulers\\WC_Queue_Interface\.$#'
identifier: class.notFound
@@ -67383,18 +67197,6 @@ parameters:
count: 4
path: src/Internal/Admin/Schedulers/ImportScheduler.php
- -
- message: '#^Call to static method instance\(\) on an unknown class ActionScheduler_Versions\.$#'
- identifier: class.notFound
- count: 1
- path: src/Internal/Admin/Schedulers/ImportScheduler.php
-
- -
- message: '#^Call to static method store\(\) on an unknown class ActionScheduler\.$#'
- identifier: class.notFound
- count: 1
- path: src/Internal/Admin/Schedulers/ImportScheduler.php
-
-
message: '#^Expected 3 @param tags, found 2\.$#'
identifier: paramTag.count
@@ -67521,12 +67323,6 @@ parameters:
count: 2
path: src/Internal/Admin/Schedulers/ImportScheduler.php
- -
- message: '#^Parameter \$action of method Automattic\\WooCommerce\\Internal\\Admin\\Schedulers\\ImportScheduler\:\:get_next_action_time\(\) has invalid type ActionScheduler_Action\.$#'
- identifier: class.notFound
- count: 1
- path: src/Internal/Admin/Schedulers/ImportScheduler.php
-
-
message: '#^Parameter \$queue of method Automattic\\WooCommerce\\Internal\\Admin\\Schedulers\\ImportScheduler\:\:set_queue\(\) has invalid type Automattic\\WooCommerce\\Admin\\Schedulers\\WC_Queue_Interface\.$#'
identifier: class.notFound
@@ -67575,18 +67371,6 @@ parameters:
count: 1
path: src/Internal/Admin/Schedulers/OrdersScheduler.php
- -
- message: '#^Function as_schedule_recurring_action not found\.$#'
- identifier: function.notFound
- count: 1
- path: src/Internal/Admin/Schedulers/OrdersScheduler.php
-
- -
- message: '#^Function as_unschedule_all_actions not found\.$#'
- identifier: function.notFound
- count: 1
- path: src/Internal/Admin/Schedulers/OrdersScheduler.php
-
-
message: '#^Method Automattic\\WooCommerce\\Internal\\Admin\\Schedulers\\OrdersScheduler\:\:get_items\(\) has no return type specified\.$#'
identifier: missingType.return
@@ -67611,12 +67395,6 @@ parameters:
count: 1
path: src/Internal/Admin/Schedulers/OrdersScheduler.php
- -
- message: '#^Parameter \#1 \$function of function call_user_func expects callable\(\)\: mixed, ''as_has_scheduled…''\|''as_next_scheduled…'' given\.$#'
- identifier: argument.type
- count: 1
- path: src/Internal/Admin/Schedulers/OrdersScheduler.php
-
-
message: '#^Argument of an invalid type array\|WP_Error supplied for foreach, only iterables are supported\.$#'
identifier: foreach.nonIterable
@@ -68751,30 +68529,6 @@ parameters:
count: 1
path: src/Internal/BatchProcessing/BatchProcessingController.php
- -
- message: '#^Function as_has_scheduled_action not found\.$#'
- identifier: function.notFound
- count: 2
- path: src/Internal/BatchProcessing/BatchProcessingController.php
-
- -
- message: '#^Function as_schedule_single_action not found\.$#'
- identifier: function.notFound
- count: 2
- path: src/Internal/BatchProcessing/BatchProcessingController.php
-
- -
- message: '#^Function as_unschedule_all_actions not found\.$#'
- identifier: function.notFound
- count: 3
- path: src/Internal/BatchProcessing/BatchProcessingController.php
-
- -
- message: '#^Parameter \#1 \$function of function call_user_func expects callable\(\)\: mixed, ''as_has_scheduled…''\|''as_next_scheduled…'' given\.$#'
- identifier: argument.type
- count: 1
- path: src/Internal/BatchProcessing/BatchProcessingController.php
-
-
message: '#^Parameter \#1 \$id of method Automattic\\WooCommerce\\Container\:\:get\(\) expects class\-string\<object\>, string given\.$#'
identifier: argument.type
@@ -69873,12 +69627,6 @@ parameters:
count: 3
path: src/Internal/DataStores/Orders/DataSynchronizer.php
- -
- message: '#^Function as_schedule_recurring_action not found\.$#'
- identifier: function.notFound
- count: 1
- path: src/Internal/DataStores/Orders/DataSynchronizer.php
-
-
message: '#^Method Automattic\\WooCommerce\\Internal\\DataStores\\Orders\\DataSynchronizer\:\:cleanup_synchronization_state\(\) has no return type specified\.$#'
identifier: missingType.return
@@ -71046,12 +70794,6 @@ parameters:
count: 1
path: src/Internal/DependencyManagement/RuntimeContainer.php
- -
- message: '#^Access to constant STATUS_PENDING on an unknown class ActionScheduler_Store\.$#'
- identifier: class.notFound
- count: 1
- path: src/Internal/DownloadPermissionsAdjuster.php
-
-
message: '#^Call to method create_from_data\(\) on an unknown class Automattic\\WooCommerce\\Internal\\WC_Data_Store\.$#'
identifier: class.notFound
@@ -72966,12 +72708,6 @@ parameters:
count: 1
path: src/Internal/ProductAttributesLookup/CLIRunner.php
- -
- message: '#^Access to constant STATUS_PENDING on an unknown class ActionScheduler_Store\.$#'
- identifier: class.notFound
- count: 1
- path: src/Internal/ProductAttributesLookup/DataRegenerator.php
-
-
message: '#^Call to an undefined method object\:\:cancel_all\(\)\.$#'
identifier: method.notFound
@@ -73140,12 +72876,6 @@ parameters:
count: 1
path: src/Internal/ProductAttributesLookup/Filterer.php
- -
- message: '#^Access to constant STATUS_PENDING on an unknown class ActionScheduler_Store\.$#'
- identifier: class.notFound
- count: 1
- path: src/Internal/ProductAttributesLookup/LookupDataStore.php
-
-
message: '#^Call to an undefined method object\:\:schedule_single\(\)\.$#'
identifier: method.notFound
@@ -78096,24 +77826,6 @@ parameters:
count: 1
path: src/Internal/TransientFiles/TransientFilesEngine.php
- -
- message: '#^Function as_has_scheduled_action not found\.$#'
- identifier: function.notFound
- count: 1
- path: src/Internal/TransientFiles/TransientFilesEngine.php
-
- -
- message: '#^Function as_schedule_single_action not found\.$#'
- identifier: function.notFound
- count: 1
- path: src/Internal/TransientFiles/TransientFilesEngine.php
-
- -
- message: '#^Function as_unschedule_action not found\.$#'
- identifier: function.notFound
- count: 1
- path: src/Internal/TransientFiles/TransientFilesEngine.php
-
-
message: '#^Method Automattic\\WooCommerce\\Internal\\TransientFiles\\TransientFilesEngine\:\:add_endpoint\(\) has no return type specified\.$#'
identifier: missingType.return
diff --git a/plugins/woocommerce/phpstan.neon b/plugins/woocommerce/phpstan.neon
index 634a82c5ef..7f89cdd47b 100644
--- a/plugins/woocommerce/phpstan.neon
+++ b/plugins/woocommerce/phpstan.neon
@@ -18,6 +18,7 @@ parameters:
- vendor/autoload.php
scanDirectories:
- vendor/wordpress/abilities-api
+ - packages/action-scheduler
scanFiles:
- php-stubs/wc-admin-feature-config.php
- php-stubs/wc-constants.php
diff --git a/plugins/woocommerce/src/Blocks/Domain/Services/DraftOrders.php b/plugins/woocommerce/src/Blocks/Domain/Services/DraftOrders.php
index 1cc8bfb9ce..422b09742a 100644
--- a/plugins/woocommerce/src/Blocks/Domain/Services/DraftOrders.php
+++ b/plugins/woocommerce/src/Blocks/Domain/Services/DraftOrders.php
@@ -79,7 +79,10 @@ class DraftOrders {
protected function maybe_create_cronjobs() {
$has_scheduled_action = function_exists( 'as_has_scheduled_action' ) ? 'as_has_scheduled_action' : 'as_next_scheduled_action';
if ( false === call_user_func( $has_scheduled_action, self::DRAFT_CLEANUP_EVENT_HOOK ) ) {
- as_schedule_recurring_action( strtotime( 'midnight tonight' ), DAY_IN_SECONDS, self::DRAFT_CLEANUP_EVENT_HOOK );
+ $midnight_tonight = strtotime( 'midnight tonight' );
+ if ( false !== $midnight_tonight ) {
+ as_schedule_recurring_action( $midnight_tonight, DAY_IN_SECONDS, self::DRAFT_CLEANUP_EVENT_HOOK );
+ }
}
}
diff --git a/plugins/woocommerce/src/Internal/Admin/Schedulers/OrdersScheduler.php b/plugins/woocommerce/src/Internal/Admin/Schedulers/OrdersScheduler.php
index e8fd27e2a7..c6fa2384b2 100644
--- a/plugins/woocommerce/src/Internal/Admin/Schedulers/OrdersScheduler.php
+++ b/plugins/woocommerce/src/Internal/Admin/Schedulers/OrdersScheduler.php
@@ -381,6 +381,9 @@ AND status NOT IN ( 'wc-auto-draft', 'trash', 'auto-draft' )
*/
public static function schedule_recurring_batch_processor() {
$action_hook = self::get_action( self::PROCESS_PENDING_ORDERS_BATCH_ACTION );
+ if ( null === $action_hook ) {
+ return;
+ }
// The most efficient way to check for an existing action is to use `as_has_scheduled_action`, but in unusual
// cases where another plugin has loaded a very old version of Action Scheduler, it may not be available to us.
$has_scheduled_action = function_exists( 'as_has_scheduled_action' ) ? 'as_has_scheduled_action' : 'as_next_scheduled_action';
@@ -390,7 +393,7 @@ AND status NOT IN ( 'wc-auto-draft', 'trash', 'auto-draft' )
$interval = self::get_import_interval();
- as_schedule_recurring_action( time(), $interval, $action_hook, array(), static::$group, true );
+ as_schedule_recurring_action( time(), $interval, $action_hook, array(), static::$group ?? '', true );
}
/**
@@ -412,7 +415,9 @@ AND status NOT IN ( 'wc-auto-draft', 'trash', 'auto-draft' )
if ( 'yes' === $old_value && 'no' === $new_value ) {
// Unschedule the recurring batch processor.
$action_hook = self::get_action( self::PROCESS_PENDING_ORDERS_BATCH_ACTION );
- as_unschedule_all_actions( $action_hook, array(), static::$group );
+ if ( null !== $action_hook ) {
+ as_unschedule_all_actions( $action_hook, array(), static::$group ?? '' );
+ }
// Schedule an immediate catchup batch to process all orders up to now.
// This ensures no orders are missed during the transition.
diff --git a/plugins/woocommerce/src/Internal/ProductFeed/Integrations/POSCatalog/AsyncGenerator.php b/plugins/woocommerce/src/Internal/ProductFeed/Integrations/POSCatalog/AsyncGenerator.php
index 0fb0f67e9e..d317d8877c 100644
--- a/plugins/woocommerce/src/Internal/ProductFeed/Integrations/POSCatalog/AsyncGenerator.php
+++ b/plugins/woocommerce/src/Internal/ProductFeed/Integrations/POSCatalog/AsyncGenerator.php
@@ -108,7 +108,7 @@ class AsyncGenerator {
}
// Clear all previous actions to avoid race conditions.
- as_unschedule_all_actions( self::FEED_GENERATION_ACTION, array( $option_key ), 'woo-product-feed' ); // @phpstan-ignore function.notFound
+ as_unschedule_all_actions( self::FEED_GENERATION_ACTION, array( $option_key ), 'woo-product-feed' );
$status = array(
'scheduled_at' => time(),
@@ -126,7 +126,6 @@ class AsyncGenerator {
);
// Start an immediate async action to generate the feed.
- // @phpstan-ignore-next-line function.notFound -- Action Scheduler.
as_enqueue_async_action(
self::FEED_GENERATION_ACTION,
array( $option_key ),
@@ -200,7 +199,6 @@ class AsyncGenerator {
update_option( $option_key, $status );
// Schedule another action to delete the file after the expiry time.
- // @phpstan-ignore-next-line function.notFound -- Action Scheduler.
as_schedule_single_action(
time() + self::FEED_EXPIRY,
self::FEED_DELETION_ACTION,