src/Terion/PackageInstaller/ConfigUpdater.php
protected function isCharInComment($haystack, $charPosition)
    {
        // check for line comment
        for ($c = $charPosition; $c > 0; --$c) {
            if ($haystack[$c] === PHP_EOL) {
                break;
            } elseif ($haystack[$c] === '#' or ($haystack[$c] === '/'
                    and ($haystack[$c + 1] === '/' or $haystack[$c - 1] === '/'))
            ) {
                return true;
            }
        }
        // check for block comment
        $openingsCount = 0;
        $closingsCount = 0;
        for ($c = $charPosition; $c > 0; --$c) {
            if ($haystack[$c] === '*' and $haystack[$c - 1] === '/') {
                ++$openingsCount;
            }
            if ($haystack[$c] === '/' and $haystack[$c - 1] === '*') {
                ++$closingsCount;
            }
        }
        if ($openingsCount !== $closingsCount) {
            return true;
        }
        return false;
    }
protected function isCharInComment($haystack, $charPosition)
    {
        // check for line comment
        for ($c = $charPosition; $c > 0; --$c) {
            if ($haystack[$c] === PHP_EOL) {
                break;
            } elseif ($haystack[$c] === '#' or ($haystack[$c] === '/'
                    and ($haystack[$c + 1] === '/' or $haystack[$c - 1] === '/'))
            ) {
                return true;
            }
        }
        // check for block comment
        $openingsCount = 0;
        $closingsCount = 0;
        for ($c = $charPosition; $c > 0; --$c) {
            if ($haystack[$c] === '*' and $haystack[$c - 1] === '/') {
                ++$openingsCount;
            }
            if ($haystack[$c] === '/' and $haystack[$c - 1] === '*') {
                ++$closingsCount;
            }
        }
        if ($openingsCount !== $closingsCount) {
            return true;
        }
        return false;
    }
protected function isCharInComment ( $ haystack , $ charPosition ) { // check for line comment for ( $ c = $ charPosition ; $ c > 0 ; -- $ c ) { if ( $ haystack [ $ c ] === PHP_EOL ) { break ; } elseif ( $ haystack [ $ c ] === '#' or ( $ haystack [ $ c ] === '/' and ( $ haystack [ $ c + 1 ] === '/' or $ haystack [ $ c - 1 ] === '/' ) ) ) { return true ; } } // check for block comment $ openingsCount = 0 ; $ closingsCount = 0 ; for ( $ c = $ charPosition ; $ c > 0 ; -- $ c ) { if ( $ haystack [ $ c ] === '*' and $ haystack [ $ c - 1 ] === '/' ) { ++ $ openingsCount ; } if ( $ haystack [ $ c ] === '/' and $ haystack [ $ c - 1 ] === '*' ) { ++ $ closingsCount ; } } if ( $ openingsCount !== $ closingsCount ) { return true ; } return false ; }
Detect is character at specified position is inside of a comment

@param $haystack
@param $charPosition

@return bool
Detect is character at specified position is inside of a comment