1: <?php
2:
3: /**
4: * This file is part of the Nette Framework (https://nette.org)
5: * Copyright (c) 2004 David Grudl (https://davidgrudl.com)
6: */
7:
8: namespace Nette\DI;
9:
10: use Nette;
11:
12:
13: /**
14: * Assignment or calling statement.
15: *
16: * @property string|array|ServiceDefinition|null $entity
17: */
18: class Statement
19: {
20: use Nette\SmartObject;
21:
22: /** @var array */
23: public $arguments;
24:
25: /** @var string|array|ServiceDefinition|null */
26: private $entity;
27:
28:
29: /**
30: * @param string|array|ServiceDefinition|null
31: */
32: public function __construct($entity, array $arguments = [])
33: {
34: if (
35: !is_string($entity) // Class, @service, not, PHP literal, entity::member
36: && !(is_array($entity) && isset($entity[0], $entity[1])) // [Class | @service | '' | Statement | ServiceDefinition, method | $property | $appender]
37: && !$entity instanceof ServiceDefinition
38: && $entity !== null
39: ) {
40: throw new Nette\InvalidArgumentException('Argument is not valid Statement entity.');
41: }
42: $this->entity = $entity;
43: $this->arguments = $arguments;
44: }
45:
46:
47: /** @deprecated */
48: public function setEntity($entity)
49: {
50: trigger_error(__METHOD__ . ' is deprecated, change Statement object itself.', E_USER_DEPRECATED);
51: $this->__construct($entity, $this->arguments);
52: return $this;
53: }
54:
55:
56: public function getEntity()
57: {
58: return $this->entity;
59: }
60: }
61: