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\PhpGenerator\Traits;
9:
10:
11: /**
12: * @internal
13: */
14: trait CommentAware
15: {
16: /** @var string|null */
17: private $comment;
18:
19:
20: /**
21: * @param string|null
22: * @return static
23: */
24: public function setComment($val)
25: {
26: $this->comment = $val ? (string) $val : null;
27: return $this;
28: }
29:
30:
31: /**
32: * @return string|null
33: */
34: public function getComment()
35: {
36: return $this->comment;
37: }
38:
39:
40: /**
41: * @param string
42: * @return static
43: */
44: public function addComment($val)
45: {
46: $this->comment .= $this->comment ? "\n$val" : $val;
47: return $this;
48: }
49:
50:
51: /** @deprecated */
52: public function setDocuments(array $s)
53: {
54: trigger_error(__METHOD__ . '() is deprecated, use similar setComment()', E_USER_DEPRECATED);
55: return $this->setComment(implode("\n", $s));
56: }
57:
58:
59: /** @deprecated */
60: public function getDocuments()
61: {
62: trigger_error(__METHOD__ . '() is deprecated, use similar getComment()', E_USER_DEPRECATED);
63: return $this->comment ? [$this->comment] : [];
64: }
65:
66:
67: /** @deprecated */
68: public function addDocument($s)
69: {
70: trigger_error(__METHOD__ . '() is deprecated, use addComment()', E_USER_DEPRECATED);
71: return $this->addComment($s);
72: }
73: }
74: