Skip to content

Commit

Permalink
Check PHP has populated argv
Browse files Browse the repository at this point in the history
This will always be a non-empty-list<string> in a CLI script but because it might be
null in other contexts Psalm is strict about checking for it here
  • Loading branch information
ciaranmcnulty committed Sep 7, 2023
1 parent 9db73ff commit 4e784d4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions php/bin/gherkin
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ use Cucumber\Gherkin\GherkinParser;
use Cucumber\Messages\Source;
use Cucumber\Messages\Streams\NdJson\NdJsonStreamWriter;

assert(is_array($argv), "Script must be run from the command line");

$options = ['predictable-ids', 'no-source', 'no-ast', 'no-pickles'];

$selectedOptions = getopt('', $options, $restIndex);

$paths = array_slice($argv, $restIndex);

// lazily-read list of Sources
$sources = (
/** @param list<string> $paths */
Expand Down
2 changes: 2 additions & 0 deletions php/bin/gherkin-generate-tokens
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ namespace Cucumber\Gherkin;

require __DIR__ . '/../vendor/autoload.php';

assert(is_array($argv), "Script must be run from the command line");

$parser = new Parser(new TokenFormatterBuilder());

// first element is the script name
Expand Down

0 comments on commit 4e784d4

Please sign in to comment.