Skip to content

Commit 5152375

Browse files
committed
Resolver: processing of functions like not() moved to PhpGenerator
1 parent 965c203 commit 5152375

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

src/DI/PhpGenerator.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,15 @@ public function formatStatement(Statement $statement): string
113113
case is_string($entity) && str_contains($entity, '?'): // PHP literal
114114
return $this->formatPhp($entity, $arguments);
115115

116+
case $entity === 'not':
117+
return $this->formatPhp('!(?)', $arguments);
118+
119+
case $entity === 'bool':
120+
case $entity === 'int':
121+
case $entity === 'float':
122+
case $entity === 'string':
123+
return $this->formatPhp('?::?(?, ?)', [Helpers::class, 'convertType', $arguments[0], $entity]);
124+
116125
case is_string($entity): // create class
117126
return $arguments
118127
? $this->formatPhp("new $entity(...?:)", [$arguments])

src/DI/Resolver.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -192,23 +192,13 @@ public function completeStatement(Statement $statement, bool $currentServiceAllo
192192
break;
193193

194194
case $entity === 'not':
195-
if (count($arguments) !== 1) {
196-
throw new ServiceCreationException(sprintf('Function %s() expects 1 parameter, %s given.', $entity, count($arguments)));
197-
}
198-
199-
$entity = ['', '!'];
200-
break;
201-
202195
case $entity === 'bool':
203196
case $entity === 'int':
204197
case $entity === 'float':
205198
case $entity === 'string':
206199
if (count($arguments) !== 1) {
207200
throw new ServiceCreationException(sprintf('Function %s() expects 1 parameter, %s given.', $entity, count($arguments)));
208201
}
209-
210-
$arguments = [$arguments[0], $entity];
211-
$entity = [Helpers::class, 'convertType'];
212202
break;
213203

214204
case is_string($entity): // create class

0 commit comments

Comments
 (0)