PHPackages                             bearsunday/rector-bearsunday - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. bearsunday/rector-bearsunday

ActiveRector-extension[Framework](/categories/framework)

bearsunday/rector-bearsunday
============================

Rector upgrades rules for BEAR.Sunday Framework

1.1.0(4mo ago)2197MITPHPPHP ^8.2

Since Apr 1Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/bearsunday/rector-bearsunday)[ Packagist](https://packagist.org/packages/bearsunday/rector-bearsunday)[ RSS](/packages/bearsunday-rector-bearsunday/feed)WikiDiscussions 1.x Synced 1mo ago

READMEChangelog (3)Dependencies (12)Versions (6)Used By (0)

Rector Rules for BEAR.Sunday
============================

[](#rector-rules-for-bearsunday)

Rector rules to migrate BEAR.Sunday and Ray.Di applications from annotations to PHP 8 attributes.

Requirements
------------

[](#requirements)

- PHP 8.2+
- Rector 2.0+

Installation
------------

[](#installation)

```
composer require --dev bearsunday/rector-bearsunday
```

Usage
-----

[](#usage)

Run Rector using the provided configuration file:

```
# Preview changes
vendor/bin/rector process src tests -c vendor/bearsunday/rector-bearsunday/rector.php --dry-run

# Apply changes
vendor/bin/rector process src tests -c vendor/bearsunday/rector-bearsunday/rector.php
```

Rules
-----

[](#rules)

### RayDiNamedAnnotationRector

[](#raydinamedannotationrector)

Converts `@Named` annotations on methods to `#[Named]` attributes on constructor parameters.

**Before:**

```
class SomeClass
{
    /**
     * @Named("a=foo, b=bar")
     */
    public function __construct(int $a, int $b)
    {
    }
}
```

**After:**

```
class SomeClass
{
    public function __construct(
        #[Named('foo')] int $a,
        #[Named('bar')] int $b
    ) {
    }
}
```

### AnnotationToAttributeRector

[](#annotationtoattributerector)

Converts BEAR.Sunday and Ray.Di annotations to PHP 8 attributes.

The provided `rector.php` configuration includes rules for:

**Ray.Di:**

- `@Inject` → `#[Inject]`
- `@Named` → `#[Named]`
- `@PostConstruct` → `#[PostConstruct]`
- `@Assisted` → `#[Assisted]`
- `@Set` → `#[Set]`
- `@Qualifier` → `#[Qualifier]`

**Ray.AuraSqlModule:**

- `@ReadOnlyConnection` → `#[ReadOnlyConnection]`
- `@WriteConnection` → `#[WriteConnection]`
- `@Transactional` → `#[Transactional]`

**Ray.PsrCacheModule:**

- `@CacheNamespace` → `#[CacheNamespace]`
- `@Local` → `#[Local]`
- `@Shared` → `#[Shared]`
- `@CacheDir` → `#[CacheDir]`

**Ray.WebContextParam:**

- `@CookieParam` → `#[CookieParam]`
- `@EnvParam` → `#[EnvParam]`
- `@FilesParam` → `#[FilesParam]`
- `@FormParam` → `#[FormParam]`
- `@QueryParam` → `#[QueryParam]`
- `@ServerParam` → `#[ServerParam]`

**Ray.QueryModule:**

- `@Query` → `#[Query]`

**Ray.RoleModule:**

- `@RequiresRoles` → `#[RequiresRoles]`

**BEAR.Resource:**

- `@AppName` → `#[AppName]`
- `@ContextScheme` → `#[ContextScheme]`
- `@Embed` → `#[Embed]`
- `@ImportAppConfig` → `#[ImportAppConfig]`
- `@Link` → `#[Link]`
- `@OptionsBody` → `#[OptionsBody]`
- `@ResourceParam` → `#[ResourceParam]`

**BEAR.Package:**

- `@ReturnCreatedResource` → `#[ReturnCreatedResource]`

**BEAR.QueryRepository:**

- `@Cacheable` → `#[Cacheable]`
- `@Purge` → `#[Purge]`
- `@Refresh` → `#[Refresh]`

**BEAR.Accept:**

- `@Available` → `#[Available]`
- `@Produces` → `#[Produces]`

### SetterToConstructorInjectionRector

[](#settertoconstructorinjectionrector)

Converts setter injection with `#[Inject]` to constructor injection.

**Before:**

```
class SomeClass
{
    private FooInterface $foo;

    #[Inject]
    public function setFoo(FooInterface $foo): void
    {
        $this->foo = $foo;
    }
}
```

**After:**

```
class SomeClass
{
    public function __construct(
        private readonly FooInterface $foo
    ) {
    }
}
```

### TraitToConstructorInjectionRector

[](#traittoconstructorinjectionrector)

Converts trait-based injection to constructor injection.

**Supported traits:**

- `BEAR\Resource\ResourceInject` → `ResourceInterface $resource`
- `BEAR\Sunday\Inject\ResourceInject` → `ResourceInterface $resource`
- `Ray\Di\InjectorInject` → `InjectorInterface $injector`

**Before:**

```
use BEAR\Resource\ResourceInject;

class SomeClass
{
    use ResourceInject;
}
```

**After:**

```
use BEAR\Resource\ResourceInterface;

class SomeClass
{
    public function __construct(
        private readonly ResourceInterface $resource
    ) {
    }
}
```

### ResourceObjectReturnTypeRector

[](#resourceobjectreturntyperector)

Converts `ResourceObject` and `self` return types to `static` in resource methods.

**Before:**

```
class Article extends ResourceObject
{
    public function onGet(int $id): ResourceObject
    {
        return $this;
    }
}
```

**After:**

```
class Article extends ResourceObject
{
    public function onGet(int $id): static
    {
        return $this;
    }
}
```

See Also
--------

[](#see-also)

- [Rector - Instant PHP Upgrades](https://getrector.com/)
- [AnnotationToAttributeRector](https://github.com/rectorphp/rector/blob/main/docs/rector_rules_overview.md#annotationtoattributerector)

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance77

Regular maintenance activity

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~142 days

Total

5

Last Release

127d ago

PHP version history (2 changes)2.x-devPHP ^8.1

1.0.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/db4fc75ffc631168d0d7143b6f2c24b1534dfb921212bd851c026c5cbbb1344d?d=identicon)[koriym](/maintainers/koriym)

---

Top Contributors

[![koriym](https://avatars.githubusercontent.com/u/529021?v=4)](https://github.com/koriym "koriym (32 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/bearsunday-rector-bearsunday/health.svg)

```
[![Health](https://phpackages.com/badges/bearsunday-rector-bearsunday/health.svg)](https://phpackages.com/packages/bearsunday-rector-bearsunday)
```

###  Alternatives

[laravel/telescope

An elegant debug assistant for the Laravel framework.

5.2k67.8M190](/packages/laravel-telescope)[nolimits4web/swiper

Most modern mobile touch slider and framework with hardware accelerated transitions

41.8k177.2k1](/packages/nolimits4web-swiper)[laravel/prompts

Add beautiful and user-friendly forms to your command-line applications.

708181.8M591](/packages/laravel-prompts)[cakephp/chronos

A simple API extension for DateTime.

1.4k47.7M121](/packages/cakephp-chronos)[laravel/pail

Easily delve into your Laravel application's log files directly from the command line.

91245.3M585](/packages/laravel-pail)[nette/bootstrap

🅱 Nette Bootstrap: the simple way to configure and bootstrap your Nette application.

68435.8M590](/packages/nette-bootstrap)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
