public function processFile(string $file, string $contents, array $coveredIds) : array
    {
        // These keynames are expected by Istanbul compatible coverage reporters
        // the format is outlined here: https://github.com/gotwarlost/istanbul/blob/master/coverage.json.md
        $this->fileCoverage = [
            // path to file this coverage information is for (i.e. resources/user-agents/browsers/chrome/chrome.json)
            'path' => $file,
            // location information for the statements that should be covered
            'statementMap' => [],
            // location information for the functions that should be covered
            'fnMap' => [],
            // location information for the different branch structures that should be covered
            'branchMap' => [],
            // coverage counts for the statements from statementMap
            's' => [],
            // coverage counts for the branches from branchMap (in array form)
            'b' => [],
            // coverage counts for the functions from fnMap
            'f' => [],
        ];

        $this->fileLines      = explode("\n", $contents);
        $this->fileCoveredIds = $coveredIds;

        $lexer = new Lexer();
        $lexer->setInput($contents);

        $this->handleJsonRoot($lexer);

        // This re-indexes the arrays to be 1 based instead of 0, which will make them be JSON objects rather
        // than arrays, which is how they're expected to be in the coverage JSON file
        $this->fileCoverage['fnMap']        = array_filter(array_merge([0], $this->fileCoverage['fnMap']));
        $this->fileCoverage['statementMap'] = array_filter(array_merge([0], $this->fileCoverage['statementMap']));
        $this->fileCoverage['branchMap']    = array_filter(array_merge([0], $this->fileCoverage['branchMap']));

        // Can't use the same method for the b/s/f sections since they can (and should) contain a 0 value, which
        // array_filter would remove
        array_unshift($this->fileCoverage['b'], '');
        unset($this->fileCoverage['b'][0]);
        array_unshift($this->fileCoverage['f'], '');
        unset($this->fileCoverage['f'][0]);
        array_unshift($this->fileCoverage['s'], '');
        unset($this->fileCoverage['s'][0]);

        return $this->fileCoverage;
    }
public function processFile(string $file, string $contents, array $coveredIds) : array
    {
        // These keynames are expected by Istanbul compatible coverage reporters
        // the format is outlined here: https://github.com/gotwarlost/istanbul/blob/master/coverage.json.md
        $this->fileCoverage = [
            // path to file this coverage information is for (i.e. resources/user-agents/browsers/chrome/chrome.json)
            'path' => $file,
            // location information for the statements that should be covered
            'statementMap' => [],
            // location information for the functions that should be covered
            'fnMap' => [],
            // location information for the different branch structures that should be covered
            'branchMap' => [],
            // coverage counts for the statements from statementMap
            's' => [],
            // coverage counts for the branches from branchMap (in array form)
            'b' => [],
            // coverage counts for the functions from fnMap
            'f' => [],
        ];

        $this->fileLines      = explode("\n", $contents);
        $this->fileCoveredIds = $coveredIds;

        $lexer = new Lexer();
        $lexer->setInput($contents);

        $this->handleJsonRoot($lexer);

        // This re-indexes the arrays to be 1 based instead of 0, which will make them be JSON objects rather
        // than arrays, which is how they're expected to be in the coverage JSON file
        $this->fileCoverage['fnMap']        = array_filter(array_merge([0], $this->fileCoverage['fnMap']));
        $this->fileCoverage['statementMap'] = array_filter(array_merge([0], $this->fileCoverage['statementMap']));
        $this->fileCoverage['branchMap']    = array_filter(array_merge([0], $this->fileCoverage['branchMap']));

        // Can't use the same method for the b/s/f sections since they can (and should) contain a 0 value, which
        // array_filter would remove
        array_unshift($this->fileCoverage['b'], '');
        unset($this->fileCoverage['b'][0]);
        array_unshift($this->fileCoverage['f'], '');
        unset($this->fileCoverage['f'][0]);
        array_unshift($this->fileCoverage['s'], '');
        unset($this->fileCoverage['s'][0]);

        return $this->fileCoverage;
    }
public function processFile ( string $ file , string $ contents , array $ coveredIds ) : array { // These keynames are expected by Istanbul compatible coverage reporters // the format is outlined here: https://github.com/gotwarlost/istanbul/blob/master/coverage.json.md $ this -> fileCoverage = [ // path to file this coverage information is for (i.e. resources/user-agents/browsers/chrome/chrome.json) 'path' => $ file , // location information for the statements that should be covered 'statementMap' => [ ] , // location information for the functions that should be covered 'fnMap' => [ ] , // location information for the different branch structures that should be covered 'branchMap' => [ ] , // coverage counts for the statements from statementMap 's' => [ ] , // coverage counts for the branches from branchMap (in array form) 'b' => [ ] , // coverage counts for the functions from fnMap 'f' => [ ] , ] ; $ this -> fileLines = explode ( "\n" , $ contents ) ; $ this -> fileCoveredIds = $ coveredIds ; $ lexer = new Lexer ( ) ; $ lexer -> setInput ( $ contents ) ; $ this -> handleJsonRoot ( $ lexer ) ; // This re-indexes the arrays to be 1 based instead of 0, which will make them be JSON objects rather // than arrays, which is how they're expected to be in the coverage JSON file $ this -> fileCoverage [ 'fnMap' ] = array_filter ( array_merge ( [ 0 ] , $ this -> fileCoverage [ 'fnMap' ] ) ) ; $ this -> fileCoverage [ 'statementMap' ] = array_filter ( array_merge ( [ 0 ] , $ this -> fileCoverage [ 'statementMap' ] ) ) ; $ this -> fileCoverage [ 'branchMap' ] = array_filter ( array_merge ( [ 0 ] , $ this -> fileCoverage [ 'branchMap' ] ) ) ; // Can't use the same method for the b/s/f sections since they can (and should) contain a 0 value, which // array_filter would remove array_unshift ( $ this -> fileCoverage [ 'b' ] , '' ) ; unset ( $ this -> fileCoverage [ 'b' ] [ 0 ] ) ; array_unshift ( $ this -> fileCoverage [ 'f' ] , '' ) ; unset ( $ this -> fileCoverage [ 'f' ] [ 0 ] ) ; array_unshift ( $ this -> fileCoverage [ 's' ] , '' ) ; unset ( $ this -> fileCoverage [ 's' ] [ 0 ] ) ; return $ this -> fileCoverage ; }
Process an individual file for coverage data using covered ids

@param string   $file
@param string   $contents
@param string[] $coveredIds

@return array
Process an individual file for coverage data using covered ids