1 | <?php |
||
35 | abstract class BaseMessage extends MagicAttributes |
||
36 | { |
||
37 | |||
38 | /** |
||
39 | * 允许的属性 |
||
40 | * |
||
41 | * @var array |
||
42 | */ |
||
43 | protected $properties = array(); |
||
44 | |||
45 | /** |
||
46 | * 基础属性 |
||
47 | * |
||
48 | * @var array |
||
49 | */ |
||
50 | protected $baseProperties = array( |
||
51 | 'from', |
||
52 | 'to', |
||
53 | 'to_group', |
||
54 | 'to_all', |
||
55 | 'staff', |
||
56 | ); |
||
57 | |||
58 | /** |
||
59 | * 生成用于主动推送的数据 |
||
60 | * |
||
61 | * @return array |
||
62 | */ |
||
63 | public function buildForStaff() |
||
79 | |||
80 | /** |
||
81 | * 生成用于回复的数据 |
||
82 | * |
||
83 | * @return array |
||
84 | */ |
||
85 | public function buildForReply() |
||
100 | |||
101 | /** |
||
102 | * 生成通过群发的数据 |
||
103 | * |
||
104 | * @return array |
||
105 | */ |
||
106 | public function buildForBroadcast() |
||
107 | { |
||
108 | if (!method_exists($this, 'toStaff')) { |
||
109 | throw new \Exception(__CLASS__.'未实现此方法:toStaff()'); |
||
110 | } |
||
111 | |||
112 | if (is_null($this->to_group)) { |
||
|
|||
113 | $group = array( |
||
114 | 'filter' => array( |
||
115 | 'is_to_all' => true, |
||
116 | ), |
||
117 | ); |
||
118 | } elseif (is_array($this->to_group)) { |
||
119 | $group = array( |
||
120 | 'touser' => $this->to_group, |
||
121 | ); |
||
122 | } else { |
||
123 | $group = array( |
||
124 | 'filter' => array( |
||
125 | 'is_to_all' => false, |
||
126 | 'group_id' => $this->to_group, |
||
127 | ), |
||
128 | ); |
||
129 | } |
||
130 | |||
131 | $base = array( |
||
132 | 'msgtype' => $this->getDefaultMessageType(), |
||
133 | ); |
||
134 | |||
135 | return array_merge($group, $this->toStaff(), $base); |
||
136 | } |
||
137 | |||
138 | /** |
||
139 | * 生成通过群发预览的数据 |
||
140 | * |
||
141 | * @param $type |
||
142 | * |
||
143 | * @return array |
||
144 | * |
||
145 | * @throws \Exception |
||
146 | */ |
||
147 | public function buildForBroadcastPreview($type) |
||
160 | |||
161 | /** |
||
162 | * 获取默认的消息类型名称 |
||
163 | * |
||
164 | * @return string |
||
165 | */ |
||
166 | public function getDefaultMessageType() |
||
172 | |||
173 | /** |
||
174 | * 验证 |
||
175 | * |
||
176 | * @param string $attribute |
||
177 | * @param mixed $value |
||
178 | * |
||
179 | * @return bool |
||
180 | */ |
||
181 | protected function validate($attribute, $value) |
||
187 | } |
||
188 |
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.