Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

Bad logic while checking if timeouts are numeric #169

Closed
@javabudd

Description

@javabudd
  • I was not able to find an open or closed issue matching what I'm seeing.
  • This is not a question. (Questions should be asked on chat (Signup here) or our forums.)

There was new logic added to the Client and Socket adapters to apply an integer/numeric check (5b36ca3, 4dc2c30) that is not working as expected.

if ($connectTimeout !== null && (! is_int($connectTimeout) || ! is_numeric($connectTimeout))) {
                throw new AdapterException\InvalidArgumentException(sprintf(
                    'integer or numeric string expected, got %s',
                    gettype($connectTimeout)
                ));
            }

If $connectTimeout is a numeric string, ! is_int($connectTimeout) will return true and the exception will be thrown without is_numeric being called.

Code to reproduce the issue

$client = new \Zend\Http\Client();
$client->setOptions(['timeout' => '20']);

$request = new \Zend\Http\Request();
$client->dispatch($request);

Expected results

Timeout should be validated properly since it's a numeric string.

Actual results

Exception is thrown integer or numeric string expected, got string.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions