Botman: Web driver php 8 error: Cannot use positional argument after named argument

Created on 1 Mar 2021  路  3Comments  路  Source: botman/botman

  • BotMan Version: 2.6.1
  • PHP Version: 8.0.2
  • Messaging Service(s): Web
  • Cache Driver: laravel file driver

Description:

Error:
Cannot use positional argument after named argument {"exception":"[object] (Error(code: 0): Cannot use positional argument after named argument at ..../vendor/botman/botman/src/BotMan.php:495)

Tried to change the order to first positional followed by the named arguments:
in BotMan.php line 474 to 487:
image
(didn't change comments, so they are invalid)

But that ends in another error:
Named parameter $id overwrites previous argument {"exception":"[object] (Error(code: 0): Named parameter $id overwrites previous argument at ..../vendor/botman/botman/src/BotMan.php:495)

The paramters I get from the matcher:
image
(after mentioned changes)

Steps To Reproduce:

Just started the conversation with the starting message "start72/de". 72 is $id and "de" is the $locale in my case
$bot->hears('start{id}/{locale}', function ($bot, $id, $locale) {...}

Most helpful comment

I had the same problem and solved it through array_values.

All 3 comments

@lostertschnig I bump into this problem too. For now there is no way to intercept MatchingMessage to modify matched arguments of a command. So, only way is to match not {named} but (\w+) or other regular expression type matches since they are not appear in resulting argument matches with string keys and not interfere with named arguments part of call_user_func_array.

Really wish to see fix for this problem, since it looks like it is the only one error blocking PHP 8 compability.

I had the same problem and solved it through array_values.

Welcome. As I see, some measures have already been taken to make Batman work on php 8. But I still get an error

Cannot use optional argument after named argument {"exception":"[object] (Error(code: 0): Cannot use optional argument after named argument at /home/web/web/staging/vendor/botman/botman/src/BotMan.php:495)

We found a solution and just corrected it in the vendor for now. But this is somehow wrong. Maybe there is already a solution and we are not looking for it there?

Was this page helpful?
0 / 5 - 0 ratings