Prevent infinite loop caused when argv not set.

If shell is invoked with the wrong PHP executable (not CLI) and argv is not an array,  array_search on null causes infinite number of error messages.
Merge pull request #3381 from planardothum/shell-requires-cli

Add check to abort if $argv is undefined.