Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 8, 2025

  • Constrain all dev dependencies to PHP 7.4+ compatible versions in composer.json
  • Run composer update to update composer.lock with compatible package versions
  • Verify composer install works on PHP 7.4+ with no dependency conflicts
  • Commit the updated composer.json and composer.lock files
  • Remove redundant test files from root directory
  • Fix deprecated PHPUnit assertion method
  • Fix PHP 7.4 syntax error (trailing comma in function parameters)

Summary

Fixed CI failures across PHP 7.4, 8.0, and 8.1 by downgrading all dev dependencies to PHP 7.4+ compatible versions.

Package Version Changes

Symfony Components (v7.x/v6.x → v5.4.x, requires PHP 7.2.5+):

  • symfony/console: v7.3.4 → v5.4.47
  • symfony/deprecation-contracts: v3.6.0 → v2.5.4
  • symfony/event-dispatcher: v7.3.3 → v5.4.45
  • symfony/event-dispatcher-contracts: v3.6.0 → v2.5.4
  • symfony/filesystem: v7.3.2 → v5.4.45
  • symfony/finder: v7.3.2 → v5.4.45
  • symfony/options-resolver: v7.3.3 → v5.4.45
  • symfony/process: v7.3.4 → v5.4.47
  • symfony/service-contracts: v3.6.0 → v2.5.4
  • symfony/stopwatch: v7.3.0 → v5.4.45
  • symfony/string: v6.4.26 → v5.4.47

Other Dependencies:

  • brainmaestro/composer-git-hooks: v3.0.0 → v2.8.5 (PHP 8.0+ → PHP 7.1+)
  • doctrine/instantiator: 2.0.0 → 1.5.0 (PHP 8.1+ → PHP 7.1+)
  • psr/log: 2.0.0 → 1.1.4 (PHP 8.0+ → PHP 5.3+)

Additional Changes

  • Removed test-exit-codes.php and test-scanner.php from root directory as their functionality is already covered by proper PHPUnit tests in tests/Integration/DefaultScanTest.php
  • Replaced deprecated assertRegExp() with assertMatchesRegularExpression() in test suite
  • Fixed PHP 7.4 syntax error by removing trailing comma in function parameter list (only supported in PHP 8.0+)

This ensures compatibility with all PHP versions tested in CI: 7.4, 8.0, 8.1, 8.2, 8.3.

Original prompt

The CI job is failing because the composer dependencies are incompatible with the PHP version (8.1.33) used in the workflow. Specifically, symfony/console v7.3.4 requires PHP >=8.2, but the project is running on PHP 8.1. The package marcocesarato/php-conventional-changelog requires symfony/console ^4 || ^5 || ^6 || ^7, and the composer.lock is currently locked to v7.3.4, which causes the incompatibility.

To fix this:

  • Update composer.json to require symfony/console ^6.0 (or ^5.0 if needed), ensuring compatibility with PHP 8.1.
  • Run composer update symfony/console to update composer.lock accordingly.
  • Commit the updated composer.json and composer.lock files.

This change will resolve the dependency conflict and allow the CI workflow to pass with PHP 8.1.

Reference: CI job run

