Skip to content

Commit

Permalink
fix: undefined index when running programmatically
Browse files Browse the repository at this point in the history
Closes: #35
  • Loading branch information
marcocesarato committed Oct 3, 2021
1 parent 49a5aad commit fb265fa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/Console/Argv.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ public function setExamples($examples)
/**
* Parse argvs.
*
* @param null $args
* @param array $args
*/
public function parse($args = null)
public function parse($args = [])
{
if (empty($args)) {
$args = array_slice($_SERVER['argv'], 1); // First argument removed (php [index.php.php] [<path>] [<functions>])
if (empty($args) && !empty($_SERVER['argv'])) {
$args = array_slice($_SERVER['argv'], 1); // First argument removed (php [scanner.php] [<path>] [<functions>])
}

foreach ($args as $pos => $arg) {
Expand Down
6 changes: 3 additions & 3 deletions src/Scanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ private function init()
*
* @return bool|object
*/
public function run($args = null)
public function run($args = [])
{
$this->interrupt = false;

Expand Down Expand Up @@ -408,9 +408,9 @@ public function run($args = null)
/**
* Initialize application arguments.
*
* @param null $args
* @param array $args
*/
private function arguments($args = null)
private function arguments($args = [])
{
$isCLI = self::isCli();
self::$argv = new Argv(self::getLowerName(), self::getDescription());
Expand Down

0 comments on commit fb265fa

Please sign in to comment.