PHPTestFestBrasil/phptt

phptt generate shows error message (skeleton for functions without optional arguments) but works

leonampd opened this issue · 4 comments

Running phptt generate -f strlen -b for exemple. The command outputs some errors:

/usr/local/bin/usr/local/bin/phptt
Warning: count(): Parameter must be an array or an object that implements Countable in phar:///usr/src/php/scripts/dev/generate-phpt.phar/gtTestSubject.php on line 109

Warning: count(): Parameter must be an array or an object that implements Countable in phar:///usr/src/php/scripts/dev/generate-phpt.phar/gtTestSubject.php on line 52

Warning: count(): Parameter must be an array or an object that implements Countable in phar:///usr/src/php/scripts/dev/generate-phpt.phar/gtTestSubject.php on line 150

I think the problem is the usr/src dir that doesn't exists

Hi, @leonampd, thanks for letting us know about this issue (we've seen several participants of #phptestfest São Paulo edition by @PHPSP in 2017-11-11 suffering with this same issue).

We'd like just to inform that even with this message, phptt generate command is working, so everytime you got this message take a look at your directory: your .phpt file (test skeleton) should be there.

As we had explained during meetup, this generate subcommand wasn't created from the ground. It uses a source code that is available in php/php-src ( I guess since PHP 5.3 ), and I think the problem is there! I took a look at https://github.com/php/php-src/blob/master/scripts/dev/generate-phpt/src/gtTestSubject.php#L45 , I guess it's a problem in gtTestSubject::optionalArgumentNames not being initialized as an array (even an empty one) before it is used as one Countable.

I've noted that this error is not happening when we try to run phptt generate for a function that accepts optional arguments (for example print_r, command: phptt generate -f print_r -b).

Let's continue to work on it, ok? Just let's confirm it is an phptt issue or a php-src issue, so we can send our solution suggestion to the right place.

Thanks again!

Hi @rogeriopradoj

I also had the same problem, I did some tests with some optional parameter functions and it worked normal, but when I create functions without optional parameter I have the same output as the @leonampd commented.

@rogeriopradoj @leonampd I think this issue can be closed

You're correct @danilosilva87 , thanks!