-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[ObjectMapper] CS fixes #60031
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ObjectMapper] CS fixes #60031
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,7 +100,7 @@ public function testHasNothingToMapTo() | |
{ | ||
$this->expectException(MappingException::class); | ||
$this->expectExceptionMessage('Mapping target not found for source "class@anonymous".'); | ||
(new ObjectMapper())->map(new class () {}); | ||
(new ObjectMapper())->map(new class {}); | ||
} | ||
|
||
public function testHasNothingToMapToWithNamedClass() | ||
|
@@ -211,7 +211,7 @@ public function get(string $id): mixed | |
}; | ||
} | ||
|
||
public function testSourceOnly(): void | ||
public function testSourceOnly() | ||
{ | ||
$a = new \stdClass(); | ||
$a->name = 'test'; | ||
|
@@ -220,7 +220,7 @@ public function testSourceOnly(): void | |
$this->assertInstanceOf(SourceOnly::class, $mapped); | ||
$this->assertSame('test', $mapped->mappedName); | ||
|
||
$a = new class () { | ||
$a = new class { | ||
public function __get(string $key): string | ||
{ | ||
return match ($key) { | ||
|
@@ -235,13 +235,12 @@ public function __get(string $key): string | |
$this->assertSame('test', $mapped->mappedName); | ||
} | ||
|
||
|
||
public function testTransformToWrongValueType(): void | ||
public function testTransformToWrongValueType() | ||
{ | ||
$this->expectException(MappingTransformException::class); | ||
$this->expectExceptionMessage('Cannot map "stdClass" to a non-object target of type "string".'); | ||
OskarStark marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
$u = new \stdClass; | ||
$u = new \stdClass(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
$u->foo = 'bar'; | ||
|
||
$metadata = $this->createStub(ObjectMapperMetadataFactoryInterface::class); | ||
|
@@ -250,16 +249,16 @@ public function testTransformToWrongValueType(): void | |
$mapper->map($u); | ||
} | ||
|
||
public function testTransformToWrongObject(): void | ||
public function testTransformToWrongObject() | ||
{ | ||
$this->expectException(MappingException::class); | ||
$this->expectExceptionMessage(sprintf('Expected the mapped object to be an instance of "%s" but got "stdClass".', ClassWithoutTarget::class)); | ||
$this->expectExceptionMessage(\sprintf('Expected the mapped object to be an instance of "%s" but got "stdClass".', ClassWithoutTarget::class)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There should also be a CS fixer for this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is native_function_invocation There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, didn't found it on the go |
||
|
||
$u = new \stdClass; | ||
$u = new \stdClass(); | ||
$u->foo = 'bar'; | ||
|
||
$metadata = $this->createStub(ObjectMapperMetadataFactoryInterface::class); | ||
$metadata->method('create')->with($u)->willReturn([new Mapping(target: ClassWithoutTarget::class, transform: fn() => new \stdClass)]); | ||
$metadata->method('create')->with($u)->willReturn([new Mapping(target: ClassWithoutTarget::class, transform: fn () => new \stdClass())]); | ||
GromNaN marked this conversation as resolved.
Show resolved
Hide resolved
|
||
$mapper = new ObjectMapper($metadata); | ||
$mapper->map($u); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we enable:
https://cs.symfony.com/doc/rules/operator/new_with_parentheses.html#example-2