zephir-lang / zephir

Zephir is a compiled high-level language aimed to ease the creation of C-extensions for PHP
https://zephir-lang.com
MIT License
3.29k stars 466 forks source link

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

Open eureka2 opened 4 years ago

eureka2 commented 4 years ago

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

sergeyklay commented 4 years ago

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.

eureka2 commented 4 years ago

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.