PHP code example of bearsunday / rector-bearsunday

1. Go to this page and download the library: Download bearsunday/rector-bearsunday library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bearsunday / rector-bearsunday example snippets


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

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

class SomeClass
{
    private FooInterface $foo;

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

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

use BEAR\Resource\ResourceInject;

class SomeClass
{
    use ResourceInject;
}

use BEAR\Resource\ResourceInterface;

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

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

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