Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal error: Uncaught TypeError: str_replace(): Argument #1 ($search) must be of type array|string, null given in \Helper\PathFinder.php:19 #2

Open
mambax7 opened this issue Jan 25, 2023 · 6 comments

Comments

@mambax7
Copy link

mambax7 commented Jan 25, 2023

Unfortunately, I couldn't get it to work on PHP 8.2.1. Should I use a different version of PHP?

Fatal error: Uncaught TypeError: str_replace(): Argument #1 ($search) must be of type array|string, null given in \vendor\xepozz\test-it\src\Helper\PathFinder.php:19
Stack trace:
#0 \vendor\xepozz\test-it\src\Helper\PathFinder.php(19): str_replace(NULL, '', 'App\\Obituaries3...')
#1 \vendor\xepozz\test-it\src\TestGenerator\NamespaceGenerator.php(27): Xepozz\TestIt\Helper\PathFinder::translateNamespace('App\\Obituaries3...', 'C:\\wamp64\\www\\2...')
#2 \vendor\xepozz\test-it\src\Parser\ContextMethodVisitor.php(70): Xepozz\TestIt\TestGenerator\NamespaceGenerator->generate(Object(Xepozz\TestIt\Parser\Context), Array)
#3 \vendor\nikic\php-parser\lib\PhpParser\NodeTraverser.php(230): Xepozz\TestIt\Parser\ContextMethodVisitor->leaveNode(Object(PhpParser\Node\Stmt\Namespace_))
#4 \vendor\nikic\php-parser\lib\PhpParser\NodeTraverser.php(91): PhpParser\NodeTraverser->traverseArray(Array)
#5 \vendor\xepozz\test-it\src\TestGenerator.php(44): PhpParser\NodeTraverser->traverse(Array)
#6 \vendor\xepozz\test-it\test-it(39): Xepozz\TestIt\TestGenerator->process()
#7 \vendor\symfony\console\Command\Command.php(310): Closure->{closure}(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 \vendor\symfony\console\SingleCommandApplication.php(52): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#9 \vendor\symfony\console\Application.php(1022): Symfony\Component\Console\SingleCommandApplication->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 \vendor\symfony\console\Application.php(314): Symfony\Component\Console\Application->doRunCommand(Object(Symfony\Component\Console\SingleCommandApplication), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 \vendor\symfony\console\Application.php(168): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 \vendor\symfony\console\SingleCommandApplication.php(65): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 \vendor\xepozz\test-it\test-it(42): Symfony\Component\Console\SingleCommandApplication->run()
#14 \vendor\bin\test-it(120): include('C:\\wamp64\\bin\\p...')
#15 {main}
  thrown in \vendor\xepozz\test-it\src\Helper\PathFinder.php on line 19
@xepozz
Copy link
Owner

xepozz commented Jan 25, 2023

Could you show your project or write a test in addition to existing ones?

@xepozz
Copy link
Owner

xepozz commented Jan 25, 2023

Probably you don't have autoload-dev section inside your composer.json?

@mambax7
Copy link
Author

mambax7 commented Jan 25, 2023

Correct. What should I put there?

@xepozz
Copy link
Owner

xepozz commented Jan 25, 2023

You should map test namespace with a test directory. Same as here.
It will be "App\\Tests\\": "tests" I suppose.

@xepozz
Copy link
Owner

xepozz commented Jan 25, 2023

@mambax7 have tried to fix the error?
I have a few thoughts about workaround over it, but adding a few lines into composer.json is the simplest solution and even logically right.

@mambax7
Copy link
Author

mambax7 commented Jan 29, 2023

I'm too busy right now, but hopefully in a week I'll try to dive into it again.
Thanks for your tips/ideas!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants