Skip to content

rector add white space at end of line after new keyword #9208

@landure

Description

@landure

Bug Report

Subject Details
Rector version e.g. v2.0.17

Rector adds a white space after new keyword before a line break.
This is an issue when declaring anonymous classes implementing an interface with generic typing.
The generic type declaration must be between the new and the class keywords.
The added white space is removed by PHP CS Fixer.

This is a recent behaviour, that appeared after May the 1st 2025.

See https://getrector.com/demo/2516b692-0b45-4ce4-8c2a-a835533cc8c5

Minimal PHP Code Causing Issue

<?php
$stringable = new
    /**
     * @implements \Stringeable
     */
    class implements \Stringeable {
        #[\Override]
     	public function __toString(): string
    	{
        	return '';
    	}
    };

Expected Behaviour

Rector shouldn't change the code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions