@param array  $args
@param array  $conf
@param string $confHash

@return Model
778512
public static function getInstance(array $args, array $conf, string $confHash) {
        @list($modelName) = $args;
        $namespace = $conf['namespace'] ?? static::$_conf['namespace'];
        $className = "\\{$namespace}\\" . Toolkit::toCamelCase($modelName, true);
        /** @var Model $model */
        $model = class_exists($className) ? new $className($modelName) : new Model($modelName);
        $model->saveConf($conf, $confHash);
        $model->init();

        return $model;
    }
880963
public function evalSha($sha1, $keys = [], $args = []) {
        \trigger_error("'evalSha' is deprecated. Please use 'eval', which automatically attempts to use 'evalSha'.");

        return $this->send(array_merge(['evalsha', $sha1, \count((array) $keys)], (array) $keys, (array) $args));
    }
1146934
protected function _makeRequest($args = array()) {
        $date = date(DATE_RFC1123);
        $sig  = $this->_createSignature($date);
        $amznAuthHeader = 'AWS3-HTTPS '.
                            'AWSAccessKeyId='.$this->_accessKey.
                            ', Algorithm=Hmac'.strtoupper(self::SIGNATURE_HASH_METHOD).
                            ', Signature='.$sig;

        $client = $this->getHttpClient()->resetParameters();
        $endpoint = sprintf(self::ENDPOINT, $this->_region);
        $client->setUri($endpoint);
        $client->setHeaders(array(
            'Date' => $date,
            'X-Amzn-Authorization' => $amznAuthHeader
        ));

        // required parameters for each request
        $args['Signature'] = $sig;
        $args['SignatureMethod'] = 'Hmac'.self::SIGNATURE_HASH_METHOD;
        $args['SignatureVersion'] = 2;
        $args['Version'] = self::API_VERSION;

        $client->setParameterPost($args);
        $response = $client->request(Zend_Http_Client::POST);

        if ($response->getStatus() !== 200) {
            $this->throwException($response->getBody());
        }
        return $response->getBody();
    }
701135
public function command(array $data, $options = [], &$hash = null)
    {
        try {
            $cursor = new \MongoCommandCursor($this->connection, $this->name, $data);
            $cursor->setReadPreference($this->getReadPreference());

            return iterator_to_array($cursor)[0];
        } catch (\MongoDB\Driver\Exception\Exception $e) {
            return ExceptionConverter::toResultArray($e);
        }
    }
550067
protected function fill(array $args): AbstractEdge
    {
        if( count($this->fields)<=0 ) {
            return $this;
        }
        $methods = array_keys($this->fields);
        $args_count = count($args);
        $fields_count = count($this->fields);
        $n = 0;
        while($n<$args_count) {
            $key = sprintf("set%s", $methods[$n]);
            $this->$key($args[$n++]);
        }
        for($n=$args_count; $n<$fields_count; $n++) {
            $method = $methods[$n];
            if(
                isset($this->fields[$method]["directives"]["now"])
                &&
                $this->fields[$method]["directives"]["now"]==true
            ) {
                    $key = sprintf("set%s", $method);
                    $this->$key(time());
            }
            elseif(
                isset($this->fields[$method]["directives"]["default"])
                &&
                $this->fields[$method]["directives"]["default"]!="|_~_~NO!-!VALUE!-!SET~_~_|" 
            ) {
                $key = sprintf("set%s", $method);
                $this->$key($this->fields[$method]["directives"]["default"]);
            }
        }
        return $this;
    }
1080408
private function prepareMethodParameters(\ReflectionMethod $refMethod, array $args, $removeUnknownArguments = true): array
    {
        $normalizedArguments = $this->normalizeArguments($args);
        if (!$removeUnknownArguments) {
            $normalizedArguments = array_merge($args, $normalizedArguments);
        }
        $normalizedArguments['args'] = $normalizedArguments;
        $indexedArguments = $this->resolveMethodArguments($refMethod, $normalizedArguments);
        ksort($indexedArguments);

        return $indexedArguments;
    }
914777
static public function factory($configs)
    {
        $config = self::_parseConfig($config);
        $config = array_merge(array('modelClass' => null, 'columnMap' => null), $config);
        return new self($config['modelClass'], $config['columnMap']);
    }
1189977
public function mergeArgsAndParams(array $args, array $params = null)
    {

        if ($params) {
            foreach ($args as &$arg) {
                if (is_array($arg)) {
                    foreach ($params as &$param) {
                        if (is_array($param)) {
                            $arg = $param;
                            unset($param);
                            break;
                        }
                    }
                }
            }
        }

        if (is_array($params)) {
            return array_merge($args, $params);
        }

        return $args;
    }
838757
protected function parseLinkConf(array $conf)
    {
        $uid  = null;
        $type = null;

        // Check link type
        switch ($conf['finalTagParts']['TYPE']) {
            // ##############
            // Page URL
            // ##############
            case 'page':
                if (is_numeric($conf['conf']['parameter'])) {
                    $uid = $conf['conf']['parameter'];
                }

                $type = SitemapUtility::SITEMAP_TYPE_PAGE;
                break;

            // ##############
            // File URL
            // ##############
            case 'file':
                $fileUrl = $conf['finalTagParts']['url'];

                if ($this->checkIfFileIsWhitelisted($fileUrl)) {
                    // File will be registered from the root page
                    // to prevent duplicate urls
                    $uid  = GeneralUtility::getRootPid();
                    $type = SitemapUtility::SITEMAP_TYPE_FILE;
                }
                break;
        }

        return array($uid, $type);
    }
943019
public function init($conf = array())
    {
        defined('DS') || define('DS', DIRECTORY_SEPARATOR);

        $app = $this;

        $this['logger'] = null;

        $this['config'] = function() use ($conf, $app) {
            $config = new Config();
            $config->load($conf);

            if (! $config->exists('phpalchemy.root_dir')) {
                $config->set('phpalchemy.root_dir', realpath(__DIR__.'/../'));
            }

            if (! empty($app->appDir)) {
                $config->set('app.root_dir', $app->getAppDir());
            }

            return $config;
        };

        // load configuration ini files
        $this->loadAppConfigurationFiles();

        // apply configurated php settings
        $this->applyPhpSettings();

        $this['autoloader'] = function() {
            return new ClassLoader();
        };

        $this['yaml'] = function () {
            return new Yaml();
        };

        $this['annotation'] = function () use ($app) {
            return new NotojReader();
            //return new Annotations($app['config']);
        };

        $this['mapper'] = function () use ($app) {
            $config = $app['config'];
            $routesDir = $config->get('app.root_dir') . DS .'config' . DS;

            if (file_exists($routesDir . 'routes.php')) {
                $mapper = include $routesDir . 'routes.php';
            } elseif (file_exists($routesDir . 'routes.yaml')) {
                $mapper = new Mapper($app['yaml']);
                $mapper->setCacheDir($config->get('app.cache_dir'));
                $mapper->loadFrom($routesDir . 'routes.yaml');
            } else {
                throw new \Exception(
                    "Application Error: No routes found for this app.\n" .
                    "You need create & configure 'config/routes.yaml'"
                );
            }

            return $mapper;
        };

        //TODO $this['exception_handler'] = $this->share(function () {
        //     return new ExceptionHandler();
        // });

        $this['dispatcher'] = function () use ($app) {
            $dispatcher = new EventDispatcher();
            $dispatcher->addSubscriber($app);

            // subscribing events
            $dispatcher->addSubscriber(new EventListener\ResponseListener($app['config']->get('templating.charset')));
            //TODO $dispatcher->addSubscriber(new LocaleListener($app['locale'], $urlMatcher));

            return $dispatcher;
        };

        $this['resolver'] = function () use ($app) {
            return new ControllerResolver($app, $app['logger']);
        };

        $this['ui_reader_factory'] = function () use ($app) {
            return new ReaderFactory();
        };

        $this['ui_parser'] = function () use ($app) {
            return new Parser();
        };

        /** @var \Alchemy\Component\UI\Engine */
        $this['ui_engine'] = function () use ($app) {
            return new Engine(
                $app['ui_reader_factory'],
                $app['ui_parser']
            );
        };

        $this['assetsHandler'] = function () use ($app) {
            return new WebAssets\Bundle();
        };

        /** @var \Alchemy\Kernel\Kernel */
        $this['kernel'] = function () use ($app) {
            return new Kernel(
                $app['dispatcher'],
                $app['mapper'],
                $app['resolver'],
                $app['config'],
                $app['annotation'],
                $app['ui_engine'],
                $app['assetsHandler']
            );
        };

        // registering the aplication namespace to SPL ClassLoader
        $this['autoloader']->register($this['config']->get('app.name'), $this['config']->get('app.app_root_dir'));

        // registering the aplication Extend folder to SPL ClassLoader (if folder was created)
        if (is_dir($this['config']->get('app.root_dir') . DIRECTORY_SEPARATOR . 'Extend')) {
            $this['autoloader']->register(
                $this['config']->get('app.name') . '/Extend',
                $this['config']->get('app.root_dir') . DIRECTORY_SEPARATOR . 'Extend'
            );
        }

        $this['exception_handler'] = function() use ($app) {
            return new ExceptionHandler();
        };
    }
1022545
public function run($args)
	{
		if(!isset($args[0]))
		{
			echo "Error: model class name is required.\n";
			echo $this->getHelp();
			return 1;
		}
		$className=$args[0];

		if(($db=Yii::app()->getDb())===null)
		{
			echo "Error: an active 'db' connection is required.\n";
			echo "If you already added 'db' component in application configuration,\n";
			echo "please quit and re-enter the yiic shell.\n";
			return 1;
		}

		$db->active=true;
		$this->_schema=$db->schema;

		if(!preg_match('/^[\w\.\-\*]*(.*?)$/',$className,$matches))
		{
			echo "Error: model class name is invalid.\n";
			return 1;
		}

		if(empty($matches[1]))  // without regular expression
		{
			$this->generateClassNames($this->_schema);
			if(($pos=strrpos($className,'.'))===false)
				$basePath=Yii::getPathOfAlias('application.models');
			else
			{
				$basePath=Yii::getPathOfAlias(substr($className,0,$pos));
				$className=substr($className,$pos+1);
			}
			if($className==='*') // generate all models
				$this->generateRelations();
			else
			{
				$tableName=isset($args[1])?$args[1]:$className;
				$tableName=$this->addPrefix($tableName);
				$this->_tables[$tableName]=$className;
				$this->generateRelations();
				$this->_classes=array($tableName=>$className);
			}
		}
		else  // with regular expression
		{
			$pattern=$matches[1];
			$pos=strrpos($className,$pattern);
			if($pos>0)  // only regexp is given
				$basePath=Yii::getPathOfAlias(rtrim(substr($className,0,$pos),'.'));
			else
				$basePath=Yii::getPathOfAlias('application.models');
			$this->generateClassNames($this->_schema,$pattern);
			$classes=$this->_tables;
			$this->generateRelations();
			$this->_classes=$classes;
		}

		if(count($this->_classes)>1)
		{
			$entries=array();
			$count=0;
			foreach($this->_classes as $tableName=>$className)
				$entries[]=++$count.". $className ($tableName)";
			echo "The following model classes (tables) match your criteria:\n";
			echo implode("\n",$entries)."\n\n";
			if(!$this->confirm("Do you want to generate the above classes?"))
				return;
		}

		$templatePath=$this->templatePath===null?YII_PATH.'/cli/views/shell/model':$this->templatePath;
		$fixturePath=$this->fixturePath===null?Yii::getPathOfAlias('application.tests.fixtures'):$this->fixturePath;
		$unitTestPath=$this->unitTestPath===null?Yii::getPathOfAlias('application.tests.unit'):$this->unitTestPath;

		$list=array();
		$files=array();
		foreach ($this->_classes as $tableName=>$className)
		{
			$files[$className]=$classFile=$basePath.DIRECTORY_SEPARATOR.$className.'.php';
			$list['models/'.$className.'.php']=array(
				'source'=>$templatePath.DIRECTORY_SEPARATOR.'model.php',
				'target'=>$classFile,
				'callback'=>array($this,'generateModel'),
				'params'=>array($className,$tableName),
			);
			if($fixturePath!==false)
			{
				$list['fixtures/'.$tableName.'.php']=array(
					'source'=>$templatePath.DIRECTORY_SEPARATOR.'fixture.php',
					'target'=>$fixturePath.DIRECTORY_SEPARATOR.$tableName.'.php',
					'callback'=>array($this,'generateFixture'),
					'params'=>$this->_schema->getTable($tableName),
				);
			}
			if($unitTestPath!==false)
			{
				$fixtureName=$this->pluralize($className);
				$fixtureName[0]=strtolower($fixtureName);
				$list['unit/'.$className.'Test.php']=array(
					'source'=>$templatePath.DIRECTORY_SEPARATOR.'test.php',
					'target'=>$unitTestPath.DIRECTORY_SEPARATOR.$className.'Test.php',
					'callback'=>array($this,'generateTest'),
					'params'=>array($className,$fixtureName),
				);
			}
		}

		$this->copyFiles($list);

		foreach($files as $className=>$file)
		{
			if(!class_exists($className,false))
				include_once($file);
		}

		$classes=implode(", ", $this->_classes);

		echo <<<EOD

The following model classes are successfully generated:
    $classes

If you have a 'db' database connection, you can test these models now with:
    \$model={$className}::model()->find();
    print_r(\$model);

EOD;
	}
