Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PHP 8 support #8

Merged
merged 7 commits into from
Feb 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/composer.phar
/vendor/
/phpunit.xml
.phpunit.result.cache
10 changes: 6 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ cache:
- "$HOME/.composer/cache"

php:
- 7.0
MyZik marked this conversation as resolved.
Show resolved Hide resolved
- 7.1
- 7.3
- 7.4
- 8.0
- nightly
- hhvm


matrix:
allow_failures:
- php: nightly
Expand All @@ -30,7 +32,7 @@ install:

script:
- composer check-code
- if [ "$TRAVIS_PHP_VERSION" == "7.1" ]; then composer test-cov; else composer test; fi
MyZik marked this conversation as resolved.
Show resolved Hide resolved
- if [ "$TRAVIS_PHP_VERSION" == "8.0" ]; then composer test-cov; else composer test; fi

after_script:
- if [ "$TRAVIS_PHP_VERSION" == "7.1" ]; then composer test-cov-upload; fi
- if [ "$TRAVIS_PHP_VERSION" == "8.0" ]; then composer test-cov-upload; fi
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ composer require php-telegram-bot/inline-keyboard-pagination:^1.0.0
```php
$items = range(1, 100); // required.
$command = 'testCommand'; // optional. Default: pagination
$selected_page = 10; // optional. Default: 1
$selectedPage = 10; // optional. Default: 1
$labels = [ // optional. Change button labels (showing defaults)
'default' => '%d',
'first' => '« %d',
Expand All @@ -40,7 +40,7 @@ $labels = [ // optional. Change button labels (showing defau
];

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

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

// Get pagination.
$pagination = $ikp->getPagination($selected_page);
$pagination = $ikp->getPagination($selectedPage);

// or, in 2 steps.
$ikp->setSelectedPage($selected_page);
$ikp->setSelectedPage($selectedPage);
$pagination = $ikp->getPagination();
```

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

$params = InlineKeyboardPagination::getParametersFromCallbackData($callback_data);
$params = InlineKeyboardPagination::getParametersFromCallbackData($callbackData);

//$params = [
// 'command' => 'testCommand',
Expand All @@ -91,7 +91,7 @@ $params = InlineKeyboardPagination::getParametersFromCallbackData($callback_data
//];

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

## Code Quality
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@
}
],
"require": {
"php": "^7.0"
MyZik marked this conversation as resolved.
Show resolved Hide resolved
"php": "^7.3|^8.0"
},
"require-dev": {
"jakub-onderka/php-parallel-lint": "^0.9.2",
"phpunit/phpunit": "^6.3",
"php-parallel-lint/php-parallel-lint": "v1.2.0",
"phpunit/phpunit": "^9.5.2",
"squizlabs/php_codesniffer": "^3.0"
},
"autoload": {
Expand Down
Loading