Skip to content

Commit

Permalink
Merge pull request #10 from Riimu/add-php82-support
Browse files Browse the repository at this point in the history
Add support for php 8.2
  • Loading branch information
Riimu authored Dec 10, 2022
2 parents 09634d2 + f8e646f commit 72ff782
Show file tree
Hide file tree
Showing 16 changed files with 194 additions and 137 deletions.
6 changes: 4 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
* text eol=lf

# Remove developer files from exports
.github export-ignore
tests export-ignore

.gitattributes export-ignore
.github export-ignore
.gitignore export-ignore
.php_cs export-ignore
.php-cs-fixer.php export-ignore
.phpcs.xml export-ignore
.travis.yml export-ignore
phpunit.xml export-ignore
sami_config.php export-ignore
19 changes: 19 additions & 0 deletions .github/actions/setup-composer/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: "Setup Composer"
description: "Sets up the composer dependencies"
runs:
using: "composite"
steps:
- name: Get Composer Cache Directory
id: composer-cache
shell: bash
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install dependencies
run: composer install --no-progress --prefer-dist --classmap-authoritative --no-interaction
shell: bash
100 changes: 57 additions & 43 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,74 +8,88 @@ on:
workflow_dispatch:

jobs:
tests:
PHPUnit:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0']
operating-system: [ 'ubuntu-latest', 'windows-latest', 'macos-latest' ]
php-versions: [ '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1' , '8.2']
runs-on: ${{ matrix.operating-system }}
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
coverage: none
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v2
ini-values: error_reporting=E_ALL
- name: Setup Composer
uses: ./.github/actions/setup-composer
- name: Install PHPUnit
run: composer require --dev phpunit/phpunit
- name: Run PHPUnit
run: composer test
PHP_CodeSniffer:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
run: composer install --no-progress --prefer-dist --classmap-authoritative --no-interaction
- name: Setup problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Test with phpunit
run: vendor/bin/phpunit
lint:
php-version: latest
coverage: none
tools: phpcs
- name: Setup Composer
uses: ./.github/actions/setup-composer
- name: Run PHP_CodeSniffer
run: composer phpcs -- --no-cache
PHP-CS-Fixer:
runs-on: ubuntu-latest
env:
PHP_CS_FIXER_IGNORE_ENV: 1
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: latest
coverage: none
tools: cs2pr, php-cs-fixer, phpcs
tools: php-cs-fixer
- name: Setup Composer
uses: ./.github/actions/setup-composer
- name: Run PHP Coding Standards Fixer
run: php-cs-fixer fix --dry-run --using-cache=no --format=checkstyle | cs2pr
- name: Run PHP_CodeSniffer
run: phpcs --standard=PSR12 --exclude=PSR12.Properties.ConstantVisibility -q --report=checkstyle src tests | cs2pr
run: composer php-cs-fixer -- --dry-run --diff --using-cache=no
composer-normalize:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: latest
coverage: none
tools: composer-normalize
- name: Setup Composer
uses: ./.github/actions/setup-composer
- name: Run composer-normalize
run: composer-normalize --dry-run
coverage:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
php-version: latest
coverage: xdebug
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
run: composer install --no-progress --prefer-dist --classmap-authoritative --no-interaction
- name: Setup problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Test with phpunit
run: vendor/bin/phpunit --coverage-clover coverage.xml
tools: phpunit
- name: Setup Composer
uses: ./.github/actions/setup-composer
- name: Run PHPUnit with coverage
run: composer test -- --do-not-cache-result --coverage-clover coverage.xml
- name: Upload coverage
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v3
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
build/
vendor/
.phpunit.result.cache
.phpunit.cache
.php-cs-fixer.cache
examples/dbconf.php
composer.lock
64 changes: 19 additions & 45 deletions .php_cs → .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,52 +4,43 @@
->in(__DIR__ . '/src')
->in(__DIR__ . '/tests');

