Skip to content

Support subqueries #3

@echo511

Description

@echo511
{
  "classes": [
    {
      "type": "A",
      "implements": [
        {
          "type": "IA"
        },
        {
          "type": "IX"
        }
      ]
    },
    {
      "type": "B",
      "implements": [
        {
          "type": "IB"
        },
        {
          "type": "IX"
        }
      ]
    },
    {
      "type": "C",
      "implements": []
    }
  ]
}
$parser = \phpDocumentor\JsonPath\Parser::createInstance();
$query = $parser->parse('$.classes[?(@.implements[?(@.type == "IX")])]');

$executor = new \phpDocumentor\JsonPath\Executor();
foreach ($executor->evaluate($query, $json) as $result) {
    var_dump($result);
}

results in parsing error even though the syntax is valid - works at https://jsonpath.com.

For context:

I am trying using phpdocumentor class-list directive against interface not abstract class. The code below works only on abstract classes.

.. phpdoc:class-list:: [?(@.inheritedElement == "\phpDocumentor\Transformer\Writer\WriterAbstract")]

I had dumped AST tree and trying to use implements collection defined on class metadata. But I cannot subfilter. Hence this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions