Skip to content

Matching empty array always return true #13

@pskt

Description

@pskt

Hi

I'm using php-matcher to match some JSONs and I found an issue.
If in $value will be empty array php-matcher always return true.

For example, as $value I have

{"status":"ok","data":[]}

And as $pattern

{
  "status": "ok",
  "data": [
      {
          "id": @integer@,
          "code": "123987",
          "name": "Anvill",
          "short_description": "ACME Anvill",
          "url": "http://test-store.example.com/p/123987",
          "image": {
          "url": "http://test-store.example.com/i/123987-0.jpg",
          "description": "ACME Anvill"
          },
          "price": 95,
          "promotion_description": "Anvills sale"
      },
      {
          "id": @integer@,
          "code": "123988",
          "name": "Red Anvill",
          "short_description": "Red ACME Anvill",
          "url": "http://test-store.example.com/p/123988",
          "image": {
          "url": "http://test-store.example.com/i/123988-0.jpg",
          "description": "ACME Anvill"
          },
          "price": 44.99,
          "promotion_description": "Red is cheap"
      }
  ]
}

And matcher return true.

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