196001
private function getConfig($key = null, $args = null)
    {
        if($key!=null) {

            $value = null;
            if(isset($this->_config[$key])) {
                $value = $this->_config[$key];

            } elseif(isset($this->_updateConfig[$key])) {
                    $value = $this->_updateConfig[$key];

            }

            if (isset($args["returnAsArray"]) && $args["returnAsArray"]){

                /** Return the response as an array */
                if(is_array($value)){
                    return $value;
                }
                
            }elseif(is_array($value)) {
                /** @var CheckoutApi_Lib_RespondObj $to_return */
                $to_return = CheckoutApi_Lib_Factory::getInstance('CheckoutApi_Lib_RespondObj');
                $to_return->setConfig( $value);
                return $to_return;
            }

            return $value;
        }

        if($key == null) {
            return $this->_config;
        }
        return null;
    }
77190
public static function generateHashes($configPath = 'FileStorage') {
		if (is_array($configPath)) {
			$imageSizes = $configPath;
		} else {
			$imageSizes = Configure::read($configPath . '.imageSizes');
		}
		if ($imageSizes === null) {
			throw new RuntimeException(sprintf('Image processing configuration in `%s` is missing!', $configPath . '.imageSizes'));
		}

		static::ksortRecursive($imageSizes);
		foreach ($imageSizes as $model => $version) {
			foreach ($version as $name => $operations) {
				Configure::write($configPath . '.imageHashes.' . $model . '.' . $name, static::hashOperations($operations));
			}
		}

		return Configure::read($configPath . '.imageHashes');
	}
34961
public function build(...$args)
    {
        $option = $this->query->getOption();
        $sql = 'select ' . $this->parseDistinct($option->distinct)
                . $this->parseField($option->field)
                . ' from '
                . $option->table
                . $this->parseJoin($option->join)
                . $this->parseWhere($option->where)
                . $this->parseGroup($option->group)
                . $this->parseHaving($option->having)
                . $this->parseOrder($option->order)
                . $this->parseLimit($option->offset, $option->limit)
                ;
        $this->query->bindValues($this->params);
        return $sql;
    }
