Skip to content

Commit

Permalink
update some ..
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Sep 13, 2020
1 parent 4f13562 commit 852e75f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
7 changes: 3 additions & 4 deletions src/event/src/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ public function __construct(string $name = '', array $params = [])
*/
public function destroy(): self
{
$this->params = [];
$this->target = [];
$this->params = $this->target = [];

return $this;
}
Expand Down Expand Up @@ -158,7 +157,7 @@ public function getParams(): array
/**
* clear all param
*/
public function clearParams()
public function clearParams(): array
{
$old = $this->params;
// clear
Expand Down Expand Up @@ -229,7 +228,7 @@ public function hasParam($name): bool
/**
* @param string $name
*/
public function removeParam($name)
public function removeParam($name): void
{
if (isset($this->params[$name])) {
unset($this->params[$name]);
Expand Down
12 changes: 6 additions & 6 deletions src/event/src/Manager/EventManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,11 +303,6 @@ public function trigger($event, $target = null, array $args = []): EventInterfac
$shouldCall[$name] = '';
}

// Have global wildcards '*' listener.
if (isset($this->listenedEvents['*'])) {
$shouldCall['*'] = '';
}

// Like 'app.db.query' => prefix: 'app.db'
if ($pos = strrpos($name, '.')) {
$prefix = substr($name, 0, $pos);
Expand All @@ -319,6 +314,11 @@ public function trigger($event, $target = null, array $args = []): EventInterfac
}
}

// Have global wildcards '*' listener.
if (isset($this->listenedEvents['*'])) {
$shouldCall['*'] = '';
}

// Not found listeners
if (!$shouldCall) {
return $isString ? $this->basicEvent : $event;
Expand All @@ -344,7 +344,7 @@ public function trigger($event, $target = null, array $args = []): EventInterfac
}
}

return $event;
return $this->destroyAfterFire ? $event->destroy() : $event;
}

/**
Expand Down
8 changes: 2 additions & 6 deletions src/stdlib/src/Helper/ObjectHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ public static function getDefaultValue(string $type)
$value = null;
switch ($type) {
case 'int':
case 'float':
case 'double':
case 'integer':
$value = 0;
break;
Expand All @@ -164,12 +166,6 @@ public static function getDefaultValue(string $type)
case 'boolean':
$value = false;
break;
case 'float':
$value = 0;
break;
case 'double':
$value = 0;
break;
}

return $value;
Expand Down

0 comments on commit 852e75f

Please sign in to comment.