Releases: ray-di/Ray.Di
2.20.0
What's Changed
New Features
- Add
NoHintexception for parameters without type hints or binding names - Improve
Unbounderror 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
2.19.2
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+Qualifierattributes 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:
LegacyStringParser→BcStringParserfor consistency - All backward compatibility code now uses
Bcprefix (Backward Compatibility) - Clearer, more concise naming throughout deprecated code
Technical Details:
- New class:
Ray\Di\BcParameterQualifierwithgetNames()method - Renamed:
Ray\Di\LegacyStringParser→Ray\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
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
LegacyStringParserclass insrc-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\LegacyStringParserfor parsing legacy string format - Updated:
Ray\Di\Nameto delegate string parsing toLegacyStringParser - 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
Changed
-
Move ray/compiler to suggested dependency (#304)
ray/compileris no longer required. Ray.Di only usesRay\Aop\Compilerfromray/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
AnnotationExceptionreferences - Improve test coverage for optional setter injection
Requirements
- PHP 8.2+
- ray/aop ^2.19
2.18.0
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
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
2.16.1
2.16.0
What's Changed
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