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 class|method|$property */
26: private $entity;
27:
28:
29: /**
30: * @param string|array|ServiceDefinition|null
31: */
32: public function __construct($entity, array $arguments = [])
33: {
34: if (!is_string($entity) && !(is_array($entity) && isset($entity[0], $entity[1]))
35: && !$entity instanceof ServiceDefinition && $entity !== null
36: ) {
37: throw new Nette\InvalidArgumentException('Argument is not valid Statement entity.');
38: }
39: $this->entity = $entity;
40: $this->arguments = $arguments;
41: }
42:
43:
44: /** @deprecated */
45: public function setEntity($entity)
46: {
47: trigger_error(__METHOD__ . ' is deprecated, change Statement object itself.', E_USER_DEPRECATED);
48: $this->__construct($entity, $this->arguments);
49: return $this;
50: }
51:
52:
53: public function getEntity()
54: {
55: return $this->entity;
56: }
57: }
58: