Skip to content

Releases: ray-di/Ray.Di

2.20.0

24 Dec 13:13
2a03a15

Choose a tag to compare

What's Changed

New Features

  • Add NoHint exception for parameters without type hints or binding names
  • Improve Unbound error messages with better formatting

Developer Experience

  • Drop PHPUnit 8.x support (PHPUnit 9.5+ required)

Full Changelog: 2.19.3...2.20.0

2.19.3

22 Nov 01:21
40ed629

Choose a tag to compare

Changed

  • Enhanced BcParameterQualifier to support method-level Qualifier attributes on constructors

2.19.2

19 Nov 11:13
2e5aceb

Choose a tag to compare

What's Changed

Backward Compatibility Enhancement

This release adds backward compatibility for method-level InjectInterface+Qualifier attributes on single-parameter setter methods, and improves naming consistency for deprecated code.

New: BcParameterQualifier

  • Automatically applies method-level InjectInterface+Qualifier attributes to parameters for single-parameter setters
  • Restores backward compatibility for code using combined attributes like #[FakeLogDbInject]
  • Only applies when attribute supports Attribute::TARGET_PARAMETER (distinguishes from Provider pattern)
  • Located in src-deprecated/di/ and marked as @deprecated

Example (now works):

#[FakeLogDbInject]  // InjectInterface + Qualifier
public function setDb(ExtendedPdoInterface $pdo) { }

Recommended Modern Approach:

#[Inject]
public function setDb(#[FakeLogDb] ExtendedPdoInterface $pdo) { }

Naming Improvements:

  • Renamed: LegacyStringParserBcStringParser for consistency
  • All backward compatibility code now uses Bc prefix (Backward Compatibility)
  • Clearer, more concise naming throughout deprecated code

Technical Details:

  • New class: Ray\Di\BcParameterQualifier with getNames() method
  • Renamed: Ray\Di\LegacyStringParserRay\Di\BcStringParser
  • Comprehensive test coverage for both BC features
  • Ray.Compiler compatible (inference happens at compile-time)

This ensures compatibility with packages like Ray.AuraSqlModule that use method-level qualifier attributes.

Full Changelog: 2.19.1...2.19.2

2.19.1

18 Nov 12:37
ccb3c5b

Choose a tag to compare

What's Changed

Backward Compatibility Fix

This release restores backward compatibility for the string format in toConstructor() method that was accidentally removed in 2.19.0 (commit da864a5).

Restored Support:

  • String format: toConstructor(ClassName::class, 'param=name,param2=name2')
  • This format is now handled by the new LegacyStringParser class in src-deprecated/di/
  • Marked as @deprecated - prefer using parameter-level attributes or array format

Recommended Modern Approaches:

  • Parameter-level attributes: #[Named('name')] on constructor parameters
  • Array format: toConstructor(ClassName::class, ['param' => 'name'])

Technical Details:

  • New class: Ray\Di\LegacyStringParser for parsing legacy string format
  • Updated: Ray\Di\Name to delegate string parsing to LegacyStringParser
  • Added comprehensive tests for string format parsing

This fix ensures that existing code using Ray.AuraSqlModule and other packages relying on the string format will continue to work.

Full Changelog: 2.19.0...2.19.1

2.19.0

17 Nov 15:28

Choose a tag to compare

Changed

  • Move ray/compiler to suggested dependency (#304)
    ray/compiler is no longer required. Ray.Di only uses Ray\Aop\Compiler from ray/aop.

  • Optimize codebase for PHP 8.2+ (#305)
    Modernized code with readonly properties, constructor property promotion, and improved type declarations.
    43 files changed: +166 -299 lines

Fixed

  • Remove unused AnnotationException references
  • Improve test coverage for optional setter injection

Requirements

  • PHP 8.2+
  • ray/aop ^2.19

2.18.0

29 Nov 15:49
a7dc251

Choose a tag to compare

What's Changed

  • Bug fix: Handle missing dependencies in setter methods with #[Inject(optional: true)] by @koriym in #292
  • PHP 8.4 Support: Update CI to support PHP 8.4 and include PHP 8.3 in old_stable by @koriym in #293
  • Enhance code quality with Psalm annotations by @koriym in #294

Full Changelog: 2.17.2...2.18.0

2.17.2

10 Sep 16:24
3155fc6

Choose a tag to compare

What's Changed

PDOをプロパティに持つクラスは通常シリアライズができませんが、以下のようにPDOではなくPDOのプロバイダーを注入することによりシリアライズが可能になります。

Classes that have PDO as a property cannot normally be serialized, but they can be serialized by injecting a lazy object as follows.

class LazyPdo
{

    private PDO $pdo;

    public function __construct(
        /** ProviderInterface<PDO> */
        #[Set(PDO::class)] private ProviderInterface $pdoProvider
    ) {
        $this->pdoProvider = $pdoProvider;
        $this->initialize($pdoProvider);
    }
    
    public function initialize(ProviderInterface $pdoProvider)
    {
        $this->pdo = $this->pdoProvider->get();
    }
    
    public function __serialize(): array
    {
        return [
            'pdoProvider' => $this->pdoProvider
        ];
    }
    
    public function __unserialize(array $data): void
    {
        $this->pdoProvider = $data['pdoProvider'];
        $this->initialize($data['pdoProvider']);
    }
}

Full Changelog: 2.17.1...2.17.2

2.17.1

27 May 13:52
f6f39ef

Choose a tag to compare

What's Changed

  • Implements visitor pattern #289
  • Add MultiBindings class to configuration in DI module by @koriym in #290

v2.17.0 was found to contain errors and was immediately withdrawn and replaced by v2.17.1.

Full Changelog: 2.17.0...2.17.1

2.16.1

21 Sep 08:59
c94cec2

Choose a tag to compare

What's Changed

Full Changelog: 2.16.0...2.16.1

2.16.0

15 Sep 07:23
fac2d0a

Choose a tag to compare

What's Changed

  • Remove doctrine/annotation by @koriym in #284
  • Support PHP 8.3

Starting with this version, the doctrine/annotation dependency is removed and annotations are read from reflection through the methods of Ray.Aop. Aop is expected to improve the execution speed during development and heccompilation.

このバージョンからdoctrine/annotationの依存がなくなりアノテーションの読み込みはRay.Aopのメソッドを通じて、リフレクションより行われます。Ray.Aopのアノテーションの読み込みは、対象ファイルの更新日付に基づいた恒久的なものになり開発時やヘコンパイル時の実行速度の向上が期待でできます。

Full Changelog: 2.15.1...2.16.0