From cd49a71c9a0a2f3c3ee48f097c4d4130eb0c301a Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Thu, 4 Apr 2024 09:57:42 +0200 Subject: [PATCH] Revert "Initial work on a script that prints the names of units of code that are considered public" This reverts commit c77b958af7df9dd0a8f99f14f588775c40a48022. --- build/scripts/print-public-code-units.php | 69 ----------------------- 1 file changed, 69 deletions(-) delete mode 100755 build/scripts/print-public-code-units.php diff --git a/build/scripts/print-public-code-units.php b/build/scripts/print-public-code-units.php deleted file mode 100755 index 40528253b05..00000000000 --- a/build/scripts/print-public-code-units.php +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/env php -getFilesAsArray(__DIR__ . '/../../src', '.php') as $file) { - analyse($file); -} - -function analyse(string $file): void -{ - $nodes = parse($file); - - $traverser = new NodeTraverser; - - $traverser->addVisitor(new NameResolver); - $traverser->addVisitor(new ParentConnectingVisitor); - - $traverser->addVisitor( - new class extends NodeVisitorAbstract - { - public function enterNode(Node $node): void - { - if ($node instanceof Interface_ || - $node instanceof Class_ || - $node instanceof Enum_ || - $node instanceof Trait_ || - $node instanceof Function_) { - if ($node->getDocComment() !== null && - !str_contains($node->getDocComment()->getText(), '@internal')) { - print $node->namespacedName->name . PHP_EOL; - } - } - } - } - ); - - $traverser->traverse($nodes); -} - -/** - * @psalm-return array - */ -function parse(string $file): array -{ - try { - $nodes = (new ParserFactory)->createForHostVersion()->parse(file_get_contents($file)); - - assert($nodes !== null); - - return $nodes; - } catch (Throwable $t) { - print $t->getMessage() . PHP_EOL; - - exit(1); - } -}