Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

update Factory #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
blankqwq merged 1 commit into master from dev
Mar 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions composer.json
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "blankqwq/framework",
"name": "blankphp/framework",
"description": "a mvc framework",
"license": "MIT",
"authors": [
Expand All @@ -10,8 +10,8 @@
],
"autoload": {
"psr-4": {
"Blankphp\\": "src/blankphp/",
"Helpers\\": "src/helpers/"
"BlankPhp\\": "src/blankphp/",
"BlankQwq\\Helpers\\": "src/helpers/"
},
"files": [
"src/helpers/helper.php"
Expand All @@ -25,7 +25,7 @@
"repositories": {
"blankqwq": {
"type": "path",
"url": "/home/vagrant/chart/framework"
"url": "/home/blank/project/framework"
}
}
}
25 changes: 14 additions & 11 deletions src/blankphp/Application.php
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@


use Blankphp\Cache\Cache;
use Blankphp\Cache\Driver\File;
use Blankphp\Cache\Driver\Redis;
use Blankphp\Config\Config;
use Blankphp\Config\LoadConfig;
use Blankphp\Contract\CookieContract;
Expand All @@ -21,6 +19,7 @@
use Blankphp\Database\Grammar\MysqlGrammar;
use Blankphp\Exception\Error;
use Blankphp\Exception\NotFoundClassException;
use BlankPhp\Factory\FactoryBase;
use Blankphp\Kernel\ConsoleKernel;
use Blankphp\Kernel\HttpKernel;
use Blankphp\Log\Log;
Expand All @@ -37,8 +36,10 @@
class Application extends Container
{

private $version = "0.1.3-dev";
private $version = '0.1.3-dev';

protected $boot = false;

protected $bootstraps = [
LoadConfig::class => 'load',
Error::class => 'register',
Expand Down Expand Up @@ -71,7 +72,7 @@ public function bootstrap()

public function registerDirName()
{
define("PUBLIC_PATH", APP_PATH . DIRECTORY_SEPARATOR . "public/");
define('PUBLIC_PATH', APP_PATH . DIRECTORY_SEPARATOR . 'public/');
}

public function registerService()
Expand All @@ -82,7 +83,7 @@ public function registerService()
'request' => [\Blankphp\Contract\Request::class, Request::class],
'route' => [\Blankphp\Contract\Route::class, Route::class],
'router' => [Router::class],
'app' => [\Blankphp\Contract\Container::class, Application::class],
'app' => [\Blankphp\Contract\Container::class, __CLASS__],
'db' => Database::class,
'db.grammar' => [Grammar::class, MysqlGrammar::class],
'view' => [\Blankphp\Contract\View::class, View::class],
Expand All @@ -97,16 +98,18 @@ public function registerService()
'redis' => [Redis::class],
'log' => Log::class
];
array_walk($temp, array($this, "bind"));
array_walk($temp, array($this, 'bind'));
unset($temp);
}


public function make($abstract, $parameters = [])
{
if (!$this->has($abstract))
if (class_exists($abstract) && !empty($parameters))
return $this->instance($abstract, new $abstract(...$parameters));;
if (!$this->has($abstract)) {
if (class_exists($abstract) && !empty($parameters)) {
return $this->instance($abstract, new $abstract(...$parameters));
}
}
return parent::make($abstract, $parameters);
}

Expand All @@ -122,9 +125,9 @@ public function getSignal($abstract, $name = '')
{
if (empty($name)) {
return isset($this->signal[$abstract]) ? $this->signal[$abstract] : [];
} else {
return isset($this->signal[$abstract][$name]) ? $this->signal[$abstract][$name] : [];
}

return isset($this->signal[$abstract][$name]) ? $this->signal[$abstract][$name] : [];
}

public function unsetSignal($abstract)
Expand Down
2 changes: 1 addition & 1 deletion src/blankphp/Cache/Cache.php
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Blankphp\Application;
use Blankphp\Contract\Container;
use Blankphp\Facade\Driver;
use Helpers\Str;
use BlankQwq\Helpers\Str;

class Cache extends CacheAbstract
{
Expand Down
2 changes: 1 addition & 1 deletion src/blankphp/Console/Cache/CacheConsole.php
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


use Blankphp\Console\Console;
use Helpers\File;
use BlankQwq\Helpers\File;

class CacheConsole extends Console
{
Expand Down
2 changes: 1 addition & 1 deletion src/blankphp/Console/Publish/PublishConsole.php
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Blankphp\Console\Console;
use Blankphp\Exception\Exception;
use Helpers\Str;
use BlankQwq\Helpers\Str;

class PublishConsole extends Console
{
Expand Down
41 changes: 23 additions & 18 deletions src/blankphp/Container.php
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

namespace Blankphp;

use Blankphp\Cache\Driver\File;
use \Blankphp\Contract\Container as ContainerContract;
use Blankphp\Exception\NotFoundClassException;

Expand Down Expand Up @@ -76,7 +75,7 @@ public static function getInstance()

protected function getShareObj($abstract)
{
return isset($this->classes[$abstract]) ? $this->classes[$abstract] : null;
return $this->classes[$abstract] ?? null;
}


Expand All @@ -94,7 +93,7 @@ public function make($abstract, $parameters = [])
return $this->instances[$abstract];
}

$class = $this->binds[$abstract]["concert"];
$class = $this->binds[$abstract]['concert'];
return (empty($parameters)) ? $this->instance($abstract, $this->build($class)) : $this->instance($abstract, new $class(...$parameters));
}

Expand All @@ -114,7 +113,7 @@ public function has($abstract)
public function bind($instance, $abstract, $share = false)
{
//清理老数据
if (is_null($instance)) {
if ($instance === null) {
$concert = $abstract;
} else {
if (is_array($instance)) {
Expand All @@ -123,7 +122,7 @@ public function bind($instance, $abstract, $share = false)
$concert = $instance;
}
}
$this->binds[$abstract] = compact("concert", "share");
$this->binds[$abstract] = compact('concert', 'share');
$this->bindAlice(is_array($instance) ? $instance : [$instance], $abstract);
}

Expand All @@ -137,7 +136,7 @@ public function bindAlice(array $class, $abstract)

public function getAlice($abstract)
{
return isset($this->alice[$abstract]) ? $this->alice[$abstract] : null;
return $this->alice[$abstract] ?? null;
}


Expand All @@ -161,8 +160,9 @@ public function signal($abstract, $instance)
*/
public function instance($abstract, $instance, $share = false)
{
if ($share)
if ($share) {
$this->classes[$abstract] = $instance;
}

$this->instances[$abstract] = $instance;

Expand All @@ -174,17 +174,21 @@ public function instance($abstract, $instance, $share = false)

public function notInstantiable($concrete)
{
throw new \Exception("[$concrete] no Instanctiable", 3);
throw new \RuntimeException("[$concrete] no Instantiable", 3);
}

public function build($concrete)
{
$reflector = new \ReflectionClass($concrete);
try {
$reflector = new \ReflectionClass($concrete);
} catch (\ReflectionException $e) {
throw new \RuntimeException("reflection [$concrete] error");
}
if (!$reflector->isInstantiable()) {
return $this->notInstantiable($concrete);
}
$constructor = $reflector->getConstructor();
if (is_null($constructor)) {
if ($constructor === null) {
return new $concrete;
}
if ($reflector->isInstantiable()) {
Expand All @@ -203,7 +207,7 @@ public function build($concrete)
* @return array
* 解决依赖注入问题
*/
public function resolveDepends($params = [])
public function resolveDepends($params = []):array
{
// 判断参数类型
foreach ($params as $key => $param) {
Expand All @@ -221,7 +225,7 @@ public function resolveDepends($params = [])
$paramArr[] = $args;
}
}
return $paramArr;
return $paramArr ?? [];
}


Expand All @@ -240,7 +244,7 @@ public function call($instance, $method = null, $construct = null, array $param
} else {
$instance = $this->build($instance);
}
if (is_null($method)) {
if ($method === null) {
$this->instance($abstract, $instance, true);
unset($abstract);
return $instance;
Expand All @@ -249,7 +253,7 @@ public function call($instance, $method = null, $construct = null, array $param
}


public function flush()
public function flush():void
{
$this->classes = [];
$this->alice = [];
Expand All @@ -263,8 +267,9 @@ public function flush()
*/
public function offsetExists($offset)
{
if ($this->has($offset))
if ($this->has($offset)) {
return true;
}
return false;
}

Expand All @@ -282,20 +287,20 @@ public function offsetGet($offset)
* * @param offset
* * @param value
* */
public function offsetSet($offset, $value)
public function offsetSet($offset, $value):void
{
$this->classes[$offset] = $value;
}

/**
* @param mixed $offset
*/
public function offsetUnset($offset)
public function offsetUnset($offset):void
{
unset($this->binds[$offset], $this->instances[$offset]);
}

public function alice($name, $class)
public function alice($name, $class):bool
{
return class_alias($class, $name);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Time: 10:12
*/

namespace Blankphp\Provider\Contract;
namespace Blankphp\Contract;


use Blankphp\Application;
Expand Down
8 changes: 4 additions & 4 deletions src/blankphp/Database/Database.php
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Blankphp\Database\Traits\DBJoin;
use Blankphp\Exception\DataBaseTypeException;
use Blankphp\Facade\Log;
use Helpers\Str;
use BlankQwq\Helpers\Str;

class Database
{
Expand Down Expand Up @@ -245,9 +245,9 @@ public function __call($name, $arguments)
}

//将数据进行绑定,,Connect?
public function bindValues(array $values = [])
public function bindValues(array $values = []): void
{
if (is_null($this->PDOsmt)) {
if ($this->PDOsmt === null) {
throw new DataBaseTypeException('异常错误');
}
$i = 0;
Expand All @@ -269,7 +269,7 @@ public function bindValues(array $values = [])

public function bindCall(array $values)
{
if (is_null($this->PDOsmt)) {
if ($this->PDOsmt === null) {
throw new Exception('异常错误');
}
foreach ($values as $key => $value) {
Expand Down
2 changes: 1 addition & 1 deletion src/blankphp/Driver/DataBaseDriver.php
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct($name = "default", $option = [])
//后续操作
}

public function clearExpireData($max_time)
public function clearExpireData()
{

}
Expand Down
6 changes: 4 additions & 2 deletions src/blankphp/Driver/Driver.php
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ abstract class Driver implements DriverContract, \SessionHandlerInterface
{
use SessionHandlerTrait, OtherHelpTrait;

abstract public function __construct($name = "default", $option = []);
public function __construct($name = 'default', $option = []){

}

public function parseValue($value)
{
Expand All @@ -23,7 +25,7 @@ public function valueParse($value)
return unserialize($value);
}

public function clearExpireData($maxlifetime)
public function clearExpireData($max_live_time)
{
return true;
}
Expand Down
14 changes: 14 additions & 0 deletions src/blankphp/Driver/DriverFactory.php
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php


namespace Blankphp\Driver;


use BlankPhp\Factory\FactoryBase;

class DriverFactory extends FactoryBase
{



}
Loading

AltStyle によって変換されたページ (->オリジナル) /