/usr/share/php/Sstalle/php7cc/ContextChecker.php is in php7cc 1.1.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | <?php
namespace Sstalle\php7cc;
use PhpParser\Parser;
use Sstalle\php7cc\CompatibilityViolation\ContextInterface;
use Sstalle\php7cc\CompatibilityViolation\FileContext;
use Sstalle\php7cc\Error\CheckError;
use Sstalle\php7cc\Lexer\ExtendedLexer;
use Sstalle\php7cc\NodeTraverser\Traverser;
class ContextChecker
{
/**
* @var Parser
*/
protected $parser;
/**
* @var ExtendedLexer
*/
protected $lexer;
/**
* @var Traverser
*/
protected $traverser;
/**
* @param Parser $parser
* @param ExtendedLexer $lexer
* @param Traverser $traverser
*/
public function __construct(Parser $parser, ExtendedLexer $lexer, Traverser $traverser)
{
$this->parser = $parser;
$this->lexer = $lexer;
$this->traverser = $traverser;
}
/**
* @param ContextInterface $context
*
* @return FileContext
*/
public function checkContext(ContextInterface $context)
{
try {
$parsedStatements = $this->parser->parse($context->getCheckedCode());
$this->traverser->traverse($parsedStatements, $context, $this->lexer->getTokens());
} catch (\Exception $e) {
$context->addError(new CheckError($e->getMessage()));
} catch (\ParseException $e) {
$context->addError(new CheckError($e->getMessage(), $e->getLine()));
}
}
}
|