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

v9 upgrades #677

Draft
wants to merge 19 commits into
base: master
Choose a base branch
from
Draft
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 3 additions & 5 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ tests/ export-ignore
.editorconfig export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.styleci.yml export-ignore
.travis.yml export-ignore
.php-cs-fixer.dist.php export-ignore
build.xml export-ignore
libphonenumber-for-php.spec export-ignore
phpunit.xml.dist export-ignore
phpunit export-ignore
.github/ export-ignore
src/CountryCodeToRegionCodeMapForTesting.php export-ignore

phpstan.neon.dist export-ignore
infection.json5 export-ignore

* text=auto
77 changes: 19 additions & 58 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Continuous Integration"
name: "Tests"

on:
push:
Expand All @@ -8,76 +8,37 @@ on:
paths-ignore:
- 'docs/**'

env:
COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --no-suggest --prefer-dist"
COVERAGE_FLAGS: "--coverage-text --coverage-clover build/logs/clover.xml"
SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT: "1"

jobs:
tests:
name: PHP ${{ matrix.php-version }}
name: PHP ${{ matrix.php-version }} - ${{ matrix.composer }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-version:
- "7.4"
- "8.0"
- "8.1"
- "8.2"
- "8.3"
- "8.4"
include:
- php-version: 8.3
coverage: coverage
php-version: [8.1, 8.2, 8.3, 8.4]
composer: [highest, lowest]

steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 10
uses: actions/checkout@v4

- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: dom
coverage: xdebug
env:
update: true
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Problem Matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- 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@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ matrix.php-version }}-composer-
- name: Install Composer
uses: nick-invision/retry@v1
tools: composer:v2

- uses: "ramsey/composer-install@v3"
with:
timeout_minutes: 10
max_attempts: 3
command: composer update ${{ env.COMPOSER_FLAGS }}
dependency-versions: "${{ matrix.composer }}"

- name: composer validate
run: composer validate --strict
- name: Test with phpunit (with coverage)
id: phpunit-coverage
if: "matrix.coverage == 'coverage'"
run: vendor/bin/phpunit --verbose ${{ env.COVERAGE_FLAGS }}
- name: Test with phpunit (without coverage)
if: "matrix.coverage != 'coverage'"
run: vendor/bin/phpunit --verbose
- name: Submit Coveralls
if: steps.phpunit-coverage.outcome == 'success'
uses: nick-invision/retry@v1
with:
timeout_minutes: 10
max_attempts: 3
command: |
[[ -f vendor/bin/php-coveralls ]] && COVERALLS_PATH=vendor/bin/php-coveralls || COVERALLS_PATH=vendor/bin/coveralls
[[ -n $COVERALLS_REPO_TOKEN ]] && php $COVERALLS_PATH -v --exclude-no-stmt || true
env:
COVERALLS_RUN_LOCALLY: 1
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}

- name: Run unit tests
run: "./vendor/bin/phpunit --colors=always --coverage-clover build/logs/clover.xml --coverage-text"

- name: Publish coverage report to Codecov
uses: "codecov/codecov-action@v5"
42 changes: 42 additions & 0 deletions .github/workflows/mutation-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: "Mutation tests"

on:
push:
branches:
- 'master'
paths-ignore:
- 'docs/**'
pull_request:
paths-ignore:
- 'docs/**'

jobs:
mutation-tests:
name: "Mutation tests"

runs-on: ubuntu-latest

strategy:
matrix:
php-version: [ 8.4 ]
composer: [ highest ]

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: dom
coverage: xdebug
tools: composer:v2

- uses: "ramsey/composer-install@v3"
with:
dependency-versions: "${{ matrix.composer }}"

- name: "Infection"
run: |
vendor/bin/infection --threads=max
31 changes: 31 additions & 0 deletions .github/workflows/sast.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: "SAST"

on:
push:
branches:
- 'master'
paths-ignore:
- 'docs/**'
pull_request:
paths-ignore:
- 'docs/**'

jobs:
phpstan:
name: "PHPStan"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: 8.3

- uses: "ramsey/composer-install@v3"
with:
dependency-versions: highest

