diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 18a4ff5..f4aa199 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -1,5 +1,6 @@ name: Bug report description: Report something that is not working as expected. +title: "[Bug]: " labels: - "type: bug" - "status: needs triage" diff --git a/.github/dependabot.yml b/.github/dependabot.yml index ddafb34..473f3fb 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,6 +5,8 @@ updates: - package-ecosystem: composer directory: "/" target-branch: develop + labels: + - "area: dependencies" schedule: interval: weekly groups: @@ -14,6 +16,8 @@ updates: - package-ecosystem: github-actions directory: "/" target-branch: develop + labels: + - "area: dependencies" schedule: interval: weekly groups: diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 41b5373..0687861 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,118 +1,214 @@ name: Build - -on: +'on': push: branches: - - '8.*.x' - - develop + - develop + - 8.*.x paths-ignore: - - 'README.md' - - 'docs/**' - + - README.md + - docs/** pull_request: branches: - - '8.*.x' - - develop - - workflow_dispatch: - -permissions: - contents: read - + - develop + - 8.*.x + workflow_dispatch: null concurrency: - group: ${{ github.workflow }}-${{ github.ref }} + group: build-${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true - +permissions: + contents: read jobs: - php: - name: Resolve PHP version + matrix: runs-on: ubuntu-latest outputs: - version: ${{ steps.php.outputs.version }} - + php: ${{ steps.php.outputs.versions }} + lowest: ${{ steps.php.outputs.lowest }} steps: - - name: Checkout - uses: actions/checkout@v7 - - # Every branch declares exactly one PHP minor (">=8.N <8.N+1"), so the - # version comes from composer.json on any branch. - - name: Detect target PHP version - id: php - shell: bash - run: | - constraint="$(jq -r '.require.php' composer.json)" - - if [[ ! "$constraint" =~ ^\>=(8\.[0-9]+) ]]; then - echo "Cannot read the target PHP minor from require.php: $constraint" >&2 - exit 1 - fi - - echo "version=${BASH_REMATCH[1]}" >> "$GITHUB_OUTPUT" - - check: - name: Check - needs: php + - name: Checkout + uses: actions/checkout@v7 + - name: Read supported PHP minors + id: php + shell: bash + run: | + constraint="$(jq -r '.require.php' composer.json)" + if [[ ! "$constraint" =~ ^\>=8\.([0-9]+)\ \<8\.([0-9]+)$ ]] || (( BASH_REMATCH[2] != BASH_REMATCH[1] + 1 )); then + echo "require.php must declare exactly one PHP minor as >=8.N <8.N+1, got: $constraint" >&2 + exit 1 + fi + version="8.${BASH_REMATCH[1]}" + echo "versions=$(jq -cn --arg php "$version" '[$php]')" >> "$GITHUB_OUTPUT" + echo "lowest=$version" >> "$GITHUB_OUTPUT" + validate: + needs: + - matrix runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v7 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ needs.php.outputs.version }} - extensions: mbstring, intl - coverage: none - tools: composer:v2 - - - name: Install dependencies - uses: ramsey/composer-install@v4 - - - name: Check - run: composer check - + - name: Checkout + uses: actions/checkout@v7 + - name: Setup PHP + uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # 2.40.0 + with: + php-version: ${{ needs.matrix.outputs.lowest }} + extensions: mbstring, intl + coverage: none + tools: composer:v2 + - name: Install dependencies + uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0 + with: + dependency-versions: highest + - name: Validate + run: composer validate --strict + style: + needs: + - matrix + - validate + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v7 + - name: Setup PHP + uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # 2.40.0 + with: + php-version: ${{ needs.matrix.outputs.lowest }} + extensions: mbstring, intl + coverage: none + tools: composer:v2 + - name: Install dependencies + uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0 + with: + dependency-versions: highest + - name: Style + run: composer format:check + analyse: + needs: + - matrix + - style + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v7 + - name: Setup PHP + uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # 2.40.0 + with: + php-version: ${{ needs.matrix.outputs.lowest }} + extensions: mbstring, intl + coverage: none + tools: composer:v2 + - name: Install dependencies + uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0 + with: + dependency-versions: highest + - name: Analyse + run: composer analyse tests: - name: Tests - ${{ matrix.os }} - ${{ matrix.dependencies }}${{ matrix.intl && ' - intl' || '' }} - needs: php - runs-on: ${{ matrix.os }} - + name: Tests - PHP ${{ matrix.php }} - ${{ matrix.os }} - ${{ matrix.dependencies }}${{ !matrix.intl && ' - without intl' || '' }} + needs: + - matrix + - analyse strategy: - max-parallel: 2 - - fail-fast: false - + fail-fast: true matrix: - os: - - ubuntu-latest - - windows-latest + php: ${{ fromJSON(needs.matrix.outputs.php) }} dependencies: - - lowest - - highest + - lowest + - highest + os: + - ubuntu-latest + - windows-latest intl: - - true + - true include: - # ext-intl is optional; the built-in formatters must work without it. - - os: ubuntu-latest - dependencies: highest - intl: false - + # ext-intl is optional: the built-in formatters must work without it. + - php: ${{ needs.matrix.outputs.lowest }} + dependencies: highest + os: ubuntu-latest + intl: false + runs-on: ${{ matrix.os }} + steps: + - name: Checkout + uses: actions/checkout@v7 + - name: Setup PHP + uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # 2.40.0 + with: + php-version: ${{ matrix.php }} + extensions: mbstring, ${{ matrix.intl && 'intl' || ':intl' }} + coverage: none + tools: composer:v2 + - name: Install dependencies + uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0 + with: + dependency-versions: ${{ matrix.dependencies }} + - name: Run tests + run: composer test + security: + needs: + - matrix + - tests + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v7 + - name: Setup PHP + uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # 2.40.0 + with: + php-version: ${{ needs.matrix.outputs.lowest }} + extensions: mbstring, intl + coverage: none + tools: composer:v2 + - name: Install dependencies + uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0 + with: + dependency-versions: highest + - name: Security audit + run: composer security + archive: + needs: + - matrix + - security + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v7 + - name: Setup PHP + uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # 2.40.0 + with: + php-version: ${{ needs.matrix.outputs.lowest }} + extensions: mbstring, intl + coverage: none + tools: composer:v2 + - name: Install dependencies + uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0 + with: + dependency-versions: highest + - name: Verify Composer archive + shell: bash + run: | + mkdir -p /tmp/pharaonic-ci-archive + composer archive --format=zip --dir=/tmp/pharaonic-ci-archive --file=package + unzip -t /tmp/pharaonic-ci-archive/package.zip + quality: + name: Quality gate + if: ${{ always() }} + needs: + - matrix + - validate + - style + - analyse + - tests + - security + - archive + runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v7 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ needs.php.outputs.version }} - extensions: mbstring, ${{ matrix.intl && 'intl' || ':intl' }} - coverage: none - tools: composer:v2 - - - name: Install dependencies - uses: ramsey/composer-install@v4 - with: - dependency-versions: ${{ matrix.dependencies }} - - - name: Run tests - run: composer test + - name: Require every stage to succeed + env: + NEEDS_JSON: ${{ toJSON(needs) }} + run: | + python3 - <<'PY_CHECK' + import json, os, sys + results = json.loads(os.environ['NEEDS_JSON']) + failed = {name: job['result'] for name, job in results.items() if job['result'] != 'success'} + if failed: + print('Required stages did not succeed:', failed) + sys.exit(1) + print('Every required stage succeeded.') + PY_CHECK diff --git a/.github/workflows/labels.yml b/.github/workflows/labels.yml index 8bdc79a..d96990d 100644 --- a/.github/workflows/labels.yml +++ b/.github/workflows/labels.yml @@ -22,7 +22,7 @@ jobs: # Creates and updates the labels in .github/labels.yml. Labels that are # not listed are left alone. - name: Sync labels - uses: crazy-max/ghaction-github-labeler@v5 + uses: crazy-max/ghaction-github-labeler@548a7c3603594ec17c819e1239f281a3b801ab4d # v6.0.0 with: yaml-file: .github/labels.yml skip-delete: true diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a57949..ae0018b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,18 @@ All notable changes to this project are documented in this file. +## 8.2.3 - Unreleased + +### Fixed + +- `Money::format()` with a `$locale` no longer prints a negative zero for currencies whose Intl fraction digits differ from ISO 4217: `Money::format(-0.4, 'IQD', locale: 'en_US')` returned `"-IQD 0"` and now returns `"IQD 0"`. The amount is compared with Intl's own formatted zero instead of being rounded with the ISO 4217 digits. + +### Changed + +- The internal `Support\Assert` and `Support\Excerpt` helpers moved to `Pharaonic\Readable`, and `Support\Intl` became `Pharaonic\Readable\Services\Integration\IntlService`. They stay `@internal` and are not part of the public API. +- The documentation has an upgrade guide. +- CI runs validation, style, static analysis, tests, the security audit and an archive check in order, behind one quality gate. + ## 8.2.2 - 2026-10-11 ### Fixed diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index cb3afbf..8dbb760 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -2,7 +2,7 @@ ## Our standards -Be respectful, constructive, and focused on the technical work. Harassment, discrimination, personal attacks, and intentionally disruptive behavior are not acceptable. +Be respectful, constructive, and focused on the technical work. Respect other people's privacy and never publish their private information. Harassment, discrimination, personal attacks, and intentionally disruptive behavior are not acceptable. ## Scope @@ -11,3 +11,5 @@ This code of conduct applies to repository discussions, issues, pull requests, r ## Enforcement Project maintainers may edit, remove, or reject contributions and participation that violate these standards. + +Report conduct concerns privately to the maintainers rather than in public threads. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c170925..0eaecdc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -33,7 +33,7 @@ git remote add upstream https://github.com/Pharaonic/php-readable.git ## Choose the target branch -Check out the branch that matches the PHP version you are targeting: +Check out the branch that matches the PHP version you are targeting. For a bug fix, use the oldest line that has the bug: ```bash git checkout 8.2.x @@ -85,7 +85,7 @@ All checks must pass. CI also runs the tests with the lowest allowed dependency git push origin fix/compact-rounding ``` -Open the pull request against the version branch you started from, and fill in the pull request template. Do not submit the same change to multiple version branches unless asked to. +Open the pull request against the version branch you started from, and fill in the pull request template. Maintainers port fixes from the oldest affected line to the newer lines, so do not submit the same change to several branches. ## Code of Conduct diff --git a/MAINTAINING.md b/MAINTAINING.md index 92a8069..e9c0d9d 100644 --- a/MAINTAINING.md +++ b/MAINTAINING.md @@ -18,7 +18,7 @@ One branch per PHP minor, each requiring exactly that minor (`"php": ">=8.N <8.N ## Public API invariants -- The public API is the static methods of `Arr`, `Str`, `Number`, `Bytes`, `Money` and `Duration`, and `Exceptions\MissingIntlExtension`. Everything under `Support\` is `@internal`. +- The public API is the static methods of `Arr`, `Str`, `Number`, `Bytes`, `Money` and `Duration`, and `Exceptions\MissingIntlExtension`. `Assert`, `Excerpt` and `Services\Integration\IntlService` are `@internal`, not part of the public API. - Without a `$locale`, output comes from the built-in English formatter and is identical on every machine, with or without `ext-intl`. - With a `$locale`, `ext-intl` is used; without it, `MissingIntlExtension` is thrown. Invalid locales never leak `ValueError` or `IntlException`. - Rounding is half away from zero everywhere, a rounded value carries to the next unit (`999 999 B` is `1 MB`), and no formatter prints negative zero. diff --git a/README.md b/README.md index 4b4f13d..156c375 100644 --- a/README.md +++ b/README.md @@ -3,15 +3,14 @@