Skip to content

Commit 84c61bc

Browse files
committed
ServiceDefinition: removes leading \ from class names and checks implementType
1 parent 6cd15c0 commit 84c61bc

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/DI/ServiceDefinition.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class ServiceDefinition extends Nette\Object
5050
*/
5151
public function setClass($class, array $args = array())
5252
{
53-
$this->class = $class;
53+
$this->class = ltrim($class, '\\');
5454
if ($args) {
5555
$this->setFactory($class, $args);
5656
}
@@ -243,7 +243,7 @@ public function isDynamic()
243243
*/
244244
public function setImplement($interface)
245245
{
246-
$this->implement = (string) $interface;
246+
$this->implement = ltrim($interface, '\\');
247247
return $this;
248248
}
249249

@@ -263,7 +263,10 @@ public function getImplement()
263263
*/
264264
public function setImplementType($type)
265265
{
266-
$this->implementType = (string) $type;
266+
if (!in_array($type, array('get', 'create'), TRUE)) {
267+
throw new Nette\InvalidArgumentException('Argument must be get|create.');
268+
}
269+
$this->implementType = $type;
267270
return $this;
268271
}
269272

0 commit comments

Comments
 (0)