Skip to content

Commit

Permalink
prefer toString usage over __toString
Browse files Browse the repository at this point in the history
  • Loading branch information
nyamsprod committed Jun 16, 2023
1 parent 2ce490a commit d520eb8
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion FactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public function testCreateFromUri(): void
self::assertSame((string) $psr7, (string) $uriFromLeagueUri);

$uribis = Http::fromString();
self::assertSame((string) $uribis, Uri::fromUri($uribis)->__toString());
self::assertSame((string) $uribis, Uri::fromUri($uribis)->toString());
}

/**
Expand Down
4 changes: 2 additions & 2 deletions Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,12 @@ public function getFragment(): string

public function __toString(): string
{
return $this->uri->__toString();
return $this->uri->toString();
}

public function jsonSerialize(): string
{
return $this->uri->__toString();
return $this->uri->toString();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion UriStringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ public static function validUriProvider(): array
],
'URI is a object with __toString' => [
new class() {
public function __toString()
public function __toString(): string
{
return 'http://example.org/hello:12?foo=bar#test';
}
Expand Down
10 changes: 5 additions & 5 deletions UriTemplateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public static function expectedVariableNames(): iterable
*/
public function testExpandsUriTemplates(string $template, string $expectedUriString, array $variables): void
{
self::assertSame($expectedUriString, (new UriTemplate($template))->expand($variables)->__toString());
self::assertSame($expectedUriString, (new UriTemplate($template))->expand($variables)->toString());
}

public static function templateExpansionProvider(): iterable
Expand Down Expand Up @@ -258,7 +258,7 @@ public function testAllowsQueryValuePairsArrayExpansion(): void

self::assertSame(
'http://example.com/foo/bar/one,two?query=test&more=fun&more=ice%20cream&foo%5B%5D=fizz&foo%5B%5D=buzz',
(new UriTemplate($template))->expand($variables)->__toString()
(new UriTemplate($template))->expand($variables)->toString()
);
}

Expand Down Expand Up @@ -301,7 +301,7 @@ public function testExpandWithDefaultVariables(): void

self::assertSame(
'http://example.com/foo/bar/one,two?query=test&more=fun&more=ice%20cream&foo%5B%5D=fizz&foo%5B%5D=buzz',
(new UriTemplate($template, $defaultVariables))->expand($variables)->__toString()
(new UriTemplate($template, $defaultVariables))->expand($variables)->toString()
);
}

Expand All @@ -323,7 +323,7 @@ public function testExpandWithDefaultVariablesWithOverride(): void

self::assertSame(
'http://example.com/bar/baz/one,two?query=test&more=fun&more=ice%20cream&foo%5B%5D=fizz&foo%5B%5D=buzz',
(new UriTemplate($template, $defaultVariables))->expand($variables)->__toString()
(new UriTemplate($template, $defaultVariables))->expand($variables)->toString()
);
}

Expand Down Expand Up @@ -353,6 +353,6 @@ public function testExpansionWithMultipleSameExpression(): void
$template = '{foo}/{foo}';
$data = ['foo' => 'foo'];

self::assertSame('foo/foo', (new UriTemplate($template, $data))->expand()->__toString());
self::assertSame('foo/foo', (new UriTemplate($template, $data))->expand()->toString());
}
}
2 changes: 1 addition & 1 deletion UriTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public static function missingAuthorityProvider(): array
public function testEmptyValueDetection(): void
{
$expected = '//0:0@0/0?0#0';
self::assertSame($expected, Uri::fromString($expected)->__toString());
self::assertSame($expected, Uri::fromString($expected)->toString());
}

public function testPathDetection(): void
Expand Down

0 comments on commit d520eb8

Please sign in to comment.