168806
public function run($args)
	{
		if(!isset($args[0],$args[1]))
		{
			echo "Error: both model class and view name are required.\n";
			echo $this->getHelp();
			return 1;
		}
		$scenario=isset($args[2]) ? $args[2] : '';
		$modelClass=Yii::import($args[0],true);
		$model=new $modelClass($scenario);
		$attributes=$model->getSafeAttributeNames();

		$templatePath=$this->templatePath===null?YII_PATH.'/cli/views/shell/form':$this->templatePath;
		$viewPath=Yii::getPathOfAlias($args[1]);
		$viewName=basename($viewPath);
		$viewPath.='.php';
		$params=array(
			'modelClass'=>$modelClass,
			'viewName'=>$viewName,
			'attributes'=>$attributes,
		);
		$list=array(
			basename($viewPath)=>array(
				'source'=>$templatePath.'/form.php',
				'target'=>$viewPath,
				'callback'=>array($this,'generateForm'),
				'params'=>$params,
			),
		);

		$this->copyFiles($list);

		$actionFile=$templatePath.'/action.php';
		if(!is_file($actionFile))  // fall back to default ones
			$actionFile=YII_PATH.'/cli/views/shell/form/action.php';

		echo "The following form view has been successfully created:\n";
		echo "\t$viewPath\n\n";
		echo "You may use the following code in your controller action:\n\n";
		echo $this->renderFile($actionFile,$params,true);
		echo "\n";
	}
663490
public function make($abstract, $args = [])
    {
        $abstract = isset($this->aliases[$abstract]) ? $this->aliases[$abstract] : $abstract;

        if (isset($this->instances[$abstract])) {
            return $this->instances[$abstract];
        }

        $concrete = isset($this->bindings[$abstract]) ? $this->bindings[$abstract]['concrete'] : $abstract;

        if ($abstract == $concrete || $concrete instanceof Closure) {
            $object = $this->build($concrete, $args);
        } else {
            $object = $this->make($concrete, $args);
        }

        if ($this->isShared($abstract)) {
            $this->instances[$abstract] = $object;
        }

        return $object;
    }
670959
public function run($args)
	{
		$lastupdate=date('Y/m/d H:i:s');
		$comments="
/**
 * Yii bootstrap file.
 *
 * This file is automatically generated using 'build lite' command.
 * It is the result of merging commonly used Yii class files with
 * comments and trace statements removed away.
 *
 * By using this file instead of yii.php, an Yii application may
 * improve performance due to the reduction of PHP parsing time.
 * The performance improvement is especially obvious when PHP APC extension
 * is enabled.
 *
 * DO NOT modify this file manually.
 *
 * @author Qiang Xue <qiang.xue@gmail.com>
 * @link http://www.yiiframework.com/
 * @copyright 2008-2013 Yii Software LLC
 * @license http://www.yiiframework.com/license/
 * @version \$Id: \$
 * @since 1.0
 */

";

		$content=$this->minifyYii(dirname(__FILE__).'/lite/index.php');
		$content="<?php\n".preg_replace('/^(\?>|<\?php)/mu','',$content)."\n?>";
		$content=$this->stripComments($content);
		$content=preg_replace('/^require(_once)?.*\s*;\s*$/mu','',$content);
		$content=preg_replace('/^\s*Yii::trace.*\s*;\s*$/mu','',$content);
//		$content=preg_replace('/^\s*Yii::(begin|end)Profile.*\s*;\s*$/mu','',$content);
		$content=$this->stripEmptyLines($content);
		$content=substr_replace($content,$comments,5,0);
		file_put_contents(YII_PATH.DIRECTORY_SEPARATOR.'yiilite.php',$content);
		echo "Done.\n";
	}