classes/phing/filters/ReplaceTokens.php
private function replaceTokenCallback($matches)
    {
        $key = $matches[1];

        /* Get tokens from tokensource and merge them with the
         * tokens given directly via build file. This should be
         * done a bit more elegantly
         */
        if ($this->_alltokens === null) {
            $this->_alltokens = [];

            $count = count($this->_tokensources);
            for ($i = 0; $i < $count; $i++) {
                $source = $this->_tokensources[$i];
                $this->_alltokens = array_merge($this->_alltokens, $source->getTokens());
            }

            $this->_alltokens = array_merge($this->_tokens, $this->_alltokens);
        }

        $tokens = $this->_alltokens;

        $replaceWith = null;
        $count = count($tokens);

        for ($i = 0; $i < $count; $i++) {
            if ($tokens[$i]->getKey() === $key) {
                $replaceWith = $tokens[$i]->getValue();
            }
        }

        if ($replaceWith === null) {
            $replaceWith = $this->_beginToken . $key . $this->_endToken;
            $this->log("No token defined for key \"" . $this->_beginToken . $key . $this->_endToken . "\"");
        } else {
            $this->log(
                "Replaced \"" . $this->_beginToken . $key . $this->_endToken . "\" with \"" . $replaceWith . "\"",
                Project::MSG_VERBOSE
            );
        }

        return $replaceWith;
    }
private function replaceTokenCallback($matches)
    {
        $key = $matches[1];

        /* Get tokens from tokensource and merge them with the
         * tokens given directly via build file. This should be
         * done a bit more elegantly
         */
        if ($this->_alltokens === null) {
            $this->_alltokens = [];

            $count = count($this->_tokensources);
            for ($i = 0; $i < $count; $i++) {
                $source = $this->_tokensources[$i];
                $this->_alltokens = array_merge($this->_alltokens, $source->getTokens());
            }

            $this->_alltokens = array_merge($this->_tokens, $this->_alltokens);
        }

        $tokens = $this->_alltokens;

        $replaceWith = null;
        $count = count($tokens);

        for ($i = 0; $i < $count; $i++) {
            if ($tokens[$i]->getKey() === $key) {
                $replaceWith = $tokens[$i]->getValue();
            }
        }

        if ($replaceWith === null) {
            $replaceWith = $this->_beginToken . $key . $this->_endToken;
            $this->log("No token defined for key \"" . $this->_beginToken . $key . $this->_endToken . "\"");
        } else {
            $this->log(
                "Replaced \"" . $this->_beginToken . $key . $this->_endToken . "\" with \"" . $replaceWith . "\"",
                Project::MSG_VERBOSE
            );
        }

        return $replaceWith;
    }
private function replaceTokenCallback ( $ matches ) { $ key = $ matches [ 1 ] ; /* Get tokens from tokensource and merge them with the
         * tokens given directly via build file. This should be
         * done a bit more elegantly
         */ if ( $ this -> _alltokens === null ) { $ this -> _alltokens = [ ] ; $ count = count ( $ this -> _tokensources ) ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { $ source = $ this -> _tokensources [ $ i ] ; $ this -> _alltokens = array_merge ( $ this -> _alltokens , $ source -> getTokens ( ) ) ; } $ this -> _alltokens = array_merge ( $ this -> _tokens , $ this -> _alltokens ) ; } $ tokens = $ this -> _alltokens ; $ replaceWith = null ; $ count = count ( $ tokens ) ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { if ( $ tokens [ $ i ] -> getKey ( ) === $ key ) { $ replaceWith = $ tokens [ $ i ] -> getValue ( ) ; } } if ( $ replaceWith === null ) { $ replaceWith = $ this -> _beginToken . $ key . $ this -> _endToken ; $ this -> log ( "No token defined for key \"" . $ this -> _beginToken . $ key . $ this -> _endToken . "\"" ) ; } else { $ this -> log ( "Replaced \"" . $ this -> _beginToken . $ key . $ this -> _endToken . "\" with \"" . $ replaceWith . "\"" , Project :: MSG_VERBOSE ) ; } return $ replaceWith ; }
Performs lookup on key and returns appropriate replacement string.

@param  array $matches Array of 1 el containing key to search for.
@return string Text with which to replace key or value of key if none is found.
Performs lookup on key and returns appropriate replacement string .