PHP code example of savinmikhail / annotate_throws_rector

1. Go to this page and download the library: Download savinmikhail/annotate_throws_rector 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/ */

    

savinmikhail / annotate_throws_rector example snippets




declare(strict_types=1);

use Rector\Config\RectorConfig;
use SavinMikhail\AnnotateThrowsRector\AnnotateThrowsRector;

return RectorConfig::configure()
    ->phpstanConfig(__DIR__ . '/phpstan.neon')
    ->withRules([
        AnnotateThrowsRector::class,
    ]);



declare(strict_types=1);

use Rector\Config\RectorConfig;
use SavinMikhail\AnnotateThrowsRector\AnnotateThrowsRector;

return RectorConfig::configure()
    ->phpstanConfig(__DIR__ . '/phpstan.neon')
    ->withConfiguredRule(AnnotateThrowsRector::class, [
        AnnotateThrowsRector::INCLUDE_UNCHECKED => true,
        AnnotateThrowsRector::EXCLUDED_EXCEPTION_CLASSES => [
            \Throwable::class,
            \Exception::class,
            \Error::class,
            \RuntimeException::class,
            \LogicException::class,
        ],
    ]);

final class InterviewRunner
{
    public function process(): void
    {
        $this->normalize();
    }

    public function normalize(): void
    {
        throw new \JsonException('Boom');
    }
}

final class InterviewRunner
{
    /**
     * @throws \JsonException
     */
    public function process(): void
    {
        $this->normalize();
    }

    /**
     * @throws \JsonException
     */
    public function normalize(): void
    {
        throw new \JsonException('Boom');
    }
}