Releases: ray-di/Ray.Aop
2.16.0
Ray.Aop 2.16 "Tanabata" Release Notes
This version brings significant changes to the API, simplifying usage and improving integration with the new PECL extension.
Major Changes
New Aspect Class
The most significant change is the introduction of the Aspect
class, which simplifies the configuration process:
use Ray\Aop\Aspect;
use Ray\Aop\Matcher;
$aspect = new Aspect();
$aspect->bind(
(new Matcher())->any(),
(new Matcher())->annotatedWith(NotOnWeekends::class),
[new WeekendBlocker()]
);
$billing = $aspect->newInstance(RealBillingService::class);
echo $billing->chargeOrder(); // Interceptors applied
This replaces the previous approach using Pointcut
, Bind
, and Weaver
classes:
// Old approach (2.0.0 to pre-2.16.0)
$pointcut = new Pointcut(
(new Matcher())->any(),
(new Matcher())->annotatedWith(NotOnWeekends::class),
[new WeekendBlocker()]
);
$bind = (new Bind)->bind(RealBillingService::class, [$pointcut]);
$billing = (new Weaver($bind, $tmpDir))->newInstance(RealBillingService::class, []);
PECL Extension Integration
Ray.Aop 2.16 seamlessly integrates with the new PECL extension. When the extension is installed, you can use the weave
method:
$aspect = new Aspect();
$aspect->bind(
(new Matcher())->any(),
(new Matcher())->annotatedWith(NotOnWeekends::class),
[new WeekendBlocker()]
);
$aspect->weave(__DIR__ . '/src'); // Weave the aspects
$billing = new RealBillingService();
echo $billing->chargeOrder(); // Interceptors applied
This applies aspects to all classes in a directory, allowing you to use the normal new
keyword for instantiation.
Changes
- The
Pointcut
,Bind
, andWeaver
classes are no longer used directly. Instead, use the newAspect
class. - The
newInstance
method is now part of theAspect
class, notWeaver
.
Additional Notes
- The PECL extension is optional.
- Existing interceptors and matchers should continue to work without modifications.
We believe these changes will make Ray.Aop easier to use and more powerful. As always, we appreciate your feedback and contributions!
What's Changed
- Add PHP class diagram by @koriym in #213
- PECL extension support and introduce newly refined main class "Aspect" by @koriym in #214
![Tanabata BEAR.Sunday](https://private-user-images.githubusercontent.com/529021/346314345-0bc60345-0aba-4ad5-8957-a71ef45722b3.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ2OTgyNjksIm5iZiI6MTcyNDY5Nzk2OSwicGF0aCI6Ii81MjkwMjEvMzQ2MzE0MzQ1LTBiYzYwMzQ1LTBhYmEtNGFkNS04OTU3LWE3MWVmNDU3MjJiMy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwODI2JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDgyNlQxODQ2MDlaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT02ZTU4ZDcyYWEyNjc0MjkxZjg0OTFmNDQxZjQ1NmU0ZDlkOGMyZDViMGE4MTVjMTNiYjljNTU5ZGM5ZjMxNWJlJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.IXq2hXHLaT_ihD7wFZRF5d8xWYZ4UVkDjhOz2yzE1mE)
Full Changelog: 2.15.2...2.16.0
2.15.2
What's Changed
- Support enum in attribute arguments by @apple-x-co in #212
Enumerations can now be used for attribute arguments as shown below!
enum FruitEnum
{
case Apple;
case Orange;
case Grape;
}
#[Attribute(Attribute::TARGET_METHOD)]
final class FruitEnum
{
public function __construct(
public readonly FruitEnum $fruit1,
public readonly FruitEnum $fruit2,
) {
}
}
#[AttrFoo(fruit1: FruitEnum::Apple, fruit2: FruitEnum::Orange)]
public function methodFoo() {}
Full Changelog: 2.15.1...2.15.2
2.15.1
2.15.0
2.14.0
2.13.1
What's Changed
- Update license copyright year(s) by @github-actions in #198
- Bump php parser to ^4.13.2 by @NaokiTsuchiya in #199
Full Changelog: 2.13.0...2.13.1
2.13.0
What's Changed
Full Changelog: 2.12.4...2.13.0