Skip to content

Commit 6f36d96

Browse files
committed
call method accepts Query as well
1 parent bdd133a commit 6f36d96

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

composer.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,10 @@
5757
"infect": "XDEBUG_MODE=coverage infection --show-mutations"
5858
},
5959
"minimum-stability": "stable",
60-
"prefer-stable": true
60+
"prefer-stable": true,
61+
"config": {
62+
"allow-plugins": {
63+
"infection/extension-installer": false
64+
}
65+
}
6166
}

src/Query.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
namespace WikibaseSolutions\CypherDSL;
2323

2424
use Closure;
25+
use Prophecy\Call\Call;
2526
use WikibaseSolutions\CypherDSL\Clauses\CallClause;
2627
use WikibaseSolutions\CypherDSL\Clauses\CallProcedureClause;
2728
use WikibaseSolutions\CypherDSL\Clauses\Clause;
@@ -57,6 +58,7 @@
5758
use WikibaseSolutions\CypherDSL\Types\StructuralTypes\NodeType;
5859
use WikibaseSolutions\CypherDSL\Types\StructuralTypes\PathType;
5960
use WikibaseSolutions\CypherDSL\Types\StructuralTypes\StructuralType;
61+
use function is_callable;
6062

6163
/**
6264
* Builder class for building complex Cypher queries.
@@ -640,17 +642,20 @@ public function callProcedure(string $procedure, array $arguments = [], array $y
640642
/**
641643
* Creates a CALL sub query clause.
642644
*
643-
* @param callable(Query) $decorator The callable decorating the pattern.
645+
* @param callable(Query)|Query $decoratorOrClause The callable decorating the pattern, or the actual CALL clause.
644646
*
645647
* @return Query
646648
*
647649
* @see https://neo4j.com/docs/cypher-manual/current/clauses/call-subquery/
648650
*/
649-
public function call($decorator): self
651+
public function call($decoratorOrClause): self
650652
{
651-
$subQuery = self::new();
652-
653-
$decorator($subQuery);
653+
if (is_callable($decoratorOrClause)) {
654+
$subQuery = self::new();
655+
$decoratorOrClause($subQuery);
656+
} else {
657+
$subQuery = $decoratorOrClause;
658+
}
654659

655660
$this->clauses[] = new CallClause($subQuery);
656661

0 commit comments

Comments
 (0)