- name: Run PHPStan
run: "composer run-script phpstan"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ composer.lock
libphonenumber-data-dir/
build/logs/
/.php-cs-fixer.cache
/infection.txt
/.phpunit.cache
18 changes: 15 additions & 3 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
return $config->setRules(
[
'@PER-CS2.0' => true,
'@PHP74Migration' => true,
'@PHP81Migration' => true,
'single_quote' => true,
'no_unused_imports' => true,
'no_superfluous_phpdoc_tags' => [
Expand All @@ -18,7 +18,19 @@
'remove_inheritdoc' => true,
],
'phpdoc_trim' => true,
'declare_strict_types' => true,
'php_unit_attributes' => true,
'@PHPUnit100Migration:risky' => true,
'global_namespace_import' => [
'import_classes' => true,
'import_constants' => true,
'import_functions' => true,
],
'no_empty_phpdoc' => true,
'phpdoc_align' => ['align' => 'left'],
'phpdoc_types' => true,
]
)
->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect())
->setFinder($finder);
->setRiskyAllowed(true)
->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect())
->setFinder($finder);
11 changes: 11 additions & 0 deletions METADATA-VERSION.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

declare(strict_types=1);

/**
* This file specifies the revision of the metadata to build from.
* It can be a commit, branch or tag of the https://github.com/google/libphonenumber project
* For more information, look at the phing tasks in build.xml
* @internal
*/
return 'v8.13.55';
5 changes: 0 additions & 5 deletions METADATA-VERSION.txt

This file was deleted.

8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ A PHP library for parsing, formatting, storing and validating international phon

## Installation

PHP versions 7.4 to PHP 8.4 are currently supported.
PHP versions 8.1 to 8.4 are currently supported.

The PECL [mbstring](http://php.net/mbstring) extension is required.

Expand All @@ -44,6 +44,10 @@ If you do not use composer, ensure that you also load any dependencies that this

If you only want to make use of the core PhoneNumber Util functionality, you can use [giggsey/libphonenumber-for-php-lite](https://github.com/giggsey/libphonenumber-for-php-lite), which offers a much smaller package size.

### PHP Version Policy

This library will be updated to use [supported versions of PHP](https://www.php.net/supported-versions.php) without major version bumps.

## Documentation

- [PhoneNumber Util](docs/PhoneNumberUtil.md)
Expand Down Expand Up @@ -244,7 +248,7 @@ If you do need to generate the data, the commands are provided by [Phing](https:
vendor/bin/phing compile
```

This compile process clones the [libphonenumber](https://github.com/google/libphonenumber) project at the version specified in [METADATA-VERSION.txt](METADATA-VERSION.txt).
This compile process clones the [libphonenumber](https://github.com/google/libphonenumber) project at the version specified in [METADATA-VERSION.php](METADATA-VERSION.php).

### Running tests

Expand Down
9 changes: 1 addition & 8 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,7 @@
<property name="git.url" value="https://github.com/google/libphonenumber.git"/>
<property name="git.path" value="libphonenumber-data-dir"/>

<loadfile property="metadata.version" file="METADATA-VERSION.txt">
<filterchain>
<striplinecomments>
<comment value="#" />
</striplinecomments>
<striplinebreaks />
</filterchain>
</loadfile>
<php returnProperty="metadata.version" expression="require 'METADATA-VERSION.php';" />

<property name="data.testCoreData" value="tests/core/data/"/>
<property name="data.testPrefixMapperData" value="tests/prefixmapper/data/"/>
Expand Down
5 changes: 5 additions & 0 deletions build/BuildApplication.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
<?php

declare(strict_types=1);

namespace libphonenumber\buildtools;

use libphonenumber\buildtools\Commands\BuildMetadataPHPFromXMLCommand;
use libphonenumber\buildtools\Commands\GeneratePhonePrefixDataCommand;
use libphonenumber\buildtools\Commands\GenerateTimeZonesMapDataCommand;
use Symfony\Component\Console\Application;

/**
* @internal
*/
class BuildApplication extends Application
{
public const VERSION = '5';
Expand Down
Loading