Skip to content

Commit

Permalink
Merge pull request #5 from Riimu/add-php82-support
Browse files Browse the repository at this point in the history
Add php 8.2 support
  • Loading branch information
Riimu authored Dec 13, 2022
2 parents 6fdc2dd + dcb05f1 commit 483d980
Show file tree
Hide file tree
Showing 21 changed files with 354 additions and 153 deletions.
8 changes: 5 additions & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
* text eol=lf

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

.gitattributes export-ignore
.gitignore export-ignore
.php_cs export-ignore
.travis.yml export-ignore
.php-cs-fixer.php export-ignore
.phpcs.xml export-ignore
composer.lock
phpunit.xml export-ignore
sami_config.php export-ignore
47 changes: 47 additions & 0 deletions .github/actions/prepare-composer/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: "Prepare Composer"
description: "Sets up the environment with specific global composer package"
inputs:
token:
description: "Authentication token for setup-php"
required: true
package:
description: "Global composer package to set up"
required: true
php-version:
description: "Version for PHP runtime"
default: "8.2"
coverage:
description: "Type of PHP code coverage to set up"
default: "none"
allow-plugins:
description: "Whether to allow plugins for the composer package or not"
default: "0"
runs:
using: "composite"
steps:
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ inputs.php-version }}
coverage: ${{ inputs.coverage }}
ini-values: error_reporting=E_ALL
env:
GITHUB_TOKEN: ${{ inputs.token }}
- run: composer global require --no-install "${{ inputs.package }}:*"
shell: bash
- run: composer global config "allow-plugins.${{ inputs.package }}" true
if: ${{ inputs.allow-plugins == 1 }}
shell: bash
- run: cp "$(composer config home)/composer.lock" ./composer.global.lock
shell: bash
- run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
id: composer-cache
shell: bash
- uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: Composer-${{ inputs.php-version }}-${{ hashFiles('./composer.lock', './composer.global.lock') }}
restore-keys: Composer-${{ inputs.php-version }}-
- run: composer install --no-progress --classmap-authoritative
shell: bash
- run: composer global install --no-progress --classmap-authoritative
shell: bash
81 changes: 81 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:

