码迷,mamicode.com
首页 > 其他好文 > 详细

每天laravel-20160814| Container -17

时间:2016-05-25 11:26:01      阅读:110      评论:0      收藏:0      [点我收藏+]

标签:function   return   

   /**
    * Resolve all of the dependencies from the ReflectionParameters.
    *
    * @param  array  $parameters
    * @param  array  $primitives
    * @return array
    */
// Resolve all of the dependencies from the ReflectionParameters.
   protected function getDependencies(array $parameters, array $primitives = [])
   {// if you want resolve the Dependencies ,first you need get it
       $dependencies = [];// set a array dependencies

       foreach ($parameters as $parameter) {// loop the parameters as parameter
           $dependency = $parameter->getClass();// what ever get the Class name
        // may set the name about the parameter

           // If the class is null, it means the dependency is a string or some other
           // primitive type which we can not resolve since it is not a class and
           // we will just bomb out with an error since we have no-where to go.
           if (array_key_exists($parameter->name, $primitives)) {// if the name in the primitives
               $dependencies[] = $primitives[$parameter->name];// has the dependencies array
           } elseif (is_null($dependency)) {// if is null
               $dependencies[] = $this->resolveNonClass($parameter);// change the Non Class
           } else {
               $dependencies[] = $this->resolveClass($parameter);// resolveClass
           }
       }

       return $dependencies;// ever thing done ,return the result
   }


本文出自 “专注php” 博客,请务必保留此出处http://jingshanls.blog.51cto.com/3357095/1782861

每天laravel-20160814| Container -17

标签:function   return   

原文地址:http://jingshanls.blog.51cto.com/3357095/1782861

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!