From c5f6923e5a85bc5be9aaa49030ec452fc8154f94 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Sun, 4 Dec 2022 23:49:58 +0000 Subject: [PATCH] fix: methods name with `\` --- src/Support/Str.php | 2 +- tests/.snapshots/success.txt | 7 ++++++- tests/Unit/Support/Str.php | 13 +++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 tests/Unit/Support/Str.php diff --git a/src/Support/Str.php b/src/Support/Str.php index 69522b6a..6ceaed1d 100644 --- a/src/Support/Str.php +++ b/src/Support/Str.php @@ -56,7 +56,7 @@ final class Str { $code = str_replace(' ', '_', $code); - return (string) preg_replace('/[^A-Z_a-z0-9\\\\]/', '', $code); + return (string) preg_replace('/[^A-Z_a-z0-9]/', '_', $code); } /** diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index be2b2d57..e47760bb 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -858,6 +858,11 @@ ✓ it gets file name from closure ✓ it gets property values + PASS Tests\Unit\Support\Str + ✓ it evaluates the code with ('version()', 'version__') + ✓ it evaluates the code with ('version__ ', 'version___') + ✓ it evaluates the code with ('version\', 'version_') + PASS Tests\Unit\TestSuite ✓ it does not allow to add the same test description twice ✓ it alerts users about tests with arguments but no input @@ -885,4 +890,4 @@ PASS Tests\Visual\Version ✓ visual snapshot of help command output - Tests: 4 incomplete, 2 todos, 18 skipped, 616 passed (1526 assertions) \ No newline at end of file + Tests: 4 incomplete, 2 todos, 18 skipped, 619 passed (1529 assertions) \ No newline at end of file diff --git a/tests/Unit/Support/Str.php b/tests/Unit/Support/Str.php new file mode 100644 index 00000000..870adf6d --- /dev/null +++ b/tests/Unit/Support/Str.php @@ -0,0 +1,13 @@ +toBe($expected); +})->with([ + ['version()', 'version__'], + ['version__ ', 'version___'], + ['version\\', 'version_'], +]);