Skip to content

Commit 24c501c

Browse files
authored
Merge pull request #8 from MyZik/master
Add PHP 8 support
2 parents d899229 + f62c879 commit 24c501c

File tree

8 files changed

+1243
-565
lines changed

8 files changed

+1243
-565
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
/composer.phar
33
/vendor/
44
/phpunit.xml
5+
.phpunit.result.cache

.travis.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ cache:
77
- "$HOME/.composer/cache"
88

99
php:
10-
- 7.0
11-
- 7.1
10+
- 7.3
11+
- 7.4
12+
- 8.0
1213
- nightly
1314
- hhvm
1415

16+
1517
matrix:
1618
allow_failures:
1719
- php: nightly
@@ -30,7 +32,7 @@ install:
3032

3133
script:
3234
- composer check-code
33-
- if [ "$TRAVIS_PHP_VERSION" == "7.1" ]; then composer test-cov; else composer test; fi
35+
- if [ "$TRAVIS_PHP_VERSION" == "8.0" ]; then composer test-cov; else composer test; fi
3436

3537
after_script:
36-
- if [ "$TRAVIS_PHP_VERSION" == "7.1" ]; then composer test-cov-upload; fi
38+
- if [ "$TRAVIS_PHP_VERSION" == "8.0" ]; then composer test-cov-upload; fi

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ composer require php-telegram-bot/inline-keyboard-pagination:^1.0.0
2929
```php
3030
$items = range(1, 100); // required.
3131
$command = 'testCommand'; // optional. Default: pagination
32-
$selected_page = 10; // optional. Default: 1
32+
$selectedPage = 10; // optional. Default: 1
3333
$labels = [ // optional. Change button labels (showing defaults)
3434
'default' => '%d',
3535
'first' => '« %d',
@@ -40,7 +40,7 @@ $labels = [ // optional. Change button labels (showing defau
4040
];
4141

4242
// optional. Change the callback_data format, adding placeholders for data (showing default)
43-
$callback_data_format = 'command={COMMAND}&oldPage={OLD_PAGE}&newPage={NEW_PAGE}'
43+
$callbackDataFormat = 'command={COMMAND}&oldPage={OLD_PAGE}&newPage={NEW_PAGE}'
4444
```
4545

4646
### How To Use
@@ -49,13 +49,13 @@ $callback_data_format = 'command={COMMAND}&oldPage={OLD_PAGE}&newPage={NEW_PAGE}
4949
$ikp = new InlineKeyboardPagination($items, $command);
5050
$ikp->setMaxButtons(7, true); // Second parameter set to always show 7 buttons if possible.
5151
$ikp->setLabels($labels);
52-
$ikp->setCallbackDataFormat($callback_data_format);
52+
$ikp->setCallbackDataFormat($callbackDataFormat);
5353

5454
// Get pagination.
55-
$pagination = $ikp->getPagination($selected_page);
55+
$pagination = $ikp->getPagination($selectedPage);
5656

5757
// or, in 2 steps.
58-
$ikp->setSelectedPage($selected_page);
58+
$ikp->setSelectedPage($selectedPage);
5959
$pagination = $ikp->getPagination();
6060
```
6161

@@ -82,7 +82,7 @@ To get the callback data, you can use the provided helper method (only works whe
8282
// e.g. Callback data.
8383
$callback_data = 'command=testCommand&oldPage=10&newPage=1';
8484

85-
$params = InlineKeyboardPagination::getParametersFromCallbackData($callback_data);
85+
$params = InlineKeyboardPagination::getParametersFromCallbackData($callbackData);
8686

8787
//$params = [
8888
// 'command' => 'testCommand',
@@ -91,7 +91,7 @@ $params = InlineKeyboardPagination::getParametersFromCallbackData($callback_data
9191
//];
9292

9393
// or, just use PHP directly if you like. (literally what the helper does!)
94-
parse_str($callback_data, $params);
94+
parse_str($callbackData, $params);
9595
```
9696

9797
## Code Quality

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@
2424
}
2525
],
2626
"require": {
27-
"php": "^7.0"
27+
"php": "^7.3|^8.0"
2828
},
2929
"require-dev": {
3030
"jakub-onderka/php-parallel-lint": "^0.9.2",
31-
"phpunit/phpunit": "^6.3",
31+
"php-parallel-lint/php-parallel-lint": "v1.2.0",
32+
"phpunit/phpunit": "^9.5.2",
3233
"squizlabs/php_codesniffer": "^3.0"
3334
},
3435
"autoload": {

0 commit comments

Comments
 (0)