*This pull request was created as a result of the following prompt from Copilot chat.* > The CI job is failing because the composer dependencies are incompatible with the PHP version (8.1.33) used in the workflow. Specifically, symfony/console v7.3.4 requires PHP >=8.2, but the project is running on PHP 8.1. The package marcocesarato/php-conventional-changelog requires symfony/console ^4 || ^5 || ^6 || ^7, and the composer.lock is currently locked to v7.3.4, which causes the incompatibility. > > To fix this: > - Update composer.json to require symfony/console ^6.0 (or ^5.0 if needed), ensuring compatibility with PHP 8.1. > - Run `composer update symfony/console` to update composer.lock accordingly. > - Commit the updated composer.json and composer.lock files. > > This change will resolve the dependency conflict and allow the CI workflow to pass with PHP 8.1. > > Reference: [CI job run](https://github.com/marcocesarato/PHP-Antimalware-Scanner/actions/runs/18343601244/job/52244676856) >

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@marcocesarato
Copy link
Owner

@copilot
Remove test files on root and create ad-hoc tests for them if not exists. Keep a unique structure.
As test dataset you can use https://github.com/marcocesarato/PHP-Malware-Collection

Co-authored-by: marcocesarato <36447518+marcocesarato@users.noreply.github.com>
Copilot AI changed the title [WIP] Update symfony/console dependency for PHP 8.1 compatibility Fix symfony/console dependency for PHP 7.4-8.1 compatibility Oct 8, 2025
Copilot AI requested a review from marcocesarato October 8, 2025 12:03
@marcocesarato
Copy link
Owner

@copilot

"""
un composer install --prefer-dist --no-progress
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Your lock file does not contain a compatible set of packages. Please run composer update.

Problem 1
- brainmaestro/composer-git-hooks is locked to version v3.0.0 and an update of this package was not requested.
- brainmaestro/composer-git-hooks v3.0.0 requires php ^8.0 -> your php version (7.4.33) does not satisfy that requirement.
Problem 2
- doctrine/instantiator is locked to version 2.0.0 and an update of this package was not requested.
- doctrine/instantiator 2.0.0 requires php ^8.1 -> your php version (7.4.33) does not satisfy that requirement.
Problem 3
- psr/log is locked to version 2.0.0 and an update of this package was not requested.
- psr/log 2.0.0 requires php >=8.0.0 -> your php version (7.4.33) does not satisfy that requirement.
Problem 4
- symfony/deprecation-contracts is locked to version v3.6.0 and an update of this package was not requested.
- symfony/deprecation-contracts v3.6.0 requires php >=8.1 -> your php version (7.4.33) does not satisfy that requirement.
Problem 5
- symfony/event-dispatcher is locked to version v7.3.3 and an update of this package was not requested.
- symfony/event-dispatcher v7.3.3 requires php >=8.2 -> your php version (7.4.33) does not satisfy that requirement.
Problem 6
- symfony/event-dispatcher-contracts is locked to version v3.6.0 and an update of this package was not requested.
- symfony/event-dispatcher-contracts v3.6.0 requires php >=8.1 -> your php version (7.4.33) does not satisfy that requirement.
Problem 7
- symfony/filesystem is locked to version v7.3.2 and an update of this package was not requested.
- symfony/filesystem v7.3.2 requires php >=8.2 -> your php version (7.4.33) does not satisfy that requirement.
Problem 8
- symfony/finder is locked to version v7.3.2 and an update of this package was not requested.
- symfony/finder v7.3.2 requires php >=8.2 -> your php version (7.4.33) does not satisfy that requirement.
Problem 9
- symfony/options-resolver is locked to version v7.3.3 and an update of this package was not requested.
- symfony/options-resolver v7.3.3 requires php >=8.2 -> your php version (7.4.33) does not satisfy that requirement.
Problem 10
- symfony/process is locked to version v7.3.4 and an update of this package was not requested.
- symfony/process v7.3.4 requires php >=8.2 -> your php version (7.4.33) does not satisfy that requirement.
Problem 11
- symfony/service-contracts is locked to version v3.6.0 and an update of this package was not requested.
- symfony/service-contracts v3.6.0 requires php >=8.1 -> your php version (7.4.33) does not satisfy that requirement.
Problem 12
- symfony/stopwatch is locked to version v7.3.0 and an update of this package was not requested.
- symfony/stopwatch v7.3.0 requires php >=8.2 -> your php version (7.4.33) does not satisfy that requirement.
Problem 13
- symfony/string is locked to version v6.4.26 and an update of this package was not requested.
- symfony/string v6.4.26 requires php >=8.1 -> your php version (7.4.33) does not satisfy that requirement.
Problem 14
- symfony/console is locked to version v5.4.47 and an update of this package was not requested.
- symfony/console v5.4.47 requires symfony/deprecation-contracts ^2.1|^3 -> satisfiable by symfony/deprecation-contracts[v3.6.0].
- symfony/deprecation-contracts v3.6.0 requires php >=8.1 -> your php version (7.4.33) does not satisfy that requirement.

Error: Your lock file does not contain a compatible set of packages. Please run composer update.

Problem 1
- brainmaestro/composer-git-hooks is locked to version v3.0.0 and an update of this package was not requested.
- brainmaestro/composer-git-hooks v3.0.0 requires php ^8.0 -> your php version (7.4.33) does not satisfy that requirement.
Problem 2
- doctrine/instantiator is locked to version 2.0.0 and an update of this package was not requested.
- doctrine/instantiator 2.0.0 requires php ^8.1 -> your php version (7.4.33) does not satisfy that requirement.
Problem 3
- psr/log is locked to version 2.0.0 and an update of this package was not requested.
- psr/log 2.0.0 requires php >=8.0.0 -> your php version (7.4.33) does not satisfy that requirement.
Problem 4
- symfony/deprecation-contracts is locked to version v3.6.0 and an update of this package was not requested.
- symfony/deprecation-contracts v3.6.0 requires php >=8.1 -> your php version (7.4.33) does not satisfy that requirement.
Problem 5
- symfony/event-dispatcher is locked to version v7.3.3 and an update of this package was not requested.
- symfony/event-dispatcher v7.3.3 requires php >=8.2 -> your php version (7.4.33) does not satisfy that requirement.
Problem 6
- symfony/event-dispatcher-contracts is locked to version v3.6.0 and an update of this package was not requested.
- symfony/event-dispatcher-contracts v3.6.0 requires php >=8.1 -> your php version (7.4.33) does not satisfy that requirement.
Problem 7
- symfony/filesystem is locked to version v7.3.2 and an update of this package was not requested.
- symfony/filesystem v7.3.2 requires php >=8.2 -> your php version (7.4.33) does not satisfy that requirement.
Problem 8
- symfony/finder is locked to version v7.3.2 and an update of this package was not requested.
- symfony/finder v7.3.2 requires php >=8.2 -> your php version (7.4.33) does not satisfy that requirement.
Problem 9
- symfony/options-resolver is locked to version v7.3.3 and an update of this package was not requested.
- symfony/options-resolver v7.3.3 requires php >=8.2 -> your php version (7.4.33) does not satisfy that requirement.
Problem 10
- symfony/process is locked to version v7.3.4 and an update of this package was not requested.
- symfony/process v7.3.4 requires php >=8.2 -> your php version (7.4.33) does not satisfy that requirement.
Problem 11
- symfony/service-contracts is locked to version v3.6.0 and an update of this package was not requested.
- symfony/service-contracts v3.6.0 requires php >=8.1 -> your php version (7.4.33) does not satisfy that requirement.
Problem 12
- symfony/stopwatch is locked to version v7.3.0 and an update of this package was not requested.
- symfony/stopwatch v7.3.0 requires php >=8.2 -> your php version (7.4.33) does not satisfy that requirement.
Problem 13
- symfony/string is locked to version v6.4.26 and an update of this package was not requested.
- symfony/string v6.4.26 requires php >=8.1 -> your php version (7.4.33) does not satisfy that requirement.
Problem 14
- symfony/console is locked to version v5.4.47 and an update of this package was not requested.
- symfony/console v5.4.47 requires symfony/deprecation-contracts ^2.1|^3 -> satisfiable by symfony/deprecation-contracts[v3.6.0].
- symfony/deprecation-contracts v3.6.0 requires php >=8.1 -> your php version (7.4.33) does not satisfy that requirement.

Error: Process completed with exit code 2.
"""

Pipeline error

Co-authored-by: marcocesarato <36447518+marcocesarato@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Oct 8, 2025

@copilot
Remove test files on root and create ad-hoc tests for them if not exists. Keep a unique structure.
As test dataset you can use https://github.com/marcocesarato/PHP-Malware-Collection

Removed test-exit-codes.php and test-scanner.php from root directory. Their functionality is already covered by the PHPUnit test suite in tests/Integration/DefaultScanTest.php (commit: 7a90b1e).

The exit code tests are in DefaultScanTest::testScanCleanDirectoryExitsWithZero() and DefaultScanTest::testScanMalwareDirectoryExitsWithOne(), and error reporting is configured in phpunit.xml.

Co-authored-by: marcocesarato <36447518+marcocesarato@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Oct 8, 2025

@copilot

"""
...

Fixed the PHP 7.4 compatibility issues by constraining all dev dependencies to PHP 7.4+ compatible versions (commit: 4c1f89a).

Key changes:

  • brainmaestro/composer-git-hooks: v3.0 → v2.8.5 (PHP 7.1+)
  • doctrine/instantiator: 2.0.0 → 1.5.0 (PHP 7.1+)
  • psr/log: 2.0.0 → 1.1.4 (PHP 5.3+)
  • All Symfony components: v7.x/v6.x → v5.4.x (PHP 7.2.5+)

The lock file now contains packages compatible with PHP 7.4+.

Copilot AI changed the title Fix symfony/console dependency for PHP 7.4-8.1 compatibility Fix dev dependencies for PHP 7.4+ compatibility Oct 8, 2025
@marcocesarato
Copy link
Owner

@copilot

"""
PHPUnit 9.6.29 by Sebastian Bergmann and contributors.

Runtime: PHP 8.3.26
Configuration: /home/runner/work/PHP-Antimalware-Scanner/PHP-Antimalware-Scanner/phpunit.xml
Warning: Your XML configuration validates against a deprecated schema.
Suggestion: Migrate your XML configuration using "--migrate-configuration"!

...W............... 19 / 19 (100%)

Time: 00:05.325, Memory: 6.00 MB

There was 1 warning:

  1. AMWScan\Tests\Integration\DefaultScanTest::testScanCountsFilesScanned
    assertRegExp() is deprecated and will be removed in PHPUnit 10. Refactor your code to use assertMatchesRegularExpression() instead.

WARNINGS!
Tests: 19, Assertions: 27, Warnings: 1.
Script phpunit --testsuite integration handling the test:integration event returned with error code 1
Error: Process completed with exit code 1.
"""

Co-authored-by: marcocesarato <36447518+marcocesarato@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Oct 8, 2025

@copilot

"""
...

Fixed the deprecated PHPUnit assertion by replacing assertRegExp() with assertMatchesRegularExpression() in DefaultScanTest::testScanCountsFilesScanned() (commit: e8f3d91).

This resolves the PHPUnit 9 deprecation warning and prevents the test suite from exiting with error code 1.

@marcocesarato
Copy link
Owner

@copilot

Run davidlienhard/php-simple-lint@1
Run $GITHUB_ACTION_PATH/lint.sh --lint ./ --ignore ./vendor/*
PHP Simple Lint

PHP version: 7.4 (7.4.33)
Path to scan: ./

PHP Parse error: syntax error, unexpected ')', expecting variable (T_VARIABLE) in ./src/Scanner.php on line 1042

check has finished in 2s

  • 43 files checked
  • 42 files without error
  • 1 files with error
    Error: Process completed with exit code 1.

Co-authored-by: marcocesarato <36447518+marcocesarato@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Oct 8, 2025

@copilot

Run davidlienhard/php-simple-lint@1
...

Fixed the PHP 7.4 syntax error by removing the trailing comma in the anonymous function parameter list on line 1042 of src/Scanner.php (commit: 9ab42cd).

Trailing commas in function parameters are only supported in PHP 8.0+, but this project requires PHP 7.4+ compatibility. The lint check now passes successfully.

@marcocesarato marcocesarato marked this pull request as ready for review October 9, 2025 07:30
@marcocesarato marcocesarato merged commit df31dfd into master Oct 9, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants