B
B
Bogdan Gerasimenko2021-06-16 14:19:30
PHP
Bogdan Gerasimenko, 2021-06-16 14:19:30

Is it mandatory to declare a variable type in PHP 8?

I am writing a plugin for WordPress in PHP 8, my PhpStorm IDE suggests substituting a variable type:

/**
 * Sending email with order debug data to admin.
 * @param string $email
 * @param array $data
 */
function send_admin_email(string $email, array $data) {}

I understand that this is according to the canons? I just have never seen this in other WordPress plugins, am I doing everything right or is it overkill?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DevMan, 2021-06-16
@Kleindberg

not required, just a suggestion.
and frequent plugging by beginners who perceive everything underlined as a mistake, although this is only a hint.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question