Skip to content

Commit

Permalink
PropertySource: toString() returns non-static property name without $…
Browse files Browse the repository at this point in the history
… prefix to match PHP behaviour
  • Loading branch information
mabar committed Jul 10, 2023
1 parent fe6b5bf commit 677d1c2
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased](https://github.com/orisai/source-map/compare/1.0.0...HEAD)

### Changed

- `PropertySource->toString()` returns non-static property name without `$` prefix to match PHP behaviour

## [1.0.0](https://github.com/orisai/source-map/releases/tag/1.0.0) - 2023-01-10

### Added
Expand Down
4 changes: 2 additions & 2 deletions src/PropertySource.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ public function toString(): string
$this->throwIfInvalid();

$symbol = $this->reflector->isStatic()
? '::'
? '::$'
: '->';

return "{$this->getClass()->toString()}$symbol\${$this->reflector->getName()}";
return "{$this->getClass()->toString()}$symbol{$this->reflector->getName()}";
}

public function isValid(): bool
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/AnnotationSourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function provideTarget(): Generator

yield [
new PropertySource(new ReflectionProperty($class, 'test')),
"{$class}->\$test",
"{$class}->test",
];

require_once __DIR__ . '/../Doubles/testFunction.php';
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/AttributeSourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function provideTarget(): Generator

yield [
new PropertySource(new ReflectionProperty($class, 'test')),
"{$class}->\$test",
"{$class}->test",
];

require_once __DIR__ . '/../Doubles/testFunction.php';
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/EmptyAboveReflectorSourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function provideTarget(): Generator

yield [
new PropertySource(new ReflectionProperty($class, 'test')),
"{$class}->\$test",
"{$class}->test",
];

require_once __DIR__ . '/../Doubles/testFunction.php';
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/PropertySourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function test(): void
self::assertEquals($classSource, $source->getClass());
self::assertSame($reflector, $source->getReflector());

self::assertSame("$class->\$test", $source->toString());
self::assertSame("{$class}->test", $source->toString());
self::assertSame($source->toString(), (string) $source);

self::assertEquals($source->getClass()->getLastChange(), $source->getLastChange());
Expand Down Expand Up @@ -66,7 +66,7 @@ public function testSerializationBC(): void
self::assertTrue($source->isValid());
self::assertEquals($classSource, $source->getClass());
self::assertEquals($reflector, $source->getReflector());
self::assertSame("$class->\$test", $source->toString());
self::assertSame("{$class}->test", $source->toString());
self::assertEquals($source, unserialize(serialize($source)));
}

Expand Down

0 comments on commit 677d1c2

Please sign in to comment.