Troubleshooting: WP-CLI displays PHP notices when running commands

Issue

When running commands in WP-CLI, it shows a lot of notices like below:

$ wp post list
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; QrctWp has a deprecated constructor in xxxwp-contentpluginsqr-code-taglibqrctQrctWp.php on line 11
PHP Notice:  wp_enqueue_script was called <strong>incorrectly</strong>. Scripts and styles should not be registered or enqueued until the <code>wp_enqueue_scripts</code>, <code>admin_enqueue_scripts</code>, or <code>login_enqueue_scripts</code> hooks. Please see <a href="https://codex.wordpress.org/Debugging_in_WordPress">Debugging in WordPress</a> for more information. (This message was added in version 3.3.0.) in xxxwp-includesfunctions.php on line 4231
Notice: wp_enqueue_script was called <strong>incorrectly</strong>. Scripts and styles should not be registered or enqueued until the <code>wp_enqueue_scripts</code>, <code>admin_enqueue_scripts</code>, or <code>login_enqueue_scripts</code> hooks. Please see <a href="https://codex.wordpress.org/Debugging_in_WordPress">Debugging in WordPress</a> for more information. (This message was added in version 3.3.0.) in xxxwp-includesfunctions.php on line 4231
...

Solution

Set WP_DEBUG from true to false in wp-config.php of your WordPress.

wp-config.php:

define( 'WP_DEBUG', false );