Skip to content
This repository was archived by the owner on Jan 23, 2019. It is now read-only.

Commit f6a60c4

Browse files
committed
bug fixed for container
1 parent 192b53d commit f6a60c4

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

src/collections/Collection.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ public static function make($data = null, $format = 'php', $name = 'box1')
103103
*/
104104
public function set($path, $value)
105105
{
106-
if (is_array($value) || is_object($value)) {
107-
$value = DataHelper::toArray($value, true);
108-
}
106+
// if (is_array($value) || is_object($value)) {
107+
// $value = DataHelper::toArray($value, true);
108+
// }
109109

110110
Arr::setByPath($this->data, $path, $value, $this->separator);
111111

@@ -331,7 +331,7 @@ protected function bindData(&$parent, $data, $raw = false)
331331
{
332332
// Ensure the input data is an array.
333333
if (!$raw) {
334-
$data = DataHelper::toArray($data, true);
334+
$data = DataHelper::toArray($data);
335335
}
336336

337337
foreach ($data as $key => $value) {

src/di/Container.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public function __destruct()
119119
* 'shared' => (bool), 是否共享
120120
* 'locked' => (bool), 是否锁定服务
121121
* 'aliases' => (array), 别名
122-
* 'activity' => (bool), 立即激活
122+
* 'active' => (bool), 立即激活
123123
* ]
124124
* @return $this
125125
* @internal param bool $shared 是否共享
@@ -139,7 +139,7 @@ public function set($id, $definition, array $opts = [])
139139
'aliases' => null,
140140
'shared' => true,
141141
'locked' => false,
142-
'activity' => false,
142+
'active' => false,
143143
], $opts);
144144

145145
// 已经是个服务实例 object 不是闭包 closure
@@ -189,8 +189,8 @@ public function set($id, $definition, array $opts = [])
189189

190190
$this->services[$id] = new Service($callback, $args, $opts['shared'], $opts['locked']);
191191

192-
// activity
193-
if ($opts['activity']) {
192+
// active service
193+
if ($opts['active']) {
194194
$this->get($id);
195195
}
196196

src/helpers/DataHelper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ public static function decode($txt, $allowedClasses = false)
4545
public static function toArray($data, $recursive = false)
4646
{
4747
// Ensure the input data is an array.
48-
if ($data instanceof \Traversable) {
48+
if (is_object($data) && $data instanceof \Traversable) {
4949
$data = iterator_to_array($data);
50-
} elseif (is_object($data)) {
51-
$data = get_object_vars($data);
50+
// } elseif (is_object($data)) {
51+
// $data = get_object_vars($data);
5252
} else {
5353
$data = (array)$data;
5454
}

src/helpers/PhpHelper.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,21 +132,24 @@ public static function hasXdebug(): bool
132132
* @param \Exception|\Throwable $e the exception being converted
133133
* @param bool $clearHtml
134134
* @param bool $getTrace
135+
* @param null|string $catcher
135136
* @return string the string representation of the exception.
136137
*/
137-
public static function exceptionToString($e, $clearHtml = false, $getTrace = false): string
138+
public static function exceptionToString($e, $clearHtml = false, $getTrace = false, $catcher = null): string
138139
{
139140
if (!$getTrace) {
140141
$message = "Error: {$e->getMessage()}";
141142
} else {
142143
$type = $e instanceof \ErrorException ? 'Error' : 'Exception';
144+
$catcher = $catcher ? "Catch By: $catcher\n" : '';
143145
$message = sprintf(
144-
"<h3>%s(%d): %s</h3>\n<pre><strong>File: %s(Line %d)</strong> \n\n%s</pre>",
146+
"<h3>%s(%d): %s</h3>\n<pre><strong>File: %s(Line %d)</strong>%s \n\n%s</pre>",
145147
$type,
146148
$e->getCode(),
147149
$e->getMessage(),
148150
$e->getFile(),
149151
$e->getLine(),
152+
$catcher,
150153
$e->getTraceAsString()
151154
);
152155

0 commit comments

Comments
 (0)