Skip to content

Commit

Permalink
skip NewInInitializerRector
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Sep 10, 2024
1 parent 055b0c4 commit 9cf5a48
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
2 changes: 2 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Rector\Php70\Rector\StmtsAwareInterface\IfIssetToCoalescingRector;
use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector;
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
use Rector\Php81\Rector\ClassMethod\NewInInitializerRector;
use Rector\Php81\Rector\Property\ReadOnlyPropertyRector;

return RectorConfig::configure()
Expand Down Expand Up @@ -80,6 +81,7 @@
RemoveUnusedPublicMethodParameterRector::class,
RemoveEmptyClassMethodRector::class,
RemoveUnusedPromotedPropertyRector::class,
NewInInitializerRector::class,

// start with short open tag
__DIR__ . '/src/Views/tests/fixtures/other/var.php',
Expand Down
4 changes: 3 additions & 1 deletion src/Queue/src/Interceptor/Consume/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@
*/
final class Handler
{
private readonly TracerFactoryInterface $tracerFactory;
private readonly bool $isLegacy;

public function __construct(
private readonly HandlerInterface|CoreInterface $core,
private readonly TracerFactoryInterface $tracerFactory = new NullTracerFactory(new Container()),
?TracerFactoryInterface $tracerFactory = null,
) {
$this->tracerFactory = $tracerFactory ?? new NullTracerFactory(new Container());
$this->isLegacy = !$core instanceof HandlerInterface;
}

Expand Down
4 changes: 3 additions & 1 deletion src/Router/src/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,16 @@ final class Router implements RouterInterface
private array $routes = [];

private ?RouteInterface $default = null;
private readonly TracerInterface $tracer;

public function __construct(
string $basePath,
private readonly UriHandler $uriHandler,
private readonly ContainerInterface $container,
private readonly ?EventDispatcherInterface $eventDispatcher = null,
private readonly TracerInterface $tracer = new NullTracer(),
?TracerInterface $tracer = null,
) {
$this->tracer = $tracer ?? new NullTracer();
$this->basePath = '/' . \ltrim($basePath, '/');
}

Expand Down
6 changes: 5 additions & 1 deletion src/Router/src/UriHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ final class UriHandler
];

private ?string $pattern = null;

private readonly RoutePatternRegistryInterface $patternRegistry;
private array $constrains = [];
private array $defaults = [];
private bool $matchHost = false;
Expand All @@ -54,8 +56,10 @@ final class UriHandler
public function __construct(
private readonly UriFactoryInterface $uriFactory,
SlugifyInterface $slugify = null,
private readonly RoutePatternRegistryInterface $patternRegistry = new DefaultPatternRegistry(),
?RoutePatternRegistryInterface $patternRegistry = null,
) {
$this->patternRegistry = $patternRegistry ?? new DefaultPatternRegistry();

$slugify ??= new Slugify();
$this->pathSegmentEncoder = static fn (string $segment): string => $slugify->slugify($segment);
}
Expand Down
4 changes: 3 additions & 1 deletion src/Views/src/ViewManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ final class ViewManager implements ViewsInterface
{
private readonly LoaderInterface $loader;
private ?ViewCache $cache = null;
private ContextInterface $context;

/** @var EngineInterface[] */
private array $engines = [];
Expand All @@ -20,8 +21,9 @@ public function __construct(
private readonly ViewsConfig $config,
private readonly GlobalVariablesInterface $globalVariables,
FactoryInterface $factory,
private ContextInterface $context = new ViewContext()
?ContextInterface $context = null
) {
$this->context = $context ?? new ViewContext();
$this->loader = $factory->make(LoaderInterface::class, [
'namespaces' => $config->getNamespaces(),
]);
Expand Down

0 comments on commit 9cf5a48

Please sign in to comment.