Skip to content

Fix deprecated PHP patterns for PHP 8.2–8.5+ compatibility#151

Merged
voku merged 8 commits intomasterfrom
copilot/find-and-fix-deprecated-code
Apr 9, 2026
Merged

Fix deprecated PHP patterns for PHP 8.2–8.5+ compatibility#151
voku merged 8 commits intomasterfrom
copilot/find-and-fix-deprecated-code

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 7, 2026

  • Fix composer.json PHP constraint to >=8.0.0
  • Remove PHP 7.3 and 7.4 from CI matrix (they can't satisfy >=8.0.0)
  • Move the lowest-composer include from PHP 7.3 to PHP 8.0

This change is Reviewable

Copilot AI and others added 3 commits April 7, 2026 14:56
…ties, deprecated callable syntax, phpstan config, phpunit config

Agent-Logs-Url: https://github.com/voku/Arrayy/sessions/da9c69db-a7c6-4b52-aead-672148477a67

Co-authored-by: voku <264695+voku@users.noreply.github.com>
Copilot finished work on behalf of voku April 7, 2026 15:27
Copilot AI requested a review from voku April 7, 2026 15:27
@coveralls
Copy link
Copy Markdown

coveralls commented Apr 7, 2026

Coverage Status

coverage: 89.237% (-1.2%) from 90.439% — copilot/find-and-fix-deprecated-code into master

Copilot finished work on behalf of voku April 7, 2026 16:36
@voku voku marked this pull request as ready for review April 8, 2026 14:06
@voku
Copy link
Copy Markdown
Owner

voku commented Apr 8, 2026

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request enhances PHP 8 compatibility by introducing nullable type hints across various methods and applying the AllowDynamicProperties attribute to the ArrayyMeta class. It also updates the PHPUnit configuration and adds PHPStan as a development dependency. Review feedback identifies a critical compatibility issue with Closure::fromCallable() on PHP 7.0, recommends using a more specific version constraint for PHPStan to ensure build stability, and suggests refactoring the ArrayyMeta class to avoid dynamic properties for improved maintainability.

src/Arrayy.php Outdated
* @psalm-suppress PossiblyInvalidArgument - the parameter is always some kind of array - false-positive from psalm?
*/
return \array_map(['static', 'objectToArray'], $object);
return \array_map(\Closure::fromCallable([static::class, 'objectToArray']), $object);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The use of \Closure::fromCallable() will cause a fatal error on PHP 7.0, as it was introduced in PHP 7.1. According to composer.json, this project still supports PHP 7.0.

To resolve this while maintaining compatibility, you can use [static::class, 'objectToArray'] which works on PHP 7.0 and is not deprecated.

        return \array_map([static::class, 'objectToArray'], $object);

composer.json Outdated
"require-dev": {
"phpunit/phpunit": "~6.0 || ~7.0 || ~9.0"
"phpunit/phpunit": "~6.0 || ~7.0 || ~9.0",
"phpstan/phpstan": "*"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using "*" as a version constraint for phpstan/phpstan is not recommended as it can pull in major versions with breaking changes, potentially causing your CI/builds to fail unexpectedly. It's better to use a more restrictive constraint, for example "^1.0", to ensure stability.

Suggested change
"phpstan/phpstan": "*"
"phpstan/phpstan": "^1.0"

Comment on lines +7 to 8
#[\AllowDynamicProperties]
final class ArrayyMeta
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While #[AllowDynamicProperties] makes the code compatible with PHP 8.2, it's generally better to avoid dynamic properties for improved maintainability and type safety. Consider refactoring this class to use a private array for storing properties and leverage __get() and __set() magic methods to manage them. This would make the class structure more explicit and robust.

Copilot finished work on behalf of voku April 9, 2026 22:50
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.77%. Comparing base (e88173f) to head (ce22716).

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #151      +/-   ##
============================================
- Coverage     90.45%   89.77%   -0.69%     
+ Complexity     1138     1083      -55     
============================================
  Files            39       39              
  Lines          3196     3139      -57     
============================================
- Hits           2891     2818      -73     
- Misses          305      321      +16     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 9, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
2 Security Hotspots

See analysis details on SonarQube Cloud

Copilot finished work on behalf of voku April 9, 2026 23:17
@voku voku merged commit edca381 into master Apr 9, 2026
11 of 14 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.

3 participants