Skip to content

Commit

Permalink
Offset string does not exist on array<string>|string.
Browse files Browse the repository at this point in the history
Cannot assign offset string to array<string>|string.

Parameter #1 $data of function http_build_query expects array|object, array<string>|string given.

Parameter #2 $string of function explode expects string, string|false|null given.

Method LastDragon_ru\LaraASP\Spa\Angular\Url::serialize() should return array<string>|string but returns array<array<string>|string>|string.
  • Loading branch information
LastDragon-ru committed Aug 14, 2021
1 parent dc33e30 commit feec79b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/spa/src/Angular/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function build(array $parameters = []): string {

// Replace params
$url = Utils::uriFor($this->getTemplate());
$parameters = $this->serialize($parameters);
$parameters = (array) $this->serialize($parameters);

foreach ($params as $param) {
$url = $url->withPath(str_replace(":{$param}", $parameters[$param], $url->getPath()));
Expand Down Expand Up @@ -96,7 +96,7 @@ public function build(array $parameters = []): string {
*/
private function extract(string $template): array {
$names = [];
$parts = explode('/', parse_url($template, PHP_URL_PATH));
$parts = explode('/', (string) parse_url($template, PHP_URL_PATH));

foreach ($parts as $part) {
if (str_starts_with($part, ':')) {
Expand All @@ -108,7 +108,7 @@ private function extract(string $template): array {
}

/**
* @return string|array<string>
* @return string|array<mixed>
*/
private function serialize(mixed $value): string|array {
if (is_float($value)) {
Expand Down

0 comments on commit feec79b

Please sign in to comment.