From eb16ed6ba97ff3b876fa22a0c8f0988b5f392340 Mon Sep 17 00:00:00 2001 From: Joshua Gugun Siagian Date: Sun, 6 Nov 2022 21:14:13 +0800 Subject: [PATCH 1/6] add support for PHP 8.x --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 337f0ee..91af8cb 100644 --- a/composer.json +++ b/composer.json @@ -13,10 +13,10 @@ } ], "require": { - "php": "^7.4", + "php": "^7.4 || ^8.0", "ext-json" : "*", - "nikic/php-parser": "^4.0.0", - "symfony/console": "^5.0" + "nikic/php-parser": "^4.0", + "symfony/console": "^5.0 || ^6.0" }, "require-dev": { "phpunit/phpunit": "^9.5", From df44570e5a7a7e4e7f61e638c296d8bdae089e20 Mon Sep 17 00:00:00 2001 From: Joshua Gugun Siagian Date: Mon, 7 Nov 2022 07:16:34 +0800 Subject: [PATCH 2/6] upgrade wordpress-stubs deps --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 91af8cb..0fcbd7a 100644 --- a/composer.json +++ b/composer.json @@ -20,9 +20,9 @@ }, "require-dev": { "phpunit/phpunit": "^9.5", - "symfony/finder": "^5.4", + "symfony/finder": "^5.4 || ^6.0", "php-stubs/wordpress-globals": "0.2.0", - "php-stubs/wordpress-stubs": "^5.9" + "php-stubs/wordpress-stubs": "^6.0" }, "autoload": { "psr-4": { From f38d39b3530cc567d50b826031b9876d47249afc Mon Sep 17 00:00:00 2001 From: David Barratt Date: Thu, 21 Aug 2025 19:55:10 -0400 Subject: [PATCH 3/6] Fix compatibility with newer nikic/php-parser versions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix return type violations in NodeVisitor methods by changing bare `return;` to `return null;` - Remove improper use of NodeTraverser::REMOVE_NODE in Filter visitor - Add proper condition checks before calling addDefineConstantNames() to prevent undefined property errors - These changes ensure compatibility with php-parser ^4.19 while maintaining backward compatibility 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- src/NodeVisitor/Categorize.php | 16 ++++++++++------ src/NodeVisitor/Filter.php | 5 +---- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/NodeVisitor/Categorize.php b/src/NodeVisitor/Categorize.php index f8b84b5..45b64a2 100644 --- a/src/NodeVisitor/Categorize.php +++ b/src/NodeVisitor/Categorize.php @@ -55,26 +55,30 @@ public function leaveNode(Node $node) { if ($node instanceof Node\Stmt\Class_) { $this->addClassNames($node); - return; + return null; } if ($node instanceof Node\Stmt\Interface_) { $this->addInterfaceNames($node); - return; + return null; } if ($node instanceof Node\Stmt\Function_) { $this->addFunctionNames($node); - return; + return null; } if ($node instanceof Node\Stmt\Trait_) { $this->addTraitNames($node); - return; + return null; } if ($node instanceof Node\Stmt\Const_) { $this->addConstantNames($node); - return; + return null; } - if ($node instanceof Node\Stmt\Expression) { + if ($node instanceof Node\Stmt\Expression + && $node->expr instanceof Node\Expr\FuncCall + && $node->expr->name instanceof Node\Name + && $node->expr->name->toString() === 'define' + ) { $this->addDefineConstantNames($node); } diff --git a/src/NodeVisitor/Filter.php b/src/NodeVisitor/Filter.php index d5c3b96..147f4b0 100644 --- a/src/NodeVisitor/Filter.php +++ b/src/NodeVisitor/Filter.php @@ -28,11 +28,8 @@ public function enterNode(Node $node) } } - public function leaveNode(Node $node) :?int + public function leaveNode(Node $node) { - if ( ! $this->isOfInterest($node) && $node instanceof Node\Stmt) { - return NodeTraverser::REMOVE_NODE; - } return null; } From be953cacc258abfbd2708980cd45fbf4c850e1e0 Mon Sep 17 00:00:00 2001 From: David Barratt Date: Thu, 21 Aug 2025 20:29:51 -0400 Subject: [PATCH 4/6] Fix PHP warnings for undefined property on Encapsed nodes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Handle different scalar node types in addDefineConstantNames to prevent "Undefined property: PhpParser\Node\Scalar\Encapsed::$value" warnings. Skip interpolated strings as constant names cannot be reliably extracted. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- src/NodeVisitor/Categorize.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/NodeVisitor/Categorize.php b/src/NodeVisitor/Categorize.php index 45b64a2..18ef0df 100644 --- a/src/NodeVisitor/Categorize.php +++ b/src/NodeVisitor/Categorize.php @@ -182,7 +182,21 @@ private function addDefineConstantNames(Node $node) :void } try { - $this->constants[] = (string) $node->expr->args[0]->value->value; + $valueNode = $node->expr->args[0]->value; + + // Handle different types of scalar nodes + if ($valueNode instanceof Node\Scalar\String_) { + $constantName = $valueNode->value; + } elseif ($valueNode instanceof Node\Scalar\Encapsed) { + // For interpolated strings, we can't reliably extract a constant name + // Skip these cases to avoid warnings + return; + } else { + // For other node types, try to convert to string if possible + $constantName = (string) $valueNode; + } + + $this->constants[] = $constantName; } catch (Throwable $e) { throw new RuntimeException( "define() declaration has no constant name.\n{$e->getMessage()}", From e65bb8a855bb171c39eecdcbf3fe4a4f60fb91af Mon Sep 17 00:00:00 2001 From: David Barratt Date: Tue, 26 Aug 2025 14:13:30 -0700 Subject: [PATCH 5/6] Add support for same filenames in different directories MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Generate unique output filenames by prepending path hash when processing files with identical basenames from different directory structures. This prevents filename conflicts when processing multiple stub files. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- src/ExclusionListGenerator.php | 58 ++++++++++++++++++++-------------- tests/CustomNamespaceTest.php | 12 +++---- tests/GlobalNamespaceTest.php | 30 +++++++++--------- 3 files changed, 55 insertions(+), 45 deletions(-) diff --git a/src/ExclusionListGenerator.php b/src/ExclusionListGenerator.php index c94a127..f99e820 100644 --- a/src/ExclusionListGenerator.php +++ b/src/ExclusionListGenerator.php @@ -35,30 +35,30 @@ */ final class ExclusionListGenerator { - + const STMT_FUNCTION = 'function'; const STMT_CLASS = 'class'; const STMT_CONST = 'const'; const STMT_TRAIT = 'trait'; const STMT_INTERFACE = 'interface'; - + private Parser $parser; private string $root_dir; - + public function __construct(Parser $parser, string $root_dir) { if ( ! is_dir($root_dir)) { throw new InvalidArgumentException("Directory [$root_dir] does not exist."); } - + if ( ! is_writable($root_dir)) { throw new InvalidArgumentException("Directory [$root_dir] is not writable."); } - + $this->parser = $parser; $this->root_dir = $root_dir; } - + public function dumpAsPhpArray(string $file, bool $include_empty = true) :void { $this->dump($file, function (array $exludes, string $file_path) { @@ -68,7 +68,7 @@ public function dumpAsPhpArray(string $file, bool $include_empty = true) :void ); }, '.php', $include_empty); } - + public function dumpAsJson(string $file, bool $include_empty = true) :void { $this->dump($file, function (array $excludes, $file_path) { @@ -76,7 +76,7 @@ public function dumpAsJson(string $file, bool $include_empty = true) :void return file_put_contents($file_path, $json); }, '.json', $include_empty); } - + /** * @param Closure(array,string):bool $save_do_disk */ @@ -85,37 +85,43 @@ private function dump(string $file, Closure $save_do_disk, string $file_extensio if ( ! is_readable($file)) { throw new InvalidArgumentException("File [$file] is not readable."); } - + if ('php' !== pathinfo($file, PATHINFO_EXTENSION)) { throw new InvalidArgumentException( "Only PHP files can be processed.\nCant process file [$file]." ); } - + $content = file_get_contents($file); if (false === $content) { throw new RuntimeException("Cant read file contents of file [$file]."); } - + $exclude_list = $this->generateExcludeList($content); - + $base_name = pathinfo($file, PATHINFO_FILENAME); - + + $cwd = realpath(getcwd()); + $file_dir = dirname(realpath($file)); + $relative_dir = str_replace($cwd . DIRECTORY_SEPARATOR, '', $file_dir); + + $path_hash = $relative_dir ? substr(hash('sha1', $relative_dir), 0, 7) : ''; + if(!$include_empty){ $exclude_list = array_filter($exclude_list, fn(array $arr) => count($arr)); } - + foreach ($exclude_list as $type => $excludes) { - - $path = $this->getFileName($type, $base_name, $file_extension); + + $path = $this->getFileName($type, $path_hash, $base_name, $file_extension); $success = $save_do_disk($excludes, $path); - + if (false === $success) { throw new RuntimeException("Could not dump contents for file [$base_name]."); } } } - + /** * @return array */ @@ -126,10 +132,10 @@ private function generateExcludeList(string $file_contents) :array $node_traverser->addVisitor(new NameResolver()); // The order is important. $node_traverser->addVisitor($categorizing_visitor = new Categorize()); - + $ast = $this->parser->parse($file_contents); $node_traverser->traverse($ast); - + return [ self::STMT_CLASS => $categorizing_visitor->classes(), self::STMT_INTERFACE => $categorizing_visitor->interfaces(), @@ -138,11 +144,15 @@ private function generateExcludeList(string $file_contents) :array self::STMT_CONST => $categorizing_visitor->constants(), ]; } - - private function getFileName(string $key, string $file_basename, string $extension) :string + + private function getFileName(string $key, string $path_hash, string $file_basename, string $extension) :string { $file_basename = str_replace('-stubs', '', $file_basename); $file_basename = str_replace($extension, '', $file_basename); + if ($path_hash) { + $file_basename = $path_hash . '-' . $file_basename; + } + switch ($key) { case self::STMT_FUNCTION: return $this->root_dir."/exclude-$file_basename-functions$extension"; @@ -158,5 +168,5 @@ private function getFileName(string $key, string $file_basename, string $extensi throw new RuntimeException("Unknown exclude identifier [$key]."); } } - -} \ No newline at end of file + +} diff --git a/tests/CustomNamespaceTest.php b/tests/CustomNamespaceTest.php index 97ff007..c7cb3f2 100644 --- a/tests/CustomNamespaceTest.php +++ b/tests/CustomNamespaceTest.php @@ -81,7 +81,7 @@ public function test_exception_for_dumping_non_php_file() /** @test */ public function functions_in_the_custom_namespace_are_parsed_correctly() { - $expected_path = $this->dump_to.'/exclude-wp-cli-functions.php'; + $expected_path = $this->dump_to.'/exclude-4e5576b-wp-cli-functions.php'; $this->assertFalse(is_file($expected_path)); @@ -100,7 +100,7 @@ public function functions_in_the_custom_namespace_are_parsed_correctly() /** @test */ public function classes_in_the_custom_namespace_are_parsed_correctly() { - $expected_path = $this->dump_to.'/exclude-wp-cli-classes.php'; + $expected_path = $this->dump_to.'/exclude-4e5576b-wp-cli-classes.php'; $this->assertFalse(is_file($expected_path)); @@ -119,7 +119,7 @@ public function classes_in_the_custom_namespace_are_parsed_correctly() /** @test */ public function interfaces_are_parsed_correctly() { - $expected_path = $this->dump_to.'/exclude-wp-cli-interfaces.php'; + $expected_path = $this->dump_to.'/exclude-4e5576b-wp-cli-interfaces.php'; $this->assertFalse(is_file($expected_path)); @@ -137,7 +137,7 @@ public function interfaces_are_parsed_correctly() /** @test */ public function constants_in_the_custom_namespace_are_parsed_correctly() { - $expected_path = $this->dump_to.'/exclude-wp-cli-constants.php'; + $expected_path = $this->dump_to.'/exclude-4e5576b-wp-cli-constants.php'; $this->assertFalse(is_file($expected_path)); @@ -158,7 +158,7 @@ public function constants_in_the_custom_namespace_are_parsed_correctly() /** @test */ public function traits_in_the_custom_namespace_are_parsed_correctly() { - $expected_path = $this->dump_to.'/exclude-wp-cli-traits.php'; + $expected_path = $this->dump_to.'/exclude-4e5576b-wp-cli-traits.php'; $this->assertFalse(is_file($expected_path)); @@ -179,7 +179,7 @@ public function traits_in_the_custom_namespace_are_parsed_correctly() */ public function files_can_be_dumped_as_json() :void { - $expected_path = $this->dump_to.'/exclude-wp-cli-functions.json'; + $expected_path = $this->dump_to.'/exclude-4e5576b-wp-cli-functions.json'; $this->assertFalse(is_file($expected_path)); diff --git a/tests/GlobalNamespaceTest.php b/tests/GlobalNamespaceTest.php index 72f8f9a..10e9f25 100644 --- a/tests/GlobalNamespaceTest.php +++ b/tests/GlobalNamespaceTest.php @@ -49,7 +49,7 @@ protected function tearDown() :void /** @test */ public function functions_in_the_custom_namespace_are_parsed_correctly() { - $expected_path = $this->dump_to.'/exclude-wordpress-functions.php'; + $expected_path = $this->dump_to.'/exclude-4e5576b-wordpress-functions.php'; $this->assertFalse(is_file($expected_path)); @@ -69,7 +69,7 @@ public function functions_in_the_custom_namespace_are_parsed_correctly() /** @test */ public function classes_in_the_global_namespace_are_parsed_correctly() { - $expected_path = $this->dump_to.'/exclude-wordpress-classes.php'; + $expected_path = $this->dump_to.'/exclude-4e5576b-wordpress-classes.php'; $this->assertFalse(is_file($expected_path)); @@ -89,7 +89,7 @@ public function classes_in_the_global_namespace_are_parsed_correctly() /** @test */ public function interfaces_in_the_global_namespace_are_parsed_correctly() { - $expected_path = $this->dump_to.'/exclude-wordpress-interfaces.php'; + $expected_path = $this->dump_to.'/exclude-4e5576b-wordpress-interfaces.php'; $this->assertFalse(is_file($expected_path)); @@ -107,7 +107,7 @@ public function interfaces_in_the_global_namespace_are_parsed_correctly() /** @test */ public function traits_in_the_global_namespace_are_parsed_correctly() { - $expected_path = $this->dump_to.'/exclude-wordpress-traits.php'; + $expected_path = $this->dump_to.'/exclude-4e5576b-wordpress-traits.php'; $this->assertFalse(is_file($expected_path)); @@ -126,7 +126,7 @@ public function traits_in_the_global_namespace_are_parsed_correctly() /** @test */ public function constants_in_the_global_namespace_are_parsed_correctly() { - $expected_path = $this->dump_to.'/exclude-wordpress-constants.php'; + $expected_path = $this->dump_to.'/exclude-4e5576b-wordpress-constants.php'; $this->assertFalse(is_file($expected_path)); @@ -147,17 +147,17 @@ public function constants_in_the_global_namespace_are_parsed_correctly() */ public function only_files_with_contents_can_be_dumped_as_php_array() :void { - $expected_path = $this->dump_to.'/exclude-classes-only-classes.php'; + $expected_path = $this->dump_to.'/exclude-4e5576b-classes-only-classes.php'; $this->assertFalse(is_file($expected_path)); $this->dumper->dumpAsPhpArray($this->fixtures_dir.'/classes-only.php', false); $this->assertTrue(is_file($expected_path)); - $this->assertFalse(is_file($this->dump_to.'/exclude-classes-only-traits.php')); - $this->assertFalse(is_file($this->dump_to.'/exclude-classes-only-constants.php')); - $this->assertFalse(is_file($this->dump_to.'/exclude-classes-only-functions.php')); - $this->assertFalse(is_file($this->dump_to.'/exclude-classes-only-interfaces.php')); + $this->assertFalse(is_file($this->dump_to.'/exclude-4e5576b-classes-only-traits.php')); + $this->assertFalse(is_file($this->dump_to.'/exclude-4e5576b-classes-only-constants.php')); + $this->assertFalse(is_file($this->dump_to.'/exclude-4e5576b-classes-only-functions.php')); + $this->assertFalse(is_file($this->dump_to.'/exclude-4e5576b-classes-only-interfaces.php')); $functions = require_once $expected_path; @@ -173,17 +173,17 @@ public function only_files_with_contents_can_be_dumped_as_php_array() :void */ public function only_files_with_contents_can_be_dumped_as_json_array() :void { - $expected_path = $this->dump_to.'/exclude-classes-only-classes.json'; + $expected_path = $this->dump_to.'/exclude-4e5576b-classes-only-classes.json'; $this->assertFalse(is_file($expected_path)); $this->dumper->dumpAsJson($this->fixtures_dir.'/classes-only.php', false); $this->assertTrue(is_file($expected_path)); - $this->assertFalse(is_file($this->dump_to.'/exclude-classes-only-traits.json')); - $this->assertFalse(is_file($this->dump_to.'/exclude-classes-only-constants.json')); - $this->assertFalse(is_file($this->dump_to.'/exclude-classes-only-functions.json')); - $this->assertFalse(is_file($this->dump_to.'/exclude-classes-only-interfaces.json')); + $this->assertFalse(is_file($this->dump_to.'/exclude-4e5576b-classes-only-traits.json')); + $this->assertFalse(is_file($this->dump_to.'/exclude-4e5576b-classes-only-constants.json')); + $this->assertFalse(is_file($this->dump_to.'/exclude-4e5576b-classes-only-functions.json')); + $this->assertFalse(is_file($this->dump_to.'/exclude-4e5576b-classes-only-interfaces.json')); $functions = json_decode(file_get_contents($expected_path)); From 76a9a31fcbe2fd02e77f1a666e78a5b06c583639 Mon Sep 17 00:00:00 2001 From: David Barratt Date: Thu, 2 Oct 2025 01:13:21 -0400 Subject: [PATCH 6/6] Undo hash changes --- src/ExclusionListGenerator.php | 58 ++++++++++++++-------------------- tests/CustomNamespaceTest.php | 12 +++---- tests/GlobalNamespaceTest.php | 30 +++++++++--------- 3 files changed, 45 insertions(+), 55 deletions(-) diff --git a/src/ExclusionListGenerator.php b/src/ExclusionListGenerator.php index f99e820..c94a127 100644 --- a/src/ExclusionListGenerator.php +++ b/src/ExclusionListGenerator.php @@ -35,30 +35,30 @@ */ final class ExclusionListGenerator { - + const STMT_FUNCTION = 'function'; const STMT_CLASS = 'class'; const STMT_CONST = 'const'; const STMT_TRAIT = 'trait'; const STMT_INTERFACE = 'interface'; - + private Parser $parser; private string $root_dir; - + public function __construct(Parser $parser, string $root_dir) { if ( ! is_dir($root_dir)) { throw new InvalidArgumentException("Directory [$root_dir] does not exist."); } - + if ( ! is_writable($root_dir)) { throw new InvalidArgumentException("Directory [$root_dir] is not writable."); } - + $this->parser = $parser; $this->root_dir = $root_dir; } - + public function dumpAsPhpArray(string $file, bool $include_empty = true) :void { $this->dump($file, function (array $exludes, string $file_path) { @@ -68,7 +68,7 @@ public function dumpAsPhpArray(string $file, bool $include_empty = true) :void ); }, '.php', $include_empty); } - + public function dumpAsJson(string $file, bool $include_empty = true) :void { $this->dump($file, function (array $excludes, $file_path) { @@ -76,7 +76,7 @@ public function dumpAsJson(string $file, bool $include_empty = true) :void return file_put_contents($file_path, $json); }, '.json', $include_empty); } - + /** * @param Closure(array,string):bool $save_do_disk */ @@ -85,43 +85,37 @@ private function dump(string $file, Closure $save_do_disk, string $file_extensio if ( ! is_readable($file)) { throw new InvalidArgumentException("File [$file] is not readable."); } - + if ('php' !== pathinfo($file, PATHINFO_EXTENSION)) { throw new InvalidArgumentException( "Only PHP files can be processed.\nCant process file [$file]." ); } - + $content = file_get_contents($file); if (false === $content) { throw new RuntimeException("Cant read file contents of file [$file]."); } - + $exclude_list = $this->generateExcludeList($content); - + $base_name = pathinfo($file, PATHINFO_FILENAME); - - $cwd = realpath(getcwd()); - $file_dir = dirname(realpath($file)); - $relative_dir = str_replace($cwd . DIRECTORY_SEPARATOR, '', $file_dir); - - $path_hash = $relative_dir ? substr(hash('sha1', $relative_dir), 0, 7) : ''; - + if(!$include_empty){ $exclude_list = array_filter($exclude_list, fn(array $arr) => count($arr)); } - + foreach ($exclude_list as $type => $excludes) { - - $path = $this->getFileName($type, $path_hash, $base_name, $file_extension); + + $path = $this->getFileName($type, $base_name, $file_extension); $success = $save_do_disk($excludes, $path); - + if (false === $success) { throw new RuntimeException("Could not dump contents for file [$base_name]."); } } } - + /** * @return array */ @@ -132,10 +126,10 @@ private function generateExcludeList(string $file_contents) :array $node_traverser->addVisitor(new NameResolver()); // The order is important. $node_traverser->addVisitor($categorizing_visitor = new Categorize()); - + $ast = $this->parser->parse($file_contents); $node_traverser->traverse($ast); - + return [ self::STMT_CLASS => $categorizing_visitor->classes(), self::STMT_INTERFACE => $categorizing_visitor->interfaces(), @@ -144,15 +138,11 @@ private function generateExcludeList(string $file_contents) :array self::STMT_CONST => $categorizing_visitor->constants(), ]; } - - private function getFileName(string $key, string $path_hash, string $file_basename, string $extension) :string + + private function getFileName(string $key, string $file_basename, string $extension) :string { $file_basename = str_replace('-stubs', '', $file_basename); $file_basename = str_replace($extension, '', $file_basename); - if ($path_hash) { - $file_basename = $path_hash . '-' . $file_basename; - } - switch ($key) { case self::STMT_FUNCTION: return $this->root_dir."/exclude-$file_basename-functions$extension"; @@ -168,5 +158,5 @@ private function getFileName(string $key, string $path_hash, string $file_basena throw new RuntimeException("Unknown exclude identifier [$key]."); } } - -} + +} \ No newline at end of file diff --git a/tests/CustomNamespaceTest.php b/tests/CustomNamespaceTest.php index c7cb3f2..97ff007 100644 --- a/tests/CustomNamespaceTest.php +++ b/tests/CustomNamespaceTest.php @@ -81,7 +81,7 @@ public function test_exception_for_dumping_non_php_file() /** @test */ public function functions_in_the_custom_namespace_are_parsed_correctly() { - $expected_path = $this->dump_to.'/exclude-4e5576b-wp-cli-functions.php'; + $expected_path = $this->dump_to.'/exclude-wp-cli-functions.php'; $this->assertFalse(is_file($expected_path)); @@ -100,7 +100,7 @@ public function functions_in_the_custom_namespace_are_parsed_correctly() /** @test */ public function classes_in_the_custom_namespace_are_parsed_correctly() { - $expected_path = $this->dump_to.'/exclude-4e5576b-wp-cli-classes.php'; + $expected_path = $this->dump_to.'/exclude-wp-cli-classes.php'; $this->assertFalse(is_file($expected_path)); @@ -119,7 +119,7 @@ public function classes_in_the_custom_namespace_are_parsed_correctly() /** @test */ public function interfaces_are_parsed_correctly() { - $expected_path = $this->dump_to.'/exclude-4e5576b-wp-cli-interfaces.php'; + $expected_path = $this->dump_to.'/exclude-wp-cli-interfaces.php'; $this->assertFalse(is_file($expected_path)); @@ -137,7 +137,7 @@ public function interfaces_are_parsed_correctly() /** @test */ public function constants_in_the_custom_namespace_are_parsed_correctly() { - $expected_path = $this->dump_to.'/exclude-4e5576b-wp-cli-constants.php'; + $expected_path = $this->dump_to.'/exclude-wp-cli-constants.php'; $this->assertFalse(is_file($expected_path)); @@ -158,7 +158,7 @@ public function constants_in_the_custom_namespace_are_parsed_correctly() /** @test */ public function traits_in_the_custom_namespace_are_parsed_correctly() { - $expected_path = $this->dump_to.'/exclude-4e5576b-wp-cli-traits.php'; + $expected_path = $this->dump_to.'/exclude-wp-cli-traits.php'; $this->assertFalse(is_file($expected_path)); @@ -179,7 +179,7 @@ public function traits_in_the_custom_namespace_are_parsed_correctly() */ public function files_can_be_dumped_as_json() :void { - $expected_path = $this->dump_to.'/exclude-4e5576b-wp-cli-functions.json'; + $expected_path = $this->dump_to.'/exclude-wp-cli-functions.json'; $this->assertFalse(is_file($expected_path)); diff --git a/tests/GlobalNamespaceTest.php b/tests/GlobalNamespaceTest.php index 10e9f25..72f8f9a 100644 --- a/tests/GlobalNamespaceTest.php +++ b/tests/GlobalNamespaceTest.php @@ -49,7 +49,7 @@ protected function tearDown() :void /** @test */ public function functions_in_the_custom_namespace_are_parsed_correctly() { - $expected_path = $this->dump_to.'/exclude-4e5576b-wordpress-functions.php'; + $expected_path = $this->dump_to.'/exclude-wordpress-functions.php'; $this->assertFalse(is_file($expected_path)); @@ -69,7 +69,7 @@ public function functions_in_the_custom_namespace_are_parsed_correctly() /** @test */ public function classes_in_the_global_namespace_are_parsed_correctly() { - $expected_path = $this->dump_to.'/exclude-4e5576b-wordpress-classes.php'; + $expected_path = $this->dump_to.'/exclude-wordpress-classes.php'; $this->assertFalse(is_file($expected_path)); @@ -89,7 +89,7 @@ public function classes_in_the_global_namespace_are_parsed_correctly() /** @test */ public function interfaces_in_the_global_namespace_are_parsed_correctly() { - $expected_path = $this->dump_to.'/exclude-4e5576b-wordpress-interfaces.php'; + $expected_path = $this->dump_to.'/exclude-wordpress-interfaces.php'; $this->assertFalse(is_file($expected_path)); @@ -107,7 +107,7 @@ public function interfaces_in_the_global_namespace_are_parsed_correctly() /** @test */ public function traits_in_the_global_namespace_are_parsed_correctly() { - $expected_path = $this->dump_to.'/exclude-4e5576b-wordpress-traits.php'; + $expected_path = $this->dump_to.'/exclude-wordpress-traits.php'; $this->assertFalse(is_file($expected_path)); @@ -126,7 +126,7 @@ public function traits_in_the_global_namespace_are_parsed_correctly() /** @test */ public function constants_in_the_global_namespace_are_parsed_correctly() { - $expected_path = $this->dump_to.'/exclude-4e5576b-wordpress-constants.php'; + $expected_path = $this->dump_to.'/exclude-wordpress-constants.php'; $this->assertFalse(is_file($expected_path)); @@ -147,17 +147,17 @@ public function constants_in_the_global_namespace_are_parsed_correctly() */ public function only_files_with_contents_can_be_dumped_as_php_array() :void { - $expected_path = $this->dump_to.'/exclude-4e5576b-classes-only-classes.php'; + $expected_path = $this->dump_to.'/exclude-classes-only-classes.php'; $this->assertFalse(is_file($expected_path)); $this->dumper->dumpAsPhpArray($this->fixtures_dir.'/classes-only.php', false); $this->assertTrue(is_file($expected_path)); - $this->assertFalse(is_file($this->dump_to.'/exclude-4e5576b-classes-only-traits.php')); - $this->assertFalse(is_file($this->dump_to.'/exclude-4e5576b-classes-only-constants.php')); - $this->assertFalse(is_file($this->dump_to.'/exclude-4e5576b-classes-only-functions.php')); - $this->assertFalse(is_file($this->dump_to.'/exclude-4e5576b-classes-only-interfaces.php')); + $this->assertFalse(is_file($this->dump_to.'/exclude-classes-only-traits.php')); + $this->assertFalse(is_file($this->dump_to.'/exclude-classes-only-constants.php')); + $this->assertFalse(is_file($this->dump_to.'/exclude-classes-only-functions.php')); + $this->assertFalse(is_file($this->dump_to.'/exclude-classes-only-interfaces.php')); $functions = require_once $expected_path; @@ -173,17 +173,17 @@ public function only_files_with_contents_can_be_dumped_as_php_array() :void */ public function only_files_with_contents_can_be_dumped_as_json_array() :void { - $expected_path = $this->dump_to.'/exclude-4e5576b-classes-only-classes.json'; + $expected_path = $this->dump_to.'/exclude-classes-only-classes.json'; $this->assertFalse(is_file($expected_path)); $this->dumper->dumpAsJson($this->fixtures_dir.'/classes-only.php', false); $this->assertTrue(is_file($expected_path)); - $this->assertFalse(is_file($this->dump_to.'/exclude-4e5576b-classes-only-traits.json')); - $this->assertFalse(is_file($this->dump_to.'/exclude-4e5576b-classes-only-constants.json')); - $this->assertFalse(is_file($this->dump_to.'/exclude-4e5576b-classes-only-functions.json')); - $this->assertFalse(is_file($this->dump_to.'/exclude-4e5576b-classes-only-interfaces.json')); + $this->assertFalse(is_file($this->dump_to.'/exclude-classes-only-traits.json')); + $this->assertFalse(is_file($this->dump_to.'/exclude-classes-only-constants.json')); + $this->assertFalse(is_file($this->dump_to.'/exclude-classes-only-functions.json')); + $this->assertFalse(is_file($this->dump_to.'/exclude-classes-only-interfaces.json')); $functions = json_decode(file_get_contents($expected_path));