Skip to content

Commit 08bfaee

Browse files
committed
Move to laravel/serializable-closure
1 parent f2f3a46 commit 08bfaee

File tree

6 files changed

+21
-16
lines changed

6 files changed

+21
-16
lines changed

composer.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,21 @@
88
"Chatbot"
99
],
1010
"homepage": "http://github.com/botman/botman",
11-
"authors": [{
12-
"name": "Marcel Pociot",
13-
"email": "m.pociot@gmail.com"
14-
}],
11+
"authors": [
12+
{
13+
"name": "Marcel Pociot",
14+
"email": "m.pociot@gmail.com"
15+
}
16+
],
1517
"require": {
1618
"php": ">=7.1",
1719
"symfony/http-foundation": "^2.8 || ^3.0 || ^4.0 || ^5.0 || ^6.0",
1820
"tightenco/collect": "^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0",
19-
"opis/closure": "^2.3 || ^3.0",
2021
"mpociot/pipeline": "^1.0.2",
2122
"react/socket": "~1.0",
2223
"spatie/macroable": "^1.0",
23-
"psr/container": "^1.0 || ^2.0"
24+
"psr/container": "^1.0 || ^2.0",
25+
"laravel/serializable-closure": "^1.0"
2426
},
2527
"require-dev": {
2628
"codeigniter/framework": "~3.0",

src/BotMan.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ public function __call($name, $arguments)
759759
$arguments[] = $this->getMessage();
760760
$arguments[] = $this;
761761

762-
return \call_user_func_array([$this->getDriver(), $name], $arguments);
762+
return \call_user_func_array([$this->getDriver(), $name], array_values($arguments));
763763
}
764764

765765
throw new BadMethodCallException('Method [' . $name . '] does not exist.');

src/BotManFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static function extend($methodName, $callable)
3333
public static function __callStatic($name, $arguments)
3434
{
3535
try {
36-
return \call_user_func_array(self::$extensions[$name], $arguments);
36+
return \call_user_func_array(self::$extensions[$name], array_values($arguments));
3737
} catch (\Exception $e) {
3838
throw new \BadMethodCallException("Method [$name] does not exist.");
3939
}

src/Messages/Incoming/IncomingMessage.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function getText()
9393
*/
9494
public function getConversationIdentifier()
9595
{
96-
return 'conversation-'.$this->bot_id.sha1($this->getSender()).'-'.sha1($this->getRecipient());
96+
return 'conversation-' . $this->bot_id . sha1((string)$this->getSender()) . '-' . sha1((string)$this->getRecipient());
9797
}
9898

9999
/**
@@ -103,7 +103,7 @@ public function getConversationIdentifier()
103103
*/
104104
public function getOriginatedConversationIdentifier()
105105
{
106-
return 'conversation-'.$this->bot_id.sha1($this->getSender()).'-'.sha1('');
106+
return 'conversation-' . $this->bot_id . sha1((string)$this->getSender()) . '-' . sha1('');
107107
}
108108

109109
/**
@@ -124,7 +124,7 @@ public function addExtras($key, $value)
124124
*/
125125
public function getExtras($key = null)
126126
{
127-
if (! is_null($key)) {
127+
if (!is_null($key)) {
128128
return Collection::make($this->extras)->get($key);
129129
}
130130

src/Traits/HandlesConversations.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use BotMan\BotMan\Messages\Outgoing\Question;
1010
use Closure;
1111
use Illuminate\Support\Collection;
12-
use Opis\Closure\SerializableClosure;
12+
use Laravel\SerializableClosure\SerializableClosure;
1313

1414
trait HandlesConversations
1515
{
@@ -308,14 +308,14 @@ protected function prepareConversationClosure($next, Conversation $conversation,
308308

309309
$parameters[] = $conversation;
310310

311-
call_user_func_array($next, $parameters);
311+
call_user_func_array($next, array_values($parameters));
312312

313313
/*
314314
// TODO: Needs more work
315315
if (class_exists('Illuminate\\Support\\Facades\\App')) {
316316
\Illuminate\Support\Facades\App::call($next, $parameters);
317317
} else {
318-
call_user_func_array($next, $parameters);
318+
call_user_func_array($next, array_values($parameters));
319319
}
320320
// */
321321
}

tests/Messages/QuestionTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@
44

55
use BotMan\BotMan\Messages\Outgoing\Actions\Button;
66
use BotMan\BotMan\Messages\Outgoing\Question;
7+
use DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts;
78
use PHPUnit\Framework\TestCase;
89

910
class QuestionTest extends TestCase
1011
{
12+
use ArraySubsetAsserts;
13+
1114
/** @test */
1215
public function it_can_be_created()
1316
{
@@ -49,14 +52,14 @@ public function it_can_add_buttons()
4952
public function it_can_add_a_callback_id()
5053
{
5154
$message = Question::create('foo')->callbackId('callback');
52-
$this->assertArraySubset(['callback_id' => 'callback'], $message->toArray());
55+
self::assertArraySubset(['callback_id' => 'callback'], $message->toArray());
5356
}
5457

5558
/** @test */
5659
public function it_can_add_a_fallback()
5760
{
5861
$message = Question::create('foo')->fallback('fallback');
59-
$this->assertArraySubset(['fallback' => 'fallback'], $message->toArray());
62+
self::assertArraySubset(['fallback' => 'fallback'], $message->toArray());
6063
}
6164

6265
/** @test */

0 commit comments

Comments
 (0)