replace collect()

This commit is contained in:
Jaeger 2020-04-03 17:33:32 +08:00
parent faea883c6f
commit f0a9798925
4 changed files with 9 additions and 6 deletions

View File

@ -7,6 +7,7 @@
namespace QL; namespace QL;
use Closure; use Closure;
use Tightenco\Collect\Support\Collection;
class Config class Config
{ {
@ -20,8 +21,8 @@ class Config
*/ */
public function __construct() public function __construct()
{ {
$this->plugins = collect(); $this->plugins = new Collection();
$this->binds = collect(); $this->binds = new Collection();
} }

View File

@ -9,6 +9,7 @@ namespace QL\Dom;
use phpDocumentor\Reflection\Types\Null_; use phpDocumentor\Reflection\Types\Null_;
use phpQueryObject; use phpQueryObject;
use Tightenco\Collect\Support\Collection;
/** /**
* Class Elements * Class Elements
@ -191,7 +192,7 @@ class Elements
*/ */
public function map($callback) public function map($callback)
{ {
$collection = collect(); $collection = new Collection();
$this->elements->each(function ($dom) use (& $collection, $callback) { $this->elements->each(function ($dom) use (& $collection, $callback) {
$collection->push($callback(new self(pq($dom)))); $collection->push($callback(new self(pq($dom))));
}); });

View File

@ -147,7 +147,7 @@ class Query
{ {
if (is_callable($callback)) { if (is_callable($callback)) {
if (empty($this->range)) { if (empty($this->range)) {
$data = collect($callback($data->all(), null)); $data = new Collection($callback($data->all(), null));
} else { } else {
$data = $data->map($callback); $data = $data->map($callback);
} }
@ -178,7 +178,7 @@ class Query
} }
} }
return collect($data); return new Collection($data);
} }
protected function extractContent(phpQueryObject $pqObj, $ruleName, $rule) protected function extractContent(phpQueryObject $pqObj, $ruleName, $rule)

View File

@ -14,6 +14,7 @@ use Closure;
use QL\Providers\HttpServiceProvider; use QL\Providers\HttpServiceProvider;
use QL\Providers\PluginServiceProvider; use QL\Providers\PluginServiceProvider;
use QL\Providers\SystemServiceProvider; use QL\Providers\SystemServiceProvider;
use Tightenco\Collect\Support\Collection;
class Kernel class Kernel
{ {
@ -34,7 +35,7 @@ class Kernel
public function __construct(QueryList $ql) public function __construct(QueryList $ql)
{ {
$this->ql = $ql; $this->ql = $ql;
$this->binds = collect(); $this->binds = new Collection();
} }
public function bootstrap() public function bootstrap()