diff --git a/composer.json b/composer.json index 53194e0..d1b81a5 100644 --- a/composer.json +++ b/composer.json @@ -10,10 +10,10 @@ } ], "require": { - "php": "^7.1 || ^8.0", + "php": "^7.4 || ^8.0", "ext-json": "*", "ext-pinpoint_php": "^0.5.2", - "nikic/php-parser": "^4.1" + "nikic/php-parser": "^5.0" }, "autoload": { "psr-4": { @@ -28,7 +28,7 @@ "phpunit/phpunit": "^8", "phpbench/phpbench": "1.0.0", "ext-pinpoint_php": "^0.5.2", - "nikic/php-parser": "^4.1", + "nikic/php-parser": "^5.0", "predis/predis": "^3.0@alpha", "guzzlehttp/guzzle": "8.0.x-dev", "mongodb/mongodb": "v1.19.x-dev" diff --git a/lib/Pinpoint/Common/GenProxyClassTemplateHelper.php b/lib/Pinpoint/Common/GenProxyClassTemplateHelper.php index 6228670..4cb2029 100644 --- a/lib/Pinpoint/Common/GenProxyClassTemplateHelper.php +++ b/lib/Pinpoint/Common/GenProxyClassTemplateHelper.php @@ -159,7 +159,8 @@ public function handleClassLeaveMethodNode($node, $monitorClassFullName) // 1. make a new method overriding parent's $originMethodName = $node->name->toString(); $newMethodName = $this->methodNewName($originMethodName); - $node->name = new Node\Name\FullyQualified($newMethodName); + // $node->name = new Node\Name\FullyQualified($newMethodName); + $node->name = new Node\Identifier($newMethodName); Logger::Inst()->debug("generate pinpoint code block for '$originMethodName'"); $funcVar = new Node\Arg(new Node\Scalar\MagicConst\Method()); @@ -325,8 +326,8 @@ public function handleClassLeaveMethodNode($node, $monitorClassFullName) $expArgs ) ); - - $catchBlock[] = new Node\Stmt\Throw_(new Node\Expr\Variable("e")); + // "throw $e;" + $catchBlock[] = new Node\Stmt\Expression(new Node\Expr\Throw_(new Node\Expr\Variable("e"))); $catchNode[] = new Node\Stmt\Catch_( [new Node\Name('\Exception')], diff --git a/lib/Pinpoint/Common/OriginFileVisitor.php b/lib/Pinpoint/Common/OriginFileVisitor.php index 8fa462d..15a056b 100644 --- a/lib/Pinpoint/Common/OriginFileVisitor.php +++ b/lib/Pinpoint/Common/OriginFileVisitor.php @@ -29,7 +29,8 @@ class OriginFileVisitor public function __construct() { $this->traverser = new NodeTraverser(); - $this->phpFileParser = (new ParserFactory())->create(ParserFactory::ONLY_PHP7); + // $this->phpFileParser = (new ParserFactory())->create(ParserFactory::ONLY_PHP7); + $this->phpFileParser = (new ParserFactory())->createForHostVersion(); } public function runAllVisitor(string $fullPath, AspectClassHandle $classHandler) diff --git a/lib/Pinpoint/test/php_parse.php b/lib/Pinpoint/test/php_parse.php index 72b94e0..1ee2bc8 100644 --- a/lib/Pinpoint/test/php_parse.php +++ b/lib/Pinpoint/test/php_parse.php @@ -7,12 +7,12 @@ use PDO; use PhpParser\ParserFactory; use PhpParser\PrettyPrinter; -$filename='Bear.php'; +$filename = 'Bear.php'; $code = file_get_contents($filename); -$parser = (new ParserFactory)->create(ParserFactory::ONLY_PHP7); +$parser = (new ParserFactory)->createForHostVersion(); $ast = $parser->parse($code); $prettyPrinter = new PrettyPrinter\Standard(); echo $prettyPrinter->prettyPrintFile($ast); -file_put_contents($filename.'_6.ast', print_r($ast,true)); \ No newline at end of file +file_put_contents($filename . '_6.ast', print_r($ast, true)); \ No newline at end of file