Skip to content

Add nette/di 3.1 and 3.2 support#153

Open
JanTvrdik wants to merge 1 commit intomasterfrom
nette-di-3.1-3.2
Open

Add nette/di 3.1 and 3.2 support#153
JanTvrdik wants to merge 1 commit intomasterfrom
nette-di-3.1-3.2

Conversation

@JanTvrdik
Copy link
Member

Summary

  • Fix MigrationsExtension to handle Nette\DI\Statement objects for dynamic container parameters (nette/di 3.1+ changed from PhpLiteral to Statement)
  • Return service reference strings (@service.name) instead of ServiceDefinition objects from internal definition methods (required for nette/di 3.2 compatibility)
  • Suppress E_USER_DEPRECATED during container compilation in tests (handles deprecation notices from nette/di ... syntax and doctrine/orm annotations)
  • Replace deprecated (...) autowiring syntax in test neon configs with class-name-only or explicit service reference alternatives (compatible with all nette/di versions)
  • Add nette-3.1.sh (PHP 8.0–8.3) and nette-3.2.sh (PHP 8.1–8.4) matrix files

Test plan

  • nette/di 2.4 on PHP 7.4 — all 5 tests pass
  • nette/di 3.0 on PHP 8.0 — all 5 tests pass
  • nette/di 3.1 on PHP 8.0 — all 5 tests pass
  • nette/di 3.1 on PHP 8.3 — all 5 tests pass
  • nette/di 3.2 on PHP 8.1 — all 5 tests pass
  • nette/di 3.2 on PHP 8.4 — all 5 tests pass

Copilot AI review requested due to automatic review settings February 24, 2026 19:42
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR extends the Nette DI bridge and test matrix to support nette/di 3.1 and 3.2 by adapting to Nette\DI\Statement-based dynamic parameters and newer service-reference expectations.

Changes:

  • Update MigrationsExtension to accept Nette\DI\Statement for dynamic parameters and to pass service references as strings (@service) for nette/di 3.2 compatibility.
  • Adjust integration tests to suppress E_USER_DEPRECATED during container compilation and update NEON configs away from deprecated autowiring syntax.
  • Add CI matrix scripts for nette/di 3.1 and 3.2 with appropriate PHP version ranges.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/Bridges/NetteDI/MigrationsExtension.php Adds Statement support and switches several internal helpers to return @service reference strings.
tests/cases/integration/nette-di/MigrationsExtension.phpt Suppresses E_USER_DEPRECATED during container compilation in tests.
tests/cases/integration/nette-di/MigrationsExtension.configC.neon Replaces deprecated (...) syntax for DibiAdapter service wiring.
tests/cases/integration/nette-di/MigrationsExtension.configD.neon Replaces deprecated (...) syntax and uses explicit service reference for MySqlDriver.
tests/cases/integration/nette-di/MigrationsExtension.configE.neon Replaces deprecated (...) syntax for DibiAdapter service wiring.
tests/matrix/nette-di/nette-3.1.sh Adds matrix definition for nette/di 3.1 (PHP 8.0–8.3).
tests/matrix/nette-di/nette-3.2.sh Adds matrix definition for nette/di 3.2 (PHP 8.1–8.4).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +303 to +305
if ($dir instanceof Statement) {
$append = function (string $path) use ($dir): Statement {
return new Statement('? . ?', [$dir, $path]);
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

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

The array-shape return phpdoc still says directory: string, but directory can now be a PhpLiteral or Statement (via the new $append closure branches). Update the return annotation so it matches the actual possible types to avoid misleading IDE/static analysis output.

Copilot uses AI. Check for mistakes.
@JanTvrdik JanTvrdik force-pushed the nette-di-3.1-3.2 branch 2 times, most recently from 8722ca0 to 79b2ec9 Compare February 24, 2026 19:58
- Fix MigrationsExtension to accept Nette\DI\Statement for dynamic
  container parameters (nette/di 3.1+ uses Statement instead of
  PhpLiteral for dynamic parameters)
- Return service reference strings instead of ServiceDefinition objects
  from definition methods (required for nette/di 3.2 compatibility)
- Suppress E_USER_DEPRECATED during container compilation in tests to
  handle deprecation notices from nette/di and doctrine/orm
- Replace deprecated `(...)` syntax with autowiring-compatible
  alternatives in test config files
- Add nette-3.1.sh (PHP 8.0-8.3) and nette-3.2.sh (PHP 8.1-8.4)
  matrix files
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