Skip to content

Commit 97cd061

Browse files
committed
Added Button intermediate type
1 parent 5b32e14 commit 97cd061

File tree

6 files changed

+20
-9
lines changed

6 files changed

+20
-9
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
}
2121
},
2222
"require": {
23-
"php": "^7.3|^8.0"
23+
"php": "^8.0"
2424
},
2525
"require-dev": {
2626
"pestphp/pest": "^1.21",

src/Button.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
namespace PhpTelegramBot\FluentKeyboard;
4+
5+
abstract class Button extends FluentEntity
6+
{
7+
8+
}

src/InlineKeyboard/InlineKeyboardButton.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace PhpTelegramBot\FluentKeyboard\InlineKeyboard;
44

5+
use PhpTelegramBot\FluentKeyboard\Button;
56
use PhpTelegramBot\FluentKeyboard\FluentEntity;
67

78
/**
@@ -14,7 +15,7 @@
1415
* @method self callbackGame(string $callback_game)
1516
* @method self pay(bool $pay = true)
1617
*/
17-
class InlineKeyboardButton extends FluentEntity
18+
class InlineKeyboardButton extends Button
1819
{
1920

2021
protected $defaults = [

src/KeyboardMarkup.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function __construct(array $data = [])
2525
/**
2626
* Adds a new row to the keyboard.
2727
*
28-
* @param array $buttons
28+
* @param Button[] $buttons
2929
* @return $this
3030
*/
3131
public function row(array $buttons = [])
@@ -50,7 +50,7 @@ public function row(array $buttons = [])
5050
/**
5151
* Adds buttons one per row to the keyboard.
5252
*
53-
* @param array $buttons
53+
* @param Button[] $buttons
5454
* @return $this
5555
*/
5656
public function stack(array $buttons)
@@ -66,10 +66,10 @@ public function stack(array $buttons)
6666
/**
6767
* Adds a button to the last row.
6868
*
69-
* @param \JsonSerializable $button
69+
* @param Button $button
7070
* @return $this
7171
*/
72-
public function button(\JsonSerializable $button)
72+
public function button(Button $button)
7373
{
7474
$keyboard = &$this->data[static::$keyboardFieldName];
7575

src/ReplyKeyboard/KeyboardButton.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
namespace PhpTelegramBot\FluentKeyboard\ReplyKeyboard;
44

5-
use PhpTelegramBot\FluentKeyboard\FluentEntity;
5+
use PhpTelegramBot\FluentKeyboard\Button;
66

77
/**
88
* @method self text(string $text)
99
* @method self requestContact(bool $request_contact = true)
1010
* @method self requestLocation(bool $request_location = true)
1111
* @method self requestPoll(KeyboardButtonPollType|array $request_poll = [])
1212
*/
13-
class KeyboardButton extends FluentEntity
13+
class KeyboardButton extends Button
1414
{
1515
protected $defaults = [
1616
'request_contact' => true,

src/ReplyKeyboard/KeyboardButtonPollType.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
namespace PhpTelegramBot\FluentKeyboard\ReplyKeyboard;
44

5-
class KeyboardButtonPollType implements \JsonSerializable
5+
use PhpTelegramBot\FluentKeyboard\Button;
6+
7+
class KeyboardButtonPollType extends Button
68
{
79

810
protected $data = [];

0 commit comments

Comments
 (0)