jobs:
PHPUnit:
strategy:
matrix:
operating-system: ["ubuntu-latest", "windows-latest", "macos-latest"]
php-version: ["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@v3
- name: Prepare Composer
uses: ./.github/actions/prepare-composer
with:
token: ${{ secrets.GITHUB_TOKEN }}
php-version: ${{ matrix.php-version }}
package: phpunit/phpunit
- name: Run PHPUnit
run: composer test
PHP_CodeSniffer:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Prepare Composer
uses: ./.github/actions/prepare-composer
with:
token: ${{ secrets.GITHUB_TOKEN }}
package: squizlabs/php_codesniffer
- 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@v3
- name: Prepare Composer
uses: ./.github/actions/prepare-composer
with:
token: ${{ secrets.GITHUB_TOKEN }}
package: friendsofphp/php-cs-fixer
- name: Run PHP Coding Standards Fixer
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: Prepare Composer
uses: ./.github/actions/prepare-composer
with:
token: ${{ secrets.GITHUB_TOKEN }}
package: ergebnis/composer-normalize
allow-plugins: 1
- name: Run composer-normalize
run: composer normalize --dry-run
coverage:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Prepare Composer
uses: ./.github/actions/prepare-composer
with:
token: ${{ secrets.GITHUB_TOKEN }}
package: phpunit/phpunit
coverage: xdebug
- name: Run PHPUnit with coverage
run: composer test -- --do-not-cache-result --coverage-clover coverage.xml
- name: Upload coverage
uses: codecov/codecov-action@v3
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.phpunit.cache
build/
vendor/
composer.lock

.php-cs-fixer.cache
28 changes: 13 additions & 15 deletions .php_cs → .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,18 @@
->in(__DIR__ . '/src')
->in(__DIR__ . '/tests');

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

'array_syntax' => [
'syntax' => 'short'
],
'binary_operator_spaces' => [
'align_double_arrow' => null,
'align_equals' => false,
],
'binary_operator_spaces' => true,
'blank_line_after_opening_tag' => true,
'cast_spaces' => true,
'class_attributes_separation' => ['elements' => ['method' => 'one']],
'combine_consecutive_unsets' => true,
'concat_space' => [
'spacing' => 'one'
Expand All @@ -26,13 +25,12 @@
'ereg_to_preg' => true,
'function_to_constant' => true,
'function_typehint_space' => true,
'hash_to_slash_comment' => true,
'heredoc_to_nowdoc' => true,
'include' => true,
'is_null' => true,
'lowercase_cast' => true,
'magic_constant_casing' => true,
'method_separation' => true,
'multiline_whitespace_before_semicolons' => true,
'modernize_types_casting' => true,
'native_function_casing' => true,
'new_with_braces' => true,
Expand All @@ -42,18 +40,16 @@
'no_empty_comment' => true,
'no_empty_phpdoc' => true,
'no_empty_statement' => true,
'no_extra_consecutive_blank_lines' => true,
'no_extra_blank_lines' => true,
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_mixed_echo_print' => true,
'no_multiline_whitespace_around_double_arrow' => true,
'no_multiline_whitespace_before_semicolons' => true,
'no_php4_constructor' => true,
'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_unused_imports' => true,
'no_useless_return' => true,
Expand All @@ -72,7 +68,7 @@
'phpdoc_add_missing_param_annotation' => true,
'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,
Expand All @@ -83,19 +79,21 @@
'phpdoc_types' => true,
'phpdoc_var_without_name' => true,
'pow_to_exponentiation' => true,
'psr4' => true,
'psr_autoloading' => true,
'return_type_declaration' => true,
'self_accessor' => true,
'short_scalar_cast' => true,
'single_blank_line_before_namespace' => true,
'single_line_comment_style' => true,
'single_quote' => true,
'space_after_semicolon' => true,
'standardize_not_equals' => true,
'strict_comparison' => true,
'strict_param' => true,
'ternary_operator_spaces' => 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>
31 changes: 0 additions & 31 deletions .travis.yml

This file was deleted.

9 changes: 7 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# Changelog #

## Unreleased
## v2.2.0 (2022-12-13) ##

* Add support for PHP 8.2
* Fix passing nulls to string functions
* Deprecated `UriParser::MODE_IDNA2003`
* Added `UriParser::MODE_IDNA`, which should be used instead
* Internally, the parser will now use UTS46 mode whenever it is available
* Minor bundled autoloader improvements
* Minor improvements to the build process
* Address minor code quality issues in tests
* Update CI to use Github Actions

## v2.1.0 (2017-06-30) ##

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-2017 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.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ and IDN ascii formats.

The API documentation is available at: http://kit.riimu.net/api/urlparser/

[![Travis](https://img.shields.io/travis/Riimu/Kit-UrlParser.svg?style=flat-square)](https://travis-ci.org/Riimu/Kit-UrlParser)
[![Scrutinizer](https://img.shields.io/scrutinizer/g/Riimu/Kit-UrlParser.svg?style=flat-square)](https://scrutinizer-ci.com/g/Riimu/Kit-UrlParser/)
[![Scrutinizer Coverage](https://img.shields.io/scrutinizer/coverage/g/Riimu/Kit-UrlParser.svg?style=flat-square)](https://scrutinizer-ci.com/g/Riimu/Kit-UrlParser/)
[![CI](https://img.shields.io/github/workflow/status/Riimu/Kit-UrlParser/CI/main?style=flat-square)](https://github.com/Riimu/Kit-UrlParser/actions)
[![Scrutinizer](https://img.shields.io/scrutinizer/quality/g/Riimu/Kit-UrlParser/main?style=flat-square)](https://scrutinizer-ci.com/g/Riimu/Kit-UrlParser/)
[![codecov](https://img.shields.io/codecov/c/github/Riimu/Kit-UrlParser/main?style=flat-square)](https://codecov.io/gh/Riimu/Kit-UrlParser)
[![Packagist](https://img.shields.io/packagist/v/riimu/kit-urlparser.svg?style=flat-square)](https://packagist.org/packages/riimu/kit-urlparser)

## Requirements ##
Expand Down Expand Up @@ -329,15 +329,15 @@ echo $uri->getPath(); // Outputs: /f%C3%B6%C3%B6/b%C3%A4r.html

UTF-8 characters in the domain name, however, are a bit more complex issue. The
parser, however, does provide a rudimentary support for parsing these domain
names using the IDNA2003 mode. For example:
names using the IDNA mode. For example:

```php
<?php

require 'vendor/autoload.php';

$parser = new \Riimu\Kit\UrlParser\UriParser();
$parser->setMode(\Riimu\Kit\UrlParser\UriParser::MODE_IDNA2003);
$parser->setMode(\Riimu\Kit\UrlParser\UriParser::MODE_IDNA);

$uri = $parser->parse('http://www.fööbär.com');
echo $uri->getHost(); // Outputs: www.xn--fbr-rla2ga.com
Expand Down Expand Up @@ -376,6 +376,6 @@ may encounter are as follows:

## Credits ##

This library is Copyright (c) 2013-2017 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 483d980

Please sign in to comment.