zephir icon indicating copy to clipboard operation
zephir copied to clipboard

How can i avoid this warning : Variable "xxxx" assigned but not used

Open eureka2 opened this issue 5 years ago • 2 comments

Hi,

I wrote this method which works correctly:

public function getWords(array strings) -> array {
    var pdo = this->pdo;
    var words = array_map(function(a) use (pdo) {
            let a = preg_replace("/^(j|m|s|t|l|qu|c|d|n)\'$/i", "$1e", a);
            return pdo->quote(trim(mb_strtolower(a)));
    }, strings);
    return words;
}

But I get this warning when compiling :

 Warning: Variable "pdo" assigned but not used in Nlp\Dictionary\Dictionary::getWords in C:\var\www\html\phpext\nlp\nlp\Dictionary\dictionary.zep on line 306 [unused-variable]

          var pdo = this->pdo;

        ---------------------^

How to avoid it?

as you can see, the variable 'pdo' is used in the use language construct ... function(a) use (pdo)

Thanks for your help

eureka2 avatar Dec 16 '19 18:12 eureka2

Hello,

It's a minor issue we should to deal. Right now you can safely ignore this warning. Another option is to use -Wunused-variable flag.

sergeyklay avatar Dec 16 '19 23:12 sergeyklay

Hi,

Thank you for your reply

Ok, I will ignore this warning. I don't want to use the -Wunused-variable flag. Thank you for not closing this issue until it is resolved.

eureka2 avatar Dec 17 '19 08:12 eureka2