Skip to content
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

In PHP8 get this error: Fatal error: Unparenthesized ` #21

Open
marcelscholte opened this issue Mar 29, 2023 · 0 comments
Open

In PHP8 get this error: Fatal error: Unparenthesized ` #21

marcelscholte opened this issue Mar 29, 2023 · 0 comments

Comments

@marcelscholte
Copy link

I php8 get this error in
Fatal error: Unparenthesized a ? b : c ? d : e is not supported. Use either (a ? b : c) ? d : e or a ? b : (c ? d : e) in ..../composer/vendor/route4me/route4me-php/src/Route4Me/OptimizationProblem.php on line 201

See https://stackoverflow.com/questions/61432488/php-error-unparenthesized-a-b-c-d-e-is-deprecated-use-either-a

I fixed the function in: OptimizationProblem.php. You want to update this in de SDK?

public static function update($params)
{
    $allQueryFields = ['optimization_problem_id', 'reoptimize'];
    $allBodyFields = ['addresses', 'parameters'];
    $query = ( is_array($params)
                ? (isset($params['optimization_problem_id']) || isset($params['parameters']))
				
                    ? Route4Me::generateRequestParameters($allQueryFields, $params)
                    : null
                : (isset($params->optimization_problem_id) || isset($params->parameters))
                   ) ? Route4Me::generateRequestParameters($allQueryFields, $params)
                    : null;

    $body =( is_array($params)
        ? (isset($params['addresses']) && sizeof($params['addresses'])>0) ||
        (isset($params['parameters']) && sizeof($params['parameters'])>0)
            ? Route4Me::generateRequestParameters($allBodyFields, $params)
            : null
        : (isset($params->addresses) && sizeof($params->addresses)>0) ||
            (isset($params->parameters) && sizeof($params->parameters)>0)
              )  ? Route4Me::generateRequestParameters($allBodyFields, $params)
                : null;

    $optimize = Route4Me::makeRequst([
        'url'       => Endpoint::OPTIMIZATION_PROBLEM,
        'method'    => 'PUT',
        'query'     => $query,
        'body'      => $body,
    ]);

    return $optimize;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant