Skip to content

Commit

Permalink
Add return type hints (#6)
Browse files Browse the repository at this point in the history
This adds a few return type hints to address deprecation notices and be forwards-compatible with future Symfony versions.

These changes are compatible even with PHP 7.2.
  • Loading branch information
mpdude authored May 5, 2022
1 parent 7b61693 commit 7dcd8cf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/JMS/ObjectRouting/Metadata/ClassMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function merge(MergeableInterface $object): void
$this->routes = array_merge($this->routes, $object->routes);
}

public function serialize()
public function serialize(): string
{
return serialize(
array(
Expand All @@ -49,7 +49,7 @@ public function serialize()
);
}

public function unserialize($str)
public function unserialize($str): void
{
list(
$this->routes,
Expand Down
6 changes: 3 additions & 3 deletions src/JMS/ObjectRouting/Twig/RoutingExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ public function __construct(ObjectRouter $router)
$this->router = $router;
}

public function getFunctions()
public function getFunctions(): array
{
return [
new TwigFunction('object_path', [$this, 'path']),
new TwigFunction('object_url', [$this, 'url']),
];
}

public function url($type, $object, array $extraParams = [])
public function url($type, $object, array $extraParams = []): string
{
return $this->router->generate($type, $object, true, $extraParams);
}

public function path($type, $object, array $extraParams = [])
public function path($type, $object, array $extraParams = []): string
{
return $this->router->generate($type, $object, false, $extraParams);
}
Expand Down

0 comments on commit 7dcd8cf

Please sign in to comment.