@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | (new BaseRegister($this->app))->handle(); |
| 43 | 43 | |
| 44 | 44 | //we save the bootstrapper class in container. |
| 45 | - $this->app->register('bootstrapper',$this);
|
|
| 45 | + $this->app->register('bootstrapper', $this);
|
|
| 46 | 46 | |
| 47 | 47 | //call bootstrapper process |
| 48 | 48 | $this->callBootstrapperProcess(); |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | {
|
| 62 | 62 | //The boot method to be executed can be specified by the user. |
| 63 | 63 | //We use this method to know how to customize it. |
| 64 | - BootFireCallback::setBootFire([$this->app,$bootstrapper],function($boot){
|
|
| 64 | + BootFireCallback::setBootFire([$this->app, $bootstrapper], function($boot) {
|
|
| 65 | 65 | |
| 66 | 66 | //kernel boots run and service container |
| 67 | 67 | //makeBuild for service Container |
@@ -76,11 +76,11 @@ discard block |
||
| 76 | 76 | * @param null $maker |
| 77 | 77 | * @return mixed |
| 78 | 78 | */ |
| 79 | - public function bootFire($boot=null,$maker=null) |
|
| 79 | + public function bootFire($boot = null, $maker = null) |
|
| 80 | 80 | {
|
| 81 | 81 | // we can refer to this method |
| 82 | 82 | // because we can boot classes in the middleware or bootstrapper array. |
| 83 | - if(is_null($boot) && !is_null($maker)){
|
|
| 83 | + if (is_null($boot) && !is_null($maker)) {
|
|
| 84 | 84 | |
| 85 | 85 | // we create kernel bootstrapping objects |
| 86 | 86 | // that can be changed by you with the closure dispatcher method. |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | // the boot method to be executed can be specified by the user. |
| 94 | 94 | // we use this method to know how to customize it. |
| 95 | - return forward_static_call_array([array_pop($boot),self::LOADBOOTSTRAPPERS],[$boot]); |
|
| 95 | + return forward_static_call_array([array_pop($boot), self::LOADBOOTSTRAPPERS], [$boot]); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -103,14 +103,14 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | private function bootstrapper(...$params) |
| 105 | 105 | {
|
| 106 | - [$group,$booting,$onion] = $params; |
|
| 106 | + [$group, $booting, $onion] = $params; |
|
| 107 | 107 | |
| 108 | - if($onion){
|
|
| 108 | + if ($onion) {
|
|
| 109 | 109 | |
| 110 | 110 | // we will implement a special onion method here and |
| 111 | 111 | // pass our bootstraper classes through this method. |
| 112 | 112 | // Our goal here is to implement the middleware layer correctly. |
| 113 | - $this->app->resolve(MiddlewareKernelProvider::class)->onionBoot([$group,$booting],function() use($group){
|
|
| 113 | + $this->app->resolve(MiddlewareKernelProvider::class)->onionBoot([$group, $booting], function() use($group){
|
|
| 114 | 114 | $this->boot($group); |
| 115 | 115 | }); |
| 116 | 116 | |
@@ -127,18 +127,18 @@ discard block |
||
| 127 | 127 | * |
| 128 | 128 | * @param array $customBootstrapers |
| 129 | 129 | */ |
| 130 | - public function callBootstrapperProcess($customBootstrapers=[]) |
|
| 130 | + public function callBootstrapperProcess($customBootstrapers = []) |
|
| 131 | 131 | {
|
| 132 | 132 | // here we check that a special bootstrappers list will work and we identify the onion identifier. |
| 133 | 133 | // we are peeling onion class by classifying onion class. |
| 134 | 134 | $this->getBootstrappersStack($customBootstrapers); |
| 135 | 135 | |
| 136 | 136 | //We run the bootstrap list by callback with the object specified for the content respectively. |
| 137 | - foreach($this->stack['getBootstrappers'] as $bootstrapper){
|
|
| 137 | + foreach ($this->stack['getBootstrappers'] as $bootstrapper) {
|
|
| 138 | 138 | |
| 139 | 139 | // if the callback data is different from the application kernel, |
| 140 | 140 | // we will pass it to the pusher control for a special use. |
| 141 | - call_user_func_array([$this,'bootstrapper'],[$bootstrapper,$this,$this->stack['onionIdentifier']]); |
|
| 141 | + call_user_func_array([$this, 'bootstrapper'], [$bootstrapper, $this, $this->stack['onionIdentifier']]); |
|
| 142 | 142 | } |
| 143 | 143 | } |
| 144 | 144 | |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | private function peelings() |
| 165 | 165 | {
|
| 166 | 166 | //if there are peelings |
| 167 | - if(isset($this->app['peelings'])){
|
|
| 167 | + if (isset($this->app['peelings'])) {
|
|
| 168 | 168 | |
| 169 | 169 | // We send the peelings property to |
| 170 | 170 | // the bootstrapperPeelOnion class. |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * @param $app |
| 21 | 21 | * @param array $boot |
| 22 | 22 | */ |
| 23 | - public function __construct($app,$boot=array()) |
|
| 23 | + public function __construct($app, $boot = array()) |
|
| 24 | 24 | {
|
| 25 | 25 | parent::__construct($app); |
| 26 | 26 | |
@@ -35,21 +35,21 @@ discard block |
||
| 35 | 35 | * @param array $boots |
| 36 | 36 | * @param bool $defaultBoot |
| 37 | 37 | */ |
| 38 | - private function bootstrapper($boots=array(),$defaultBoot=true) |
|
| 38 | + private function bootstrapper($boots = array(), $defaultBoot = true) |
|
| 39 | 39 | {
|
| 40 | 40 | //boot loop make bind calling |
| 41 | - foreach ($boots as $bootstrapper){
|
|
| 41 | + foreach ($boots as $bootstrapper) {
|
|
| 42 | 42 | |
| 43 | 43 | // for the default boot, we overwrite the bootstrapper class's bootstrapper property |
| 44 | 44 | // and load it with the boot method. |
| 45 | - if($defaultBoot){
|
|
| 45 | + if ($defaultBoot) {
|
|
| 46 | 46 | $this->app->loadIfNotExistBoot([$bootstrapper]); |
| 47 | 47 | } |
| 48 | 48 | // we will use the classical method for classes |
| 49 | 49 | // that will not boot from the kernel. |
| 50 | - else{
|
|
| 51 | - if(Utils::isNamespaceExists($bootstrapper) |
|
| 52 | - && false===isset($this->app['resolve'][$bootstrapper])){
|
|
| 50 | + else {
|
|
| 51 | + if (Utils::isNamespaceExists($bootstrapper) |
|
| 52 | + && false===isset($this->app['resolve'][$bootstrapper])) {
|
|
| 53 | 53 | $this->app->resolve($bootstrapper)->boot(); |
| 54 | 54 | } |
| 55 | 55 | } |
@@ -65,8 +65,8 @@ discard block |
||
| 65 | 65 | private function customBootManifest(callable $callback) |
| 66 | 66 | {
|
| 67 | 67 | //we make custom boot |
| 68 | - if(isset($this->boot['custom'])){
|
|
| 69 | - return call_user_func_array($callback,[$this->boot['custom']]); |
|
| 68 | + if (isset($this->boot['custom'])) {
|
|
| 69 | + return call_user_func_array($callback, [$this->boot['custom']]); |
|
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | |
@@ -83,8 +83,8 @@ discard block |
||
| 83 | 83 | $defaultBoot = Collection::make($this->boot)->except('custom')->all();
|
| 84 | 84 | |
| 85 | 85 | //custom boot according to manifest bootManager |
| 86 | - $this->customBootManifest(function($boot){
|
|
| 87 | - $this->bootstrapper((array)$boot,false); |
|
| 86 | + $this->customBootManifest(function($boot) {
|
|
| 87 | + $this->bootstrapper((array)$boot, false); |
|
| 88 | 88 | }); |
| 89 | 89 | |
| 90 | 90 | // and as a result we now use |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | $this->isAvailableStore(); |
| 65 | 65 | |
| 66 | 66 | //global accessor handling |
| 67 | - $this->setGlobalAccessor(); |
|
| 67 | + $this->setGlobalAccessor(); |
|
| 68 | 68 | |
| 69 | 69 | // sets a user-defined error handler function |
| 70 | 70 | // this function can be used for defining your own way of handling errors during runtime, |
@@ -151,12 +151,12 @@ discard block |
||
| 151 | 151 | if(Utils::isNamespaceExists(RequestService::class)){
|
| 152 | 152 | |
| 153 | 153 | Request::setFactory(function(array $query = array(), |
| 154 | - array $request = array(), |
|
| 155 | - array $attributes = array(), |
|
| 156 | - array $cookies = array(), |
|
| 157 | - array $files = array(), |
|
| 158 | - array $server = array(), |
|
| 159 | - $content = null) |
|
| 154 | + array $request = array(), |
|
| 155 | + array $attributes = array(), |
|
| 156 | + array $cookies = array(), |
|
| 157 | + array $files = array(), |
|
| 158 | + array $server = array(), |
|
| 159 | + $content = null) |
|
| 160 | 160 | {
|
| 161 | 161 | return new RequestService($query, |
| 162 | 162 | $request, |
@@ -32,11 +32,11 @@ discard block |
||
| 32 | 32 | // if the store directory is available, |
| 33 | 33 | // then the application process continues. |
| 34 | 34 | // if not available, only the core is executed. |
| 35 | - if(file_exists(app()->path()->storeDir())){
|
|
| 36 | - $this->app->register('isAvailableStore',true);
|
|
| 35 | + if (file_exists(app()->path()->storeDir())) {
|
|
| 36 | + $this->app->register('isAvailableStore', true);
|
|
| 37 | 37 | } |
| 38 | - else{
|
|
| 39 | - $this->app->register('isAvailableStore',false);
|
|
| 38 | + else {
|
|
| 39 | + $this->app->register('isAvailableStore', false);
|
|
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | |
@@ -49,13 +49,13 @@ discard block |
||
| 49 | 49 | {
|
| 50 | 50 | //we can use this method to move an instance of the application class with the kernel object |
| 51 | 51 | //and easily resolve an encrypted instance of all the kernel variables in our helper class. |
| 52 | - ClassAliasGroup::setAlias(App::class,'application'); |
|
| 52 | + ClassAliasGroup::setAlias(App::class, 'application'); |
|
| 53 | 53 | |
| 54 | 54 | //set base instances |
| 55 | 55 | $this->setBaseInstances(); |
| 56 | 56 | |
| 57 | 57 | //we define the general application instance object. |
| 58 | - define('appInstance',(base64_encode(serialize($this))));
|
|
| 58 | + define('appInstance', (base64_encode(serialize($this))));
|
|
| 59 | 59 | |
| 60 | 60 | //main loader for application |
| 61 | 61 | $this->mainLoader(); |
@@ -70,8 +70,8 @@ discard block |
||
| 70 | 70 | // this function can be used for defining your own way of handling errors during runtime, |
| 71 | 71 | // for example in applications in which you need to do cleanup of data/files when a critical error happens, |
| 72 | 72 | // or when you need to trigger an error under certain conditions (using trigger_error()). |
| 73 | - if($this->app['isAvailableStore']){
|
|
| 74 | - $this->app->make('exception',function(){
|
|
| 73 | + if ($this->app['isAvailableStore']) {
|
|
| 74 | + $this->app->make('exception', function() {
|
|
| 75 | 75 | return ErrorProvider::class; |
| 76 | 76 | }); |
| 77 | 77 | } |
@@ -86,30 +86,30 @@ discard block |
||
| 86 | 86 | {
|
| 87 | 87 | // for revision records, |
| 88 | 88 | // the master key is assigned as revision. |
| 89 | - $this->app->register('revision',[]);
|
|
| 89 | + $this->app->register('revision', []);
|
|
| 90 | 90 | |
| 91 | 91 | //we're saving the directory where kernel files are running to the kernel object. |
| 92 | - $this->app->register('corePath',str_replace('Foundation','',__DIR__.''));
|
|
| 92 | + $this->app->register('corePath', str_replace('Foundation', '', __DIR__.''));
|
|
| 93 | 93 | |
| 94 | 94 | //For the application, we create the object that the register method, |
| 95 | 95 | // which is the container center, is connected to by the kernel object register method. |
| 96 | - $this->app->register('container',$this->app);
|
|
| 96 | + $this->app->register('container', $this->app);
|
|
| 97 | 97 | |
| 98 | 98 | // We are saving the application class to |
| 99 | 99 | // the container object for the appClass value. |
| 100 | - $this->app->register('appClass',new \application());
|
|
| 100 | + $this->app->register('appClass', new \application());
|
|
| 101 | 101 | |
| 102 | 102 | //set closure bind instance for application |
| 103 | - $this->app->register('appClosureInstance',ClosureDispatcher::bind(app()));
|
|
| 103 | + $this->app->register('appClosureInstance', ClosureDispatcher::bind(app()));
|
|
| 104 | 104 | |
| 105 | 105 | //set closure bind instance for bootLoader class |
| 106 | - $this->app->register('closureBootLoader',ClosureDispatcher::bind($this->app['bootLoader']));
|
|
| 106 | + $this->app->register('closureBootLoader', ClosureDispatcher::bind($this->app['bootLoader']));
|
|
| 107 | 107 | |
| 108 | 108 | //set register for macro |
| 109 | - $this->app->register('macro',$this->app->resolve(Macro::class));
|
|
| 109 | + $this->app->register('macro', $this->app->resolve(Macro::class));
|
|
| 110 | 110 | |
| 111 | 111 | //set register for macro |
| 112 | - $this->app->register('pipeline',new Pipeline());
|
|
| 112 | + $this->app->register('pipeline', new Pipeline());
|
|
| 113 | 113 | |
| 114 | 114 | } |
| 115 | 115 | |
@@ -123,10 +123,10 @@ discard block |
||
| 123 | 123 | //register as instance application object |
| 124 | 124 | // and container instance resolve |
| 125 | 125 | //set core instance value |
| 126 | - $this->app->instance('container',$this->app->singleton());
|
|
| 127 | - $this->app->instance('bootLoader',$this->app->resolve(BootLoader::class));
|
|
| 128 | - $this->app->instance('containerInstanceResolve',ContainerInstanceResolver::class);
|
|
| 129 | - $this->app->instance('reflection',ReflectionProcess::class);
|
|
| 126 | + $this->app->instance('container', $this->app->singleton());
|
|
| 127 | + $this->app->instance('bootLoader', $this->app->resolve(BootLoader::class));
|
|
| 128 | + $this->app->instance('containerInstanceResolve', ContainerInstanceResolver::class);
|
|
| 129 | + $this->app->instance('reflection', ReflectionProcess::class);
|
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /** |
@@ -138,17 +138,17 @@ discard block |
||
| 138 | 138 | private function setGlobalAccessor() |
| 139 | 139 | {
|
| 140 | 140 | //get response success and status |
| 141 | - $this->app->register('instanceController',null);
|
|
| 142 | - $this->app->register('responseSuccess',true);
|
|
| 143 | - $this->app->register('responseStatus',200);
|
|
| 144 | - $this->app->register('responseType','json');
|
|
| 141 | + $this->app->register('instanceController', null);
|
|
| 142 | + $this->app->register('responseSuccess', true);
|
|
| 143 | + $this->app->register('responseStatus', 200);
|
|
| 144 | + $this->app->register('responseType', 'json');
|
|
| 145 | 145 | |
| 146 | 146 | //we first load the response class as a singleton object to allow you to send output anywhere |
| 147 | - $this->app->register('out',$this->app->resolve(ResponseProvider::class));
|
|
| 147 | + $this->app->register('out', $this->app->resolve(ResponseProvider::class));
|
|
| 148 | 148 | |
| 149 | 149 | //The HttpFoundation component defines an object-oriented layer for the HTTP specification. |
| 150 | 150 | //The HttpFoundation component replaces these default PHP global variables and functions by an object-oriented layer |
| 151 | - if(Utils::isNamespaceExists(RequestService::class)){
|
|
| 151 | + if (Utils::isNamespaceExists(RequestService::class)) {
|
|
| 152 | 152 | |
| 153 | 153 | Request::setFactory(function(array $query = array(), |
| 154 | 154 | array $request = array(), |
@@ -170,16 +170,16 @@ discard block |
||
| 170 | 170 | |
| 171 | 171 | |
| 172 | 172 | //After registering the symfony request method, we also save the get and post methods for user convenience. |
| 173 | - $this->app->register('request',Request::createFromGlobals());
|
|
| 174 | - $this->app->register('get',core()->request->query->all());
|
|
| 175 | - $this->app->register('post',core()->request->request->all());
|
|
| 173 | + $this->app->register('request', Request::createFromGlobals());
|
|
| 174 | + $this->app->register('get', core()->request->query->all());
|
|
| 175 | + $this->app->register('post', core()->request->request->all());
|
|
| 176 | 176 | |
| 177 | 177 | //We determine with the kernel object which HTTP method the requested from the client |
| 178 | - $this->app->register('httpMethod',ucfirst(strtolower(core()->request->getRealMethod())));
|
|
| 178 | + $this->app->register('httpMethod', ucfirst(strtolower(core()->request->getRealMethod())));
|
|
| 179 | 179 | |
| 180 | - define('httpMethod',strtoupper(core()->httpMethod));
|
|
| 180 | + define('httpMethod', strtoupper(core()->httpMethod));
|
|
| 181 | 181 | |
| 182 | - $this->app->register('fileSystem',new FileProcess());
|
|
| 182 | + $this->app->register('fileSystem', new FileProcess());
|
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | } |
| 186 | 186 | \ No newline at end of file |
@@ -34,8 +34,7 @@ |
||
| 34 | 34 | // if not available, only the core is executed. |
| 35 | 35 | if(file_exists(app()->path()->storeDir())){
|
| 36 | 36 | $this->app->register('isAvailableStore',true);
|
| 37 | - } |
|
| 38 | - else{
|
|
| 37 | + } else{
|
|
| 39 | 38 | $this->app->register('isAvailableStore',false);
|
| 40 | 39 | } |
| 41 | 40 | } |
@@ -12,12 +12,12 @@ discard block |
||
| 12 | 12 | * @param $callback |
| 13 | 13 | * @return void |
| 14 | 14 | */ |
| 15 | - public function consoleShared($object,$callback) |
|
| 15 | + public function consoleShared($object, $callback) |
|
| 16 | 16 | {
|
| 17 | 17 | //The console share is evaluated as a true variable to be assigned as the 3rd parameter in the classes to be bound. |
| 18 | 18 | //The work to be done here is to bind the classes to be included in the console share privately. |
| 19 | - if($this->app->console()){
|
|
| 20 | - $this->app->register('consoleShared',$object,$this->getConcrete($callback));
|
|
| 19 | + if ($this->app->console()) {
|
|
| 20 | + $this->app->register('consoleShared', $object, $this->getConcrete($callback));
|
|
| 21 | 21 | } |
| 22 | 22 | } |
| 23 | 23 | |
@@ -27,8 +27,8 @@ discard block |
||
| 27 | 27 | public function container() |
| 28 | 28 | {
|
| 29 | 29 | //We are initializing the array property for the service container object. |
| 30 | - if(!isset($this->app['serviceContainer'])){
|
|
| 31 | - $this->app->register('serviceContainer',[]);
|
|
| 30 | + if (!isset($this->app['serviceContainer'])) {
|
|
| 31 | + $this->app->register('serviceContainer', []);
|
|
| 32 | 32 | } |
| 33 | 33 | } |
| 34 | 34 | |
@@ -48,22 +48,22 @@ discard block |
||
| 48 | 48 | * @param $concrete |
| 49 | 49 | * @return void |
| 50 | 50 | */ |
| 51 | - private function setKernel($object,$concrete) |
|
| 51 | + private function setKernel($object, $concrete) |
|
| 52 | 52 | {
|
| 53 | 53 | //We check that the concrete object |
| 54 | 54 | //is an object that can be retrieved. |
| 55 | - if(!isset($this->app[$object]) && class_exists($concrete)){
|
|
| 55 | + if (!isset($this->app[$object]) && class_exists($concrete)) {
|
|
| 56 | 56 | |
| 57 | 57 | //get concrete instance |
| 58 | 58 | $concreteInstance = $this->app->resolve($concrete); |
| 59 | 59 | |
| 60 | 60 | //the value corresponding to the bind value for the global object is assigned and |
| 61 | 61 | //the resolve method is called for the dependency injection. |
| 62 | - $this->app->register($object,$concreteInstance); |
|
| 62 | + $this->app->register($object, $concreteInstance); |
|
| 63 | 63 | |
| 64 | 64 | // this method is executed if the concrete instance contains the handle method. |
| 65 | 65 | // if no handle method is included, the concrete instance is returned directly. |
| 66 | - $registerObjectInstance = (method_exists($concreteInstance,'handle')) |
|
| 66 | + $registerObjectInstance = (method_exists($concreteInstance, 'handle')) |
|
| 67 | 67 | ? $concreteInstance->handle() |
| 68 | 68 | : $concreteInstance; |
| 69 | 69 | |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | * @param null $value |
| 77 | 77 | * @return void |
| 78 | 78 | */ |
| 79 | - public function setKernelObject($object,$concrete,$value=null) |
|
| 79 | + public function setKernelObject($object, $concrete, $value = null) |
|
| 80 | 80 | {
|
| 81 | 81 | //if a pre loader class wants to have before kernel values, |
| 82 | 82 | //it must return a callback to the bind method |
@@ -84,22 +84,22 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | //the value is directly assigned to the kernel object. |
| 86 | 86 | //The value is moved throughout the application in the kernel of the application object. |
| 87 | - if($value===null){
|
|
| 88 | - $this->setKernel($object,$concrete); |
|
| 87 | + if ($value===null) {
|
|
| 88 | + $this->setKernel($object, $concrete); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | //The service container value is moved differently from the value directly assigned to the kernel object. |
| 92 | 92 | //The application container is booted directly with the service container custom class |
| 93 | 93 | //in the version section of the your application. |
| 94 | - if($value==="serviceContainer"){
|
|
| 95 | - $this->setServiceContainer($object,$concrete); |
|
| 94 | + if ($value==="serviceContainer") {
|
|
| 95 | + $this->setServiceContainer($object, $concrete); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | // we will resolve the value of concrete according to whether it is an object. |
| 99 | 99 | $detectorBindings = (is_object($concrete)) ? $concrete : Utils::resolverClass($concrete); |
| 100 | 100 | |
| 101 | 101 | //we register the bound object to the kernel bindings property. |
| 102 | - $this->app->register('bindings',$object,$detectorBindings);
|
|
| 102 | + $this->app->register('bindings', $object, $detectorBindings);
|
|
| 103 | 103 | |
| 104 | 104 | } |
| 105 | 105 | |
@@ -108,17 +108,17 @@ discard block |
||
| 108 | 108 | * @param $concrete |
| 109 | 109 | * @return void |
| 110 | 110 | */ |
| 111 | - private function setServiceContainer($object,$concrete) |
|
| 111 | + private function setServiceContainer($object, $concrete) |
|
| 112 | 112 | {
|
| 113 | 113 | //We check that the concrete object |
| 114 | 114 | //is an object that can be retrieved. |
| 115 | - if(isset($this->app['serviceContainer']) && !isset($this->app['serviceContainer'][$object])){
|
|
| 115 | + if (isset($this->app['serviceContainer']) && !isset($this->app['serviceContainer'][$object])) {
|
|
| 116 | 116 | |
| 117 | 117 | //the value corresponding to the bind value for the global object is assigned and |
| 118 | 118 | //the resolve method is called for the dependency method. |
| 119 | - $this->app->register('serviceContainer',$object,$concrete);
|
|
| 119 | + $this->app->register('serviceContainer', $object, $concrete);
|
|
| 120 | 120 | } |
| 121 | - else{
|
|
| 121 | + else {
|
|
| 122 | 122 | |
| 123 | 123 | // the service container objects are saved only once. |
| 124 | 124 | // Overflow exception is thrown on multiple records. |
@@ -117,8 +117,7 @@ |
||
| 117 | 117 | //the value corresponding to the bind value for the global object is assigned and |
| 118 | 118 | //the resolve method is called for the dependency method. |
| 119 | 119 | $this->app->register('serviceContainer',$object,$concrete);
|
| 120 | - } |
|
| 121 | - else{
|
|
| 120 | + } else{
|
|
| 122 | 121 | |
| 123 | 122 | // the service container objects are saved only once. |
| 124 | 123 | // Overflow exception is thrown on multiple records. |
@@ -18,21 +18,21 @@ discard block |
||
| 18 | 18 | * |
| 19 | 19 | * @throws \ReflectionException |
| 20 | 20 | */ |
| 21 | - public function call($class,$param,callable $callback) |
|
| 21 | + public function call($class, $param, callable $callback) |
|
| 22 | 22 | {
|
| 23 | 23 | // We use the reflection class to solve |
| 24 | 24 | // the parameters of the class's methods. |
| 25 | - $param = $this->reflectionMethodParameters($class,$param); |
|
| 25 | + $param = $this->reflectionMethodParameters($class, $param); |
|
| 26 | 26 | |
| 27 | 27 | // the results of a number of processes will be given |
| 28 | 28 | // before the container pipeline method is given. |
| 29 | 29 | return $this->app->resolve(ContainerPipelineResolve::class)->handle( |
| 30 | - function() use($class,$param,$callback) |
|
| 30 | + function() use($class, $param, $callback) |
|
| 31 | 31 | {
|
| 32 | 32 | // as a result |
| 33 | 33 | // we return the resolved class to the callback class |
| 34 | - $params = (object)['class'=>$class,'param'=>$param]; |
|
| 35 | - return call_user_func_array($callback,[$params]); |
|
| 34 | + $params = (object)['class'=>$class, 'param'=>$param]; |
|
| 35 | + return call_user_func_array($callback, [$params]); |
|
| 36 | 36 | }); |
| 37 | 37 | |
| 38 | 38 | } |
@@ -44,12 +44,12 @@ discard block |
||
| 44 | 44 | * @param $parameter |
| 45 | 45 | * @return array |
| 46 | 46 | */ |
| 47 | - private function checkParameterForContainer($containers,$parameter) |
|
| 47 | + private function checkParameterForContainer($containers, $parameter) |
|
| 48 | 48 | {
|
| 49 | 49 | // if the parameter is an object and |
| 50 | 50 | // this object is a service container object |
| 51 | 51 | // then the parameter will bind. |
| 52 | - if($parameter->getType()!==null && isset($containers[$parameter->getType()->getName()])){
|
|
| 52 | + if ($parameter->getType()!==null && isset($containers[$parameter->getType()->getName()])) {
|
|
| 53 | 53 | |
| 54 | 54 | // Unpack the container object and |
| 55 | 55 | // bind it to the param variable. |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | return [$parameterName=>$parameterResolve]; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - if($parameter->getType()!== NULL && Utils::isNamespaceExists($parameter->getType()->getName())){
|
|
| 71 | + if ($parameter->getType()!==NULL && Utils::isNamespaceExists($parameter->getType()->getName())) {
|
|
| 72 | 72 | |
| 73 | 73 | // Unpack the container object and |
| 74 | 74 | // bind it to the param variable. |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | private function getReflectionMethod($class) |
| 93 | 93 | {
|
| 94 | - [$class,$method] = [$class[0],$class[1]]; |
|
| 94 | + [$class, $method] = [$class[0], $class[1]]; |
|
| 95 | 95 | |
| 96 | 96 | return $this->app['reflection']($class)->reflectionMethodParams($method); |
| 97 | 97 | } |
@@ -105,12 +105,12 @@ discard block |
||
| 105 | 105 | * |
| 106 | 106 | * @throws \ReflectionException |
| 107 | 107 | */ |
| 108 | - private function reflectionMethodParameters($class,$param) |
|
| 108 | + private function reflectionMethodParameters($class, $param) |
|
| 109 | 109 | {
|
| 110 | 110 | $containers = []; |
| 111 | 111 | |
| 112 | 112 | //get service container objects. |
| 113 | - if(isset($this->app['serviceContainer'])){
|
|
| 113 | + if (isset($this->app['serviceContainer'])) {
|
|
| 114 | 114 | $containers = $this->app['serviceContainer']; |
| 115 | 115 | } |
| 116 | 116 | |
@@ -122,22 +122,22 @@ discard block |
||
| 122 | 122 | // we provide the user with the container method document and take action. |
| 123 | 123 | // thus, we help the methods to have a cleaner code structure. |
| 124 | 124 | $this->app->resolve(ContainerMethodDocumentResolver::class, |
| 125 | - ['document'=>$reflection->document,'class'=>$class]); |
|
| 125 | + ['document'=>$reflection->document, 'class'=>$class]); |
|
| 126 | 126 | |
| 127 | 127 | // we group the parameters into type and |
| 128 | 128 | // name and bind them with the necessary logic. |
| 129 | - foreach ($parameters as $parameter){
|
|
| 129 | + foreach ($parameters as $parameter) {
|
|
| 130 | 130 | |
| 131 | 131 | // if the parameter is an object and |
| 132 | 132 | // this object is a service container object |
| 133 | 133 | // then the parameter will bind. |
| 134 | - $checkParameterForContainer = $this->checkParameterForContainer($containers,$parameter); |
|
| 135 | - $paramMerge = array_merge($param,$checkParameterForContainer); |
|
| 134 | + $checkParameterForContainer = $this->checkParameterForContainer($containers, $parameter); |
|
| 135 | + $paramMerge = array_merge($param, $checkParameterForContainer); |
|
| 136 | 136 | |
| 137 | 137 | // we do some useful logic bind for user benefit. |
| 138 | - $param = app()->resolve(GraceContainer::class,[ |
|
| 138 | + $param = app()->resolve(GraceContainer::class, [ |
|
| 139 | 139 | 'reflection' => $reflection->reflection |
| 140 | - ])->graceContainerBuilder($parameter,$paramMerge); |
|
| 140 | + ])->graceContainerBuilder($parameter, $paramMerge); |
|
| 141 | 141 | |
| 142 | 142 | } |
| 143 | 143 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | /** |
| 12 | 12 | * @var array $nameContainers |
| 13 | 13 | */ |
| 14 | - protected $nameContainers=[ |
|
| 14 | + protected $nameContainers = [ |
|
| 15 | 15 | 'route'=>Route::class |
| 16 | 16 | ]; |
| 17 | 17 | |
@@ -44,24 +44,24 @@ discard block |
||
| 44 | 44 | * @param $param |
| 45 | 45 | * @return array |
| 46 | 46 | */ |
| 47 | - protected function getNameContainers($parameter,$param) |
|
| 47 | + protected function getNameContainers($parameter, $param) |
|
| 48 | 48 | {
|
| 49 | 49 | // If the parameter contains a route variable. |
| 50 | 50 | // We do a custom bind for the route |
| 51 | - if($this->checkNameContainer($parameter)){
|
|
| 51 | + if ($this->checkNameContainer($parameter)) {
|
|
| 52 | 52 | |
| 53 | 53 | // we do the name control for the container here, |
| 54 | 54 | // and if we have the name container we are checking, we make a handle make bind. |
| 55 | - $nameContainers=$this->nameContainers[$parameter->getName()]; |
|
| 56 | - return app()->resolve($nameContainers,[ |
|
| 55 | + $nameContainers = $this->nameContainers[$parameter->getName()]; |
|
| 56 | + return app()->resolve($nameContainers, [ |
|
| 57 | 57 | 'reflection' => $this->reflection |
| 58 | - ])->resolveContainer($parameter->getDefaultValue(),$param); |
|
| 58 | + ])->resolveContainer($parameter->getDefaultValue(), $param); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | // In particular, name container values can be specified and |
| 62 | 62 | // they are injected directly into the methods contextually. |
| 63 | - if(isset(core()->serviceContainer[$parameter->getName()])){
|
|
| 64 | - return app()->resolve(SpecialNameContainer::class)->resolveContainer($parameter,$param); |
|
| 63 | + if (isset(core()->serviceContainer[$parameter->getName()])) {
|
|
| 64 | + return app()->resolve(SpecialNameContainer::class)->resolveContainer($parameter, $param); |
|
| 65 | 65 | |
| 66 | 66 | } |
| 67 | 67 | |
@@ -73,17 +73,17 @@ discard block |
||
| 73 | 73 | * @param $param |
| 74 | 74 | * @return mixed |
| 75 | 75 | */ |
| 76 | - public function graceContainerBuilder($parameter,$param) |
|
| 76 | + public function graceContainerBuilder($parameter, $param) |
|
| 77 | 77 | {
|
| 78 | 78 | // if the parameter is an object |
| 79 | 79 | // but not a container object. |
| 80 | 80 | // we do some useful logic bind for user benefit. |
| 81 | - if($parameter->getType()!==null){
|
|
| 82 | - return app()->resolve(RepositoryContainer::class)->handle($parameter,$param); |
|
| 81 | + if ($parameter->getType()!==null) {
|
|
| 82 | + return app()->resolve(RepositoryContainer::class)->handle($parameter, $param); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | // In particular, name container values can be specified and |
| 86 | 86 | // they are injected directly into the methods contextually. |
| 87 | - return $this->getNameContainers($parameter,$param); |
|
| 87 | + return $this->getNameContainers($parameter, $param); |
|
| 88 | 88 | } |
| 89 | 89 | } |
| 90 | 90 | \ No newline at end of file |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * ContainerMethodDocumentResolver constructor. |
| 22 | 22 | * @param $app |
| 23 | 23 | */ |
| 24 | - public function __construct($app,$document,$class=array()) |
|
| 24 | + public function __construct($app, $document, $class = array()) |
|
| 25 | 25 | {
|
| 26 | 26 | parent::__construct($app); |
| 27 | 27 | |
@@ -44,25 +44,25 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | // if you have information about cache in |
| 46 | 46 | // the document section of the method, the cache process is executed. |
| 47 | - if(is_string($this->document) && preg_match('#@cache\((.*?)\)\r\n#is',$this->document,$cache)){
|
|
| 47 | + if (is_string($this->document) && preg_match('#@cache\((.*?)\)\r\n#is', $this->document, $cache)) {
|
|
| 48 | 48 | |
| 49 | 49 | // if the cache information |
| 50 | 50 | // with regular expression does not contain null data. |
| 51 | - if($cache!==null && isset($cache[1])){
|
|
| 51 | + if ($cache!==null && isset($cache[1])) {
|
|
| 52 | 52 | |
| 53 | 53 | //as static we inject the name value into the cache data. |
| 54 | 54 | $cacheData = ['cache'=>['name'=>Utils::encryptArrayData($this->class)]]; |
| 55 | 55 | |
| 56 | 56 | //cache data with the help of foreach data are transferred into the cache. |
| 57 | - foreach(array_filter(explode(" ",$cache[1]),'strlen') as $item){
|
|
| 57 | + foreach (array_filter(explode(" ", $cache[1]), 'strlen') as $item) {
|
|
| 58 | 58 | |
| 59 | - $items = explode("=",$item);
|
|
| 59 | + $items = explode("=", $item);
|
|
| 60 | 60 | $cacheData['cache'][$items[0]] = $items[1]; |
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | //we save the data stored in the cacheData variable as methodCache. |
| 66 | - $this->app->register('containerReflection','methodCache',$cacheData);
|
|
| 66 | + $this->app->register('containerReflection', 'methodCache', $cacheData);
|
|
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | \ No newline at end of file |
@@ -23,10 +23,10 @@ discard block |
||
| 23 | 23 | * @throws \DI\DependencyException |
| 24 | 24 | * @throws \DI\NotFoundException |
| 25 | 25 | */ |
| 26 | - public static function resolve($class=null) |
|
| 26 | + public static function resolve($class = null) |
|
| 27 | 27 | {
|
| 28 | 28 | //class resolve |
| 29 | - if($class!==null){
|
|
| 29 | + if ($class!==null) {
|
|
| 30 | 30 | $container = self::callBuild(); |
| 31 | 31 | return $container->get($class); |
| 32 | 32 | } |
@@ -40,12 +40,12 @@ discard block |
||
| 40 | 40 | * @throws \DI\DependencyException |
| 41 | 41 | * @throws \DI\NotFoundException |
| 42 | 42 | */ |
| 43 | - public static function make($class=null, $param=array()) |
|
| 43 | + public static function make($class = null, $param = array()) |
|
| 44 | 44 | {
|
| 45 | - if($class!==null){
|
|
| 45 | + if ($class!==null) {
|
|
| 46 | 46 | |
| 47 | 47 | $container = self::callBuild(); |
| 48 | - return $container->make($class,$param); |
|
| 48 | + return $container->make($class, $param); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | return null; |
@@ -57,9 +57,9 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | * @throws \DI\DependencyException |
| 59 | 59 | */ |
| 60 | - public static function injectOnBind($class=null) |
|
| 60 | + public static function injectOnBind($class = null) |
|
| 61 | 61 | {
|
| 62 | - if($class!==null){
|
|
| 62 | + if ($class!==null) {
|
|
| 63 | 63 | |
| 64 | 64 | $container = self::callBuild(); |
| 65 | 65 | return $container->injectOn($class); |
@@ -73,10 +73,10 @@ discard block |
||
| 73 | 73 | * @param array $param |
| 74 | 74 | * @return mixed |
| 75 | 75 | */ |
| 76 | - public static function callBind($class=null, $param=array()) |
|
| 76 | + public static function callBind($class = null, $param = array()) |
|
| 77 | 77 | {
|
| 78 | - return (app()->resolve(ContainerResolve::class))->call($class,$param,function($call){
|
|
| 79 | - return self::callBuild()->call($call->class,$call->param); |
|
| 78 | + return (app()->resolve(ContainerResolve::class))->call($class, $param, function($call) {
|
|
| 79 | + return self::callBuild()->call($call->class, $call->param); |
|
| 80 | 80 | }); |
| 81 | 81 | } |
| 82 | 82 | } |
| 83 | 83 | \ No newline at end of file |
@@ -9,23 +9,23 @@ |
||
| 9 | 9 | * @param $param |
| 10 | 10 | * @return mixed |
| 11 | 11 | */ |
| 12 | - public function handle($parameter,$param) |
|
| 12 | + public function handle($parameter, $param) |
|
| 13 | 13 | {
|
| 14 | 14 | // We will use a custom bind for the repository classes |
| 15 | 15 | // and bind the repository contract with the repository adapter class. |
| 16 | 16 | $parameterName = $parameter->getType()->getName(); |
| 17 | 17 | $repository = app()->namespace()->repository(); |
| 18 | 18 | |
| 19 | - $parameterNameWord = str_replace('\\','',$parameterName);
|
|
| 20 | - $repositoryWord = str_replace('\\','',$repository);
|
|
| 19 | + $parameterNameWord = str_replace('\\', '', $parameterName);
|
|
| 20 | + $repositoryWord = str_replace('\\', '', $repository);
|
|
| 21 | 21 | |
| 22 | 22 | |
| 23 | 23 | // if the submitted contract matches the repository class. |
| 24 | - if(preg_match('@'.$repositoryWord.'@is',$parameterNameWord)){
|
|
| 24 | + if (preg_match('@'.$repositoryWord.'@is', $parameterNameWord)) {
|
|
| 25 | 25 | |
| 26 | 26 | //we bind the contract as an adapter |
| 27 | - $repositoryName = str_replace('Contract','',$parameter->getName());
|
|
| 28 | - $getRepositoryAdapter = \application::repository($repositoryName,true); |
|
| 27 | + $repositoryName = str_replace('Contract', '', $parameter->getName());
|
|
| 28 | + $getRepositoryAdapter = \application::repository($repositoryName, true); |
|
| 29 | 29 | |
| 30 | 30 | $param[$parameter->getName()] = app()->resolve($getRepositoryAdapter)->adapter(); |
| 31 | 31 | } |