return \PhpCsFixer\Config::create()
return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules([
'@PSR2' => true,
'@PSR12' => true,

'align_multiline_comment' => true,
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'backtick_to_shell_exec' => true,
'array_syntax' => [
'syntax' => 'short'
],
'binary_operator_spaces' => true,
'blank_line_after_opening_tag' => true,
'cast_spaces' => true,
'class_attributes_separation' => ['elements' => ['method']],
'combine_consecutive_issets' => true,
'class_attributes_separation' => ['elements' => ['method' => 'one']],
'combine_consecutive_unsets' => true,
'concat_space' => ['spacing' => 'one'],
'concat_space' => [
'spacing' => 'one'
],
'declare_equal_normalize' => true,
'dir_constant' => true,
'ereg_to_preg' => true,
'fully_qualified_strict_types' => true,
'function_to_constant' => true,
'function_typehint_space' => true,
'heredoc_to_nowdoc' => true,
'include' => true,
'is_null' => true,
'list_syntax' => ['syntax' => 'short'],
'logical_operators' => true,
'lowercase_cast' => true,
'lowercase_static_reference' => true,
'magic_constant_casing' => true,
'modernize_types_casting' => true,
'multiline_comment_opening_closing' => true,
'multiline_whitespace_before_semicolons' => true,
'native_constant_invocation' => true,
'modernize_types_casting' => true,
'native_function_casing' => true,
'native_function_invocation' => ['include' => ['@compiler_optimized']],
'new_with_braces' => true,
'no_alias_functions' => true,
'no_binary_string' => true,
'no_blank_lines_after_class_opening' => true,
'no_blank_lines_after_phpdoc' => true,
'no_empty_comment' => true,
'no_empty_phpdoc' => true,
'no_empty_statement' => true,
'no_extra_blank_lines' => true,
'no_homoglyph_names' => true,
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_mixed_echo_print' => true,
Expand All @@ -58,68 +49,51 @@
'no_short_bool_cast' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_spaces_around_offset' => true,
'no_trailing_comma_in_list_call' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_trailing_comma_in_singleline' => true,
'no_unneeded_control_parentheses' => true,
'no_unneeded_curly_braces' => true,
'no_unneeded_final_method' => true,
'no_unreachable_default_argument_value' => true,
'no_unused_imports' => true,
'no_useless_return' => true,
'no_whitespace_before_comma_in_array' => true,
'no_whitespace_in_blank_line' => true,
'non_printable_character' => true,
'normalize_index_brace' => true,
'object_operator_without_whitespace' => true,
'ordered_class_elements' => ['order' => ['use_trait', 'constant', 'property', 'construct', 'method']],
'ordered_class_elements' => [
'order' => ['use_trait', 'constant', 'property', 'construct', 'method'],
],
'ordered_imports' => true,
'php_unit_construct' => true,
'php_unit_dedicate_assert' => ['target' => 'newest'],
'php_unit_expectation' => true,
'php_unit_mock' => true,
'php_unit_namespaced' => true,
'php_unit_no_expectation_annotation' => true,
'php_unit_set_up_tear_down_visibility' => true,
'php_unit_dedicate_assert' => true,
'php_unit_strict' => true,
'php_unit_test_case_static_method_calls' => ['call_type' => 'this'],
'phpdoc_add_missing_param_annotation' => true,
'phpdoc_align' => ['align' => 'left'],
'phpdoc_annotation_without_dot' => true,
'phpdoc_indent' => true,
'phpdoc_inline_tag' => true,
'phpdoc_inline_tag_normalizer' => true,
'phpdoc_no_access' => true,
'phpdoc_no_alias_tag' => true,
'phpdoc_no_package' => true,
'phpdoc_no_useless_inheritdoc' => true,
'phpdoc_return_self_reference' => true,
'phpdoc_scalar' => true,
'phpdoc_single_line_var_spacing' => true,
'phpdoc_summary' => true,
'phpdoc_to_comment' => true,
'phpdoc_trim' => true,
'phpdoc_trim_consecutive_blank_line_separation' => true,
'phpdoc_types' => true,
'phpdoc_var_without_name' => true,
'pow_to_exponentiation' => true,
'psr4' => true,
'psr_autoloading' => true,
'return_type_declaration' => true,
'self_accessor' => true,
'semicolon_after_instruction' => true,
'set_type_to_cast' => true,
'short_scalar_cast' => true,
'simplified_null_return' => true,
'single_blank_line_before_namespace' => true,
'single_line_comment_style' => true,
'single_quote' => true,
'space_after_semicolon' => true,
'standardize_increment' => true,
'standardize_not_equals' => true,
'strict_comparison' => true,
'strict_param' => true,
'ternary_operator_spaces' => true,
'ternary_to_null_coalescing' => true,
'trailing_comma_in_multiline_array' => true,
'trailing_comma_in_multiline' => true,
'trim_array_spaces' => true,
'visibility_required' => ['elements' => ['property', 'method']],
'whitespace_after_comma_in_array' => true,
])
->setFinder($finder);
14 changes: 14 additions & 0 deletions .phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0"?>
<ruleset name="Project Coding Standard">
<description>The coding standard configuration used for this project</description>

<file>./src/</file>
<file>./tests/</file>

<exclude-pattern>*/vendor/*</exclude-pattern>
<arg name="extensions" value="php" />

<rule ref="PSR12">
<exclude name="PSR12.Properties.ConstantVisibility" />
</rule>
</ruleset>
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog #

## v2.4.2 (2022-12-10) ##

* Added tests to ensure PHP 8.2 compatibility
* Changed `export` type object conversion have more consistent index order

## v2.4.1 (2020-11-29) ##

* Migrated to Github actions for CI
Expand Down
27 changes: 15 additions & 12 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
Copyright (c) 2013-2020 Riikka Kalliomäki
MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
Copyright (c) 2013-2022 Riikka Kalliomäki

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,6 @@ apply to following calls.

## Credits ##

This library is Copyright (c) 2013-2020 Riikka Kalliomäki.
This library is Copyright (c) 2013-2022 Riikka Kalliomäki.

See LICENSE for license and copying information.
Loading

0 comments on commit 72ff782

Please sign in to comment.