From 4fd2441ec26d2c14e1b2b75a010faeaa8f525959 Mon Sep 17 00:00:00 2001 From: Joao Gilberto Magalhaes Date: Sat, 22 Aug 2026 18:22:25 -0400 Subject: [PATCH 1/3] Prepare 7.0: PHP 8.3-8.6, PHPUnit 12.5, Psalm 6.16 Widen the PHP constraint to ">=8.3 <8.7". The previous "<8.6" is exclusive and therefore excluded PHP 8.6. Pin PHPUnit to ^12.5 and Psalm to ^6.16. PHPUnit 13 is not used: it requires PHP >=8.4.1, which breaks the 8.3 floor, and it needs sebastian/diff ^9.0, which stable Psalm 6.16.1 does not accept - that combination silently resolves Psalm to an unreleased 6.x-dev branch. CI: add PHP 8.6 to the build matrix, and move the Psalm job to PHP 8.5, since Psalm 6.16.1 cannot be installed on 8.6. Housekeeping: rename phpunit.xml.dist to phpunit.xml, carry the 6.x changelogs onto this branch, and add CHANGELOG-7.0.md. --- .github/workflows/phpunit.yml | 3 +- .travis.yml | 18 ----- CHANGELOG-6.0.md | 134 ++++++++++++++++++++++++++++++++ CHANGELOG-7.0.md | 36 +++++++++ composer.json | 6 +- phpunit.xml.dist => phpunit.xml | 0 6 files changed, 175 insertions(+), 22 deletions(-) delete mode 100644 .travis.yml create mode 100644 CHANGELOG-6.0.md create mode 100644 CHANGELOG-7.0.md rename phpunit.xml.dist => phpunit.xml (100%) diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index fc5f29a..87f0411 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -18,6 +18,7 @@ jobs: strategy: matrix: php-version: + - "8.6" - "8.5" - "8.4" - "8.3" @@ -34,7 +35,7 @@ jobs: # for github/codeql-action/upload-sarif to upload SARIF results security-events: write container: - image: byjg/php:8.4-cli + image: byjg/php:8.5-cli options: --user root --privileged steps: diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 909247a..0000000 --- a/.travis.yml +++ /dev/null @@ -1,18 +0,0 @@ -language: php -php: - - "7.2" - - "7.1" - - "7.0" - - "5.6" - -install: - - export SONARSCANNER_VERSION=3.2.0.1227 - - wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONARSCANNER_VERSION-linux.zip - - unzip sonar-scanner-cli-$SONARSCANNER_VERSION-linux.zip - - composer install - -script: - - vendor/bin/phpunit --coverage-clover phpunit.coverage.xml --log-junit phpunit.report.xml - - if [ "$TRAVIS_BRANCH" != "master" ]; then export SONARSCANNER_PARAM="-Dsonar.branch.name=$TRAVIS_BRANCH -Dsonar.branch.target=master"; fi - - sonar-scanner-$SONARSCANNER_VERSION-linux/bin/sonar-scanner -Dsonar.login=$SONAR_LOGIN $SONARSCANNER_PARAM - diff --git a/CHANGELOG-6.0.md b/CHANGELOG-6.0.md new file mode 100644 index 0000000..742df71 --- /dev/null +++ b/CHANGELOG-6.0.md @@ -0,0 +1,134 @@ +# Changelog - Version 6.0 + +## Overview + +Version 6.0 brings significant improvements to the Singleton Pattern library, including updated PHP version requirements, comprehensive documentation, improved tooling support, and enhanced GitHub Actions workflows. + +## New Features + +### Comprehensive Documentation Structure +- Added detailed markdown-based documentation in the `docs/` folder +- **Getting Started Guide** (`docs/getting-started.md`) - Installation and requirements +- **Creating a Singleton Class** (`docs/creating-singleton.md`) - Step-by-step implementation guide +- **Using Your Singleton** (`docs/using-singleton.md`) - Working with singleton instances +- **How It Works** (`docs/how-it-works.md`) - Implementation details and internals +- **API Reference** (`docs/api-reference.md`) - Complete API documentation +- Updated `README.md` with links to the new documentation structure + +### Enhanced Development Environment +- Added Gitpod configuration (`.gitpod.yml`) for cloud-based development +- Added VSCode launch configuration (`.vscode/launch.json`) for debugging support +- Added Composer scripts for easier testing and analysis: + - `composer test` - Run PHPUnit tests + - `composer psalm` - Run Psalm static analysis + +### Improved CI/CD Workflows +- Enhanced GitHub Actions workflow with better container options +- Added separate Psalm static analysis job with SARIF upload for security insights +- Updated to use latest `actions/checkout` action +- Added PHP 8.4 and PHP 8.5 to test matrix + +### Stability Configuration +- Added `minimum-stability: dev` with `prefer-stable: true` in `composer.json` for better dependency resolution + +## Breaking Changes + +| Aspect | Before (5.x) | After (6.x) | Description | +|--------|-------------|------------|-------------| +| **Minimum PHP Version** | PHP 8.1 | PHP 8.3 | Dropped support for PHP 8.1 and 8.2 | +| **Maximum PHP Version** | PHP <8.4 | PHP <8.6 | Added support for PHP 8.4 and 8.5 | +| **PHPUnit Version** | ^9.6 | ^10.5\|^11.5 | Updated to support PHPUnit 10 and 11 | +| **Psalm Version** | ^5.9 | ^5.9\|^6.13 | Added support for Psalm 6 | + +## Path to Upgrade from 5.x to 6.x + +### Prerequisites Check + +1. **Verify PHP Version** + ```bash + php -v + ``` + Ensure you are running PHP 8.3, 8.4, or 8.5. If you're on PHP 8.1 or 8.2, you must upgrade your PHP version before updating to version 6.0. + +### Upgrade Steps + +2. **Update Composer Dependency** + ```bash + composer require "byjg/singleton-pattern:^6.0" + ``` + +3. **Update Development Dependencies** (if applicable) + + If your project uses PHPUnit or Psalm and references the same versions, you may need to update them: + ```bash + composer update --with-dependencies + ``` + +4. **Run Tests** + + Verify your implementation works correctly: + ```bash + composer test + # or + vendor/bin/phpunit + ``` + +5. **Review Documentation** + + Check the new comprehensive documentation for best practices and implementation details: + - [Getting Started](docs/getting-started.md) + - [Creating a Singleton Class](docs/creating-singleton.md) + - [Using Your Singleton](docs/using-singleton.md) + +### Code Changes Required + +**No code changes are required** in your implementation. The Singleton trait API remains fully backward compatible. The only changes are: + +- PHP version requirement (upgrade your environment if needed) +- Development dependencies versions (only affects contributors/developers) + +### Compatibility Notes + +- All singleton implementations using the trait will continue to work without modification +- The `getInstance()` method signature remains unchanged +- Clone, serialize, and unserialize protections remain the same +- Constructor requirements (private/protected) remain unchanged + +### Troubleshooting + +If you encounter issues after upgrading: + +1. **Clear Composer cache:** + ```bash + composer clear-cache + composer install + ``` + +2. **Verify PHP version compatibility:** + ```bash + composer check-platform-reqs + ``` + +3. **Review the comprehensive documentation** in the `docs/` folder for implementation guidance + +## Additional Changes + +- Updated `psalm.xml` configuration to adjust error level and exclude test directory +- Added sponsor badge to README +- Improved PHPUnit configuration (`phpunit.xml.dist`) +- Updated GitHub workflow to use Composer scripts for Psalm analysis +- Added sample test file (`tests/Sample2.php`) for expanded test coverage +- Removed deprecated `_config.yml` file + +## Migration Timeline + +- **Version 5.x** remains available for projects using PHP 8.1-8.2 +- **Version 6.x** is recommended for all projects using PHP 8.3+ +- No end-of-life date has been announced for 5.x at this time + +## Support + +For issues, questions, or contributions: +- GitHub Issues: https://github.com/byjg/php-singleton-pattern/issues +- Documentation: [docs/getting-started.md](docs/getting-started.md) +- Sponsor: https://github.com/sponsors/byjg diff --git a/CHANGELOG-7.0.md b/CHANGELOG-7.0.md new file mode 100644 index 0000000..94e01f4 --- /dev/null +++ b/CHANGELOG-7.0.md @@ -0,0 +1,36 @@ +# Changelog - Version 7.0 + +> **Status: in development.** This document tracks changes landing on the `7.0` branch. +> Nothing here is released yet, and the contents may still change. + +## Breaking Changes + +- None. + +## Requirements + +- PHP 8.3, 8.4, 8.5 and 8.6 are now supported: `"php": ">=8.3 <8.7"`. + The previous `<8.6` upper bound excluded PHP 8.6, since `<8.6` is exclusive. + +## Toolchain + +- PHPUnit updated to `^12.5`. +- Psalm updated to `^6.16`. + + PHPUnit 13 is deliberately **not** used. It requires PHP `>=8.4.1`, which would + break the 8.3 floor, and it pulls `sebastian/diff ^9.0`, which the newest stable + Psalm (6.16.1) does not accept — that combination silently resolves Psalm to an + unreleased `6.x-dev` branch. Pinning PHPUnit to `^12.5` keeps a single stable + PHPUnit and a single stable Psalm across the whole matrix. + +## Continuous Integration + +- The build matrix now includes PHP 8.6. +- The Psalm job now runs on PHP 8.5. Psalm 6.16.1 declares + `~8.1.31 || ~8.2.27 || ~8.3.16 || ~8.4.3 || ~8.5.0` and therefore cannot be + installed on PHP 8.6. + +## Housekeeping + +- `phpunit.xml.dist` renamed to `phpunit.xml`. +- Removed the obsolete `.travis.yml`. diff --git a/composer.json b/composer.json index 91afbca..f4a9b16 100644 --- a/composer.json +++ b/composer.json @@ -12,11 +12,11 @@ } }, "require": { - "php": ">=8.3 <8.6" + "php": ">=8.3 <8.7" }, "require-dev": { - "phpunit/phpunit": "^10.5|^11.5", - "vimeo/psalm": "^5.9|^6.13" + "phpunit/phpunit": "^12.5", + "vimeo/psalm": "^6.16" }, "scripts": { "test": "vendor/bin/phpunit", diff --git a/phpunit.xml.dist b/phpunit.xml similarity index 100% rename from phpunit.xml.dist rename to phpunit.xml From 2c2f84e9053825aeb166c3fc9d7d68f298568631 Mon Sep 17 00:00:00 2001 From: Joao Gilberto Magalhaes Date: Sat, 22 Aug 2026 19:01:00 -0400 Subject: [PATCH 2/3] Move Psalm to a dedicated tools/psalm manifest Psalm enumerates the PHP versions it supports and has no 8.6 entry in any published release. As a require-dev it therefore made "composer install" fail on the 8.6 build job before a single test ran - the matrix is fail-fast, so 8.3/8.4/8.5 were cancelled rather than run. Psalm now lives in tools/psalm/composer.json with its own vendor dir, installed only by the Psalm job (PHP 8.5). The root manifest no longer constrains PHP through a dev dependency, so every build job resolves. "composer psalm" bootstraps the tool and runs it, so local usage is unchanged. tools/psalm/vendor and its lock are already covered by the existing gitignore patterns. --- .github/workflows/phpunit.yml | 5 ++++- composer.json | 8 +++++--- psalm.xml | 2 +- tools/psalm/composer.json | 5 +++++ 4 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 tools/psalm/composer.json diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index 87f0411..139ce3b 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -45,10 +45,13 @@ jobs: - name: Composer run: composer install + - name: Composer (psalm) + run: composer --working-dir=tools/psalm update --no-interaction + - name: Psalm # Note: Ignoring error code 2, which just signals that some # flaws were found, not that Psalm itself failed to run. - run: ./vendor/bin/psalm + run: ./tools/psalm/vendor/bin/psalm --show-info=true --report=psalm-results.sarif || [ $? = 2 ] diff --git a/composer.json b/composer.json index f4a9b16..8db8a8d 100644 --- a/composer.json +++ b/composer.json @@ -15,12 +15,14 @@ "php": ">=8.3 <8.7" }, "require-dev": { - "phpunit/phpunit": "^12.5", - "vimeo/psalm": "^6.16" + "phpunit/phpunit": "^12.5" }, "scripts": { "test": "vendor/bin/phpunit", - "psalm": "vendor/bin/psalm --threads=1" + "psalm": [ + "@composer --working-dir=tools/psalm update --no-interaction", + "tools/psalm/vendor/bin/psalm --threads=1" + ] }, "minimum-stability": "dev", "prefer-stable": true, diff --git a/psalm.xml b/psalm.xml index 037de8b..c1976fd 100644 --- a/psalm.xml +++ b/psalm.xml @@ -7,7 +7,7 @@ cacheDirectory="/tmp/psalm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://getpsalm.org/schema/config" - xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" + xsi:schemaLocation="https://getpsalm.org/schema/config tools/psalm/vendor/vimeo/psalm/config.xsd" > diff --git a/tools/psalm/composer.json b/tools/psalm/composer.json new file mode 100644 index 0000000..197dd5f --- /dev/null +++ b/tools/psalm/composer.json @@ -0,0 +1,5 @@ +{ + "require": { + "vimeo/psalm": "^6.16" + } +} From 135d8d9fc878bcfc7cfaccaf2359f2824eb81213 Mon Sep 17 00:00:00 2001 From: Joao Gilberto Magalhaes Date: Mon, 14 Sep 2026 12:08:42 -0400 Subject: [PATCH 3/3] Fix the license badge link and drop the hand-written dependency graph licensing.html returns 404; the page is /license/. The Dependencies mermaid drifted from composer.json, which is now what the site's graph is built from (collect-deps.py in add-doc). --- README.md | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/README.md b/README.md index 8ce3c70..425b999 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Just one class and no dependencies. [![Build Status](https://github.com/byjg/php-singleton-pattern/actions/workflows/phpunit.yml/badge.svg?branch=master)](https://github.com/byjg/php-singleton-pattern/actions/workflows/phpunit.yml) [![Opensource ByJG](https://img.shields.io/badge/opensource-byjg-success.svg)](http://opensource.byjg.com) [![GitHub source](https://img.shields.io/badge/Github-source-informational?logo=github)](https://github.com/byjg/php-singleton-pattern/) -[![GitHub license](https://img.shields.io/github/license/byjg/php-singleton-pattern.svg)](https://opensource.byjg.com/opensource/licensing.html) +[![GitHub license](https://img.shields.io/github/license/byjg/php-singleton-pattern.svg)](https://opensource.byjg.com/license/) [![GitHub release](https://img.shields.io/github/release/byjg/php-singleton-pattern.svg)](https://github.com/byjg/php-singleton-pattern/releases/) ## Documentation @@ -107,12 +107,5 @@ vendor/bin/phpunit * [Wikipedia: Singleton Pattern](https://en.wikipedia.org/wiki/Singleton_pattern) * [Documentation](docs/getting-started.md) -## Dependencies - -```mermaid -flowchart TD - byjg/singleton-pattern -``` - ---- [Open source ByJG](http://opensource.byjg.com) \ No newline at end of file