public function findLemma($lemma, $folders, $trans_methods, $regex = false, $shortOutput = false, $ext = 'php')
    {
        $files = [];

        foreach ($folders as $path) {
            foreach ($this->getFilesWithExtension($path, $ext) as $php_file_path => $dumb) {
                foreach ($this->extractTranslationFromPhpFile($php_file_path, $trans_methods) as $k => $v) {
                    $a = $this->evalString($k);
                    if (is_string($a)) {
                        $real_value = $a;
                        $found      = false;

                        if ($regex) {
                            try {
                                $r = preg_match($lemma, $real_value);
                            } // Exception is thrown via command
                            catch (\Exception $e) {
                                $this->messageBag->writeError("The argument is not a valid regular expression:".str_replace('preg_match():', '', $e->getMessage()));

                                return false;
                            }
                            if ($r === 1) {
                                $found = true;
                            }
                            // Normal behavior via method call
                            // @codeCoverageIgnoreStart
                            else {
                                if ($r === false) {
                                    $this->messageBag->writeError("The argument is not a valid regular expression");

                                    return false;
                                }
                            }
                            // @codeCoverageIgnoreEnd
                        } else {
                            if (! (strpos($real_value, $lemma) === false)) {
                                $found = true;
                            }
                        }

                        if ($found === true) {
                            if ($shortOutput === true) {
                                $php_file_path = $this->getShortPath($php_file_path);
                            }
                            $files[] = $php_file_path;
                            break;
                        }
                    } else {
                        $this->messageBag->writeError("Unable to understand string $k");
                    }
                }
            }
        }

        return $files;
    }
public function findLemma($lemma, $folders, $trans_methods, $regex = false, $shortOutput = false, $ext = 'php')
    {
        $files = [];

        foreach ($folders as $path) {
            foreach ($this->getFilesWithExtension($path, $ext) as $php_file_path => $dumb) {
                foreach ($this->extractTranslationFromPhpFile($php_file_path, $trans_methods) as $k => $v) {
                    $a = $this->evalString($k);
                    if (is_string($a)) {
                        $real_value = $a;
                        $found      = false;

                        if ($regex) {
                            try {
                                $r = preg_match($lemma, $real_value);
                            } // Exception is thrown via command
                            catch (\Exception $e) {
                                $this->messageBag->writeError("The argument is not a valid regular expression:".str_replace('preg_match():', '', $e->getMessage()));

                                return false;
                            }
                            if ($r === 1) {
                                $found = true;
                            }
                            // Normal behavior via method call
                            // @codeCoverageIgnoreStart
                            else {
                                if ($r === false) {
                                    $this->messageBag->writeError("The argument is not a valid regular expression");

                                    return false;
                                }
                            }
                            // @codeCoverageIgnoreEnd
                        } else {
                            if (! (strpos($real_value, $lemma) === false)) {
                                $found = true;
                            }
                        }

                        if ($found === true) {
                            if ($shortOutput === true) {
                                $php_file_path = $this->getShortPath($php_file_path);
                            }
                            $files[] = $php_file_path;
                            break;
                        }
                    } else {
                        $this->messageBag->writeError("Unable to understand string $k");
                    }
                }
            }
        }

        return $files;
    }
public function findLemma ( $ lemma , $ folders , $ trans_methods , $ regex = false , $ shortOutput = false , $ ext = 'php' ) { $ files = [ ] ; foreach ( $ folders as $ path ) { foreach ( $ this -> getFilesWithExtension ( $ path , $ ext ) as $ php_file_path => $ dumb ) { foreach ( $ this -> extractTranslationFromPhpFile ( $ php_file_path , $ trans_methods ) as $ k => $ v ) { $ a = $ this -> evalString ( $ k ) ; if ( is_string ( $ a ) ) { $ real_value = $ a ; $ found = false ; if ( $ regex ) { try { $ r = preg_match ( $ lemma , $ real_value ) ; } // Exception is thrown via command catch ( \ Exception $ e ) { $ this -> messageBag -> writeError ( "The argument is not a valid regular expression:" . str_replace ( 'preg_match():' , '' , $ e -> getMessage ( ) ) ) ; return false ; } if ( $ r === 1 ) { $ found = true ; } // Normal behavior via method call // @codeCoverageIgnoreStart else { if ( $ r === false ) { $ this -> messageBag -> writeError ( "The argument is not a valid regular expression" ) ; return false ; } } // @codeCoverageIgnoreEnd } else { if ( ! ( strpos ( $ real_value , $ lemma ) === false ) ) { $ found = true ; } } if ( $ found === true ) { if ( $ shortOutput === true ) { $ php_file_path = $ this -> getShortPath ( $ php_file_path ) ; } $ files [ ] = $ php_file_path ; break ; } } else { $ this -> messageBag -> writeError ( "Unable to understand string $k" ) ; } } } } return $ files ; }
Get the list of PHP code files where a lemma is defined

@param string $lemma           A lemma to search for or a regex to search for
@param array $folders          An array of folder to search for lemma in
@param array $trans_methods    An array of PHP lang functions
@param bool|false $regex       Is lemma a regex ?
@param bool|false $shortOutput Output style for file paths
@param string $ext

@return array|false
Get the list of PHP code files where a lemma is defined