Warnings in WP CLI

I have some custom functions (in a custom plugin) that work perfectly fine normally but throw warnings in CLI. And I’m wondering if it’s something I just have to accept or if I should modify my functions.

The function uses an array that I define in a different file in the plugin. Where the warning is, I make the array global and iterate through it. Again, this works fine normally. But when I use CLI, I get this warning: “foreach() argument must be of type array|object, null given”.

Is that just the way it is and I should accept it?

Is there something I should do differently?

Personally, I’m not worried about it. But my non-WP boss is (mildly) concerned that there are new warnings.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer