_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
33
8k
language
stringclasses
1 value
meta_information
dict
q12700
BaseHandler.sendChatActionReply
train
public function sendChatActionReply(): SendChatAction { $m = $this->bot->sendChatAction();
php
{ "resource": "" }
q12701
TaskSubType.copyTemplateFilesToProject
train
protected function copyTemplateFilesToProject(array $filenames, $overwrite = false) { try { $filesystem = $this->taskFilesystemStack(); foreach ($filenames as $template_path => $target_path) { $target_file = ProjectX::projectRoot() . "/{$target_path}"; $template_file = $this ->templateManager() ->getTemplateFilePath($template_path);
php
{ "resource": "" }
q12702
ArrayUtils.arrayDropdown
train
public static function arrayDropdown(array $raw, $partition, $key, $value) { $output = array(); foreach (self::arrayPartition($raw, $partition) as $target => $data) { foreach ($data as $innerKey => $innerValue) { if
php
{ "resource": "" }
q12703
ArrayUtils.arrayPartition
train
public static function arrayPartition(array $raw, $key, $keepKey = true) { $result = array(); foreach ($raw as $index => $collection) { // Make the the root partition exists if (!isset($collection[$key])) { throw new LogicException(sprintf( 'The key "%s" does not exist in provided collection', $key ));
php
{ "resource": "" }
q12704
ArrayUtils.arrayRecovery
train
public static function arrayRecovery(array $array, array $keys, $value) { foreach ($keys as $key)
php
{ "resource": "" }
q12705
ArrayUtils.valuefy
train
public static function valuefy(array $data, $valueModue = true) { if ($valueModue === true) { $values = array_values($data); } else { $values
php
{ "resource": "" }
q12706
ArrayUtils.sumColumnsWithAverages
train
public static function sumColumnsWithAverages(array $entities, array $averages = array(), $precision = 2) { // Count the sum of all columns $sum = self::sumColumns($entities); if (!empty($averages)) { $count = count($entities); // Make sure that the division by zero won't occur if ($count === 0) { $count = 1; } foreach ($averages as $average) {
php
{ "resource": "" }
q12707
ArrayUtils.roundValues
train
public static function roundValues(array $data, $precision = 2) { return self::filterValuesRecursively($data, function($value) use ($precision) { $value = is_numeric($value)
php
{ "resource": "" }
q12708
ArrayUtils.arrayColumns
train
public static function arrayColumns(array $data) { // Count the amount of values from the source input $count = count($data); if ($count === 0) {
php
{ "resource": "" }
q12709
ArrayUtils.sumColumns
train
public static function sumColumns(array $data) { $columns = self::arrayColumns($data); if ($columns !== false){
php
{ "resource": "" }
q12710
ArrayUtils.columnSum
train
public static function columnSum(array $data, array $columns) { $result = array(); foreach ($columns as $column) { foreach ($data as $collection) { if (isset($collection[$column])) { if (isset($result[$column])) { $result[$column] += $collection[$column]; } else
php
{ "resource": "" }
q12711
ArrayUtils.filterValuesRecursively
train
public static function filterValuesRecursively(array $array, Closure $callback = null) { foreach ($array as $index => $value) { if (is_array($value)) { $array[$index] = call_user_func(__METHOD__, $value, $callback); } else
php
{ "resource": "" }
q12712
ArrayUtils.filterArray
train
public static function filterArray(array $array, Closure $callback) { foreach ($array as $index => $collection) { $array[$index]
php
{ "resource": "" }
q12713
ArrayUtils.mergeWithout
train
public static function mergeWithout(array $first, array $second, array $keys)
php
{ "resource": "" }
q12714
ArrayUtils.keysExist
train
public static function keysExist(array $collection, array $keys) { $collection = array_flip($collection); foreach ($keys as $key) {
php
{ "resource": "" }
q12715
ArrayUtils.arrayOnlyWith
train
public static function arrayOnlyWith(array $array, array $keys) { $result = array(); if (!self::isSequential($array)) { foreach ($array as $key => $value) { if (in_array($key, $keys)) { $result[$key] = $value; } } } else {
php
{ "resource": "" }
q12716
ArrayUtils.arrayCombine
train
public static function arrayCombine(array $first, array $second, $replacement = null, $order = true) { // Fix for different length if (count($first) !== count($second)) { $input = array($first, $second); $count = array_map('count', $input); // Find the largest and lowest array index $min = array_keys($count , max($count)); $max = array_keys($count , min($count));
php
{ "resource": "" }
q12717
ArrayUtils.arrayList
train
public static function arrayList(array $array, $key, $value) { $result = array(); foreach ($array as $row) { if (array_key_exists($key, $row) && array_key_exists($value, $row)) { // References $name =& $row[$key]; $text =& $row[$value]; $result[$name] =
php
{ "resource": "" }
q12718
ArrayUtils.arrayWithout
train
public static function arrayWithout(array $array, array $keys) { // Shared filter function $filter = function(array $array, array $keys) { foreach ($keys as $key) { if (array_key_exists($key, $array)) { unset($array[$key]); } } return $array; }; if (self::hasAllArrayValues($array)) {
php
{ "resource": "" }
q12719
ArrayUtils.search
train
public static function search(array $haystack, $needle) { foreach ($haystack as $key => $value) { if (is_array($value)) { $target = self::search($value, $needle); } else { $target = ''; } if ($needle === $value || ($target != false && $target != null)) {
php
{ "resource": "" }
q12720
ArrayUtils.arrayUnique
train
public static function arrayUnique(array $array) { // Serialize each array's value foreach ($array as &$value) { $value = serialize($value); } // Now remove duplicate strings $array = array_unique($array);
php
{ "resource": "" }
q12721
DocumentSelector.orderBy
train
public function orderBy(string $field, int $direction = self::ASCENDING): DocumentSelector
php
{ "resource": "" }
q12722
DocumentSelector.findOne
train
public function findOne(array $query = [], bool $normalizeDates = true) { if ($normalizeDates) { $query = $this->normalizeDates($query); } //Working with projection (required to properly sort results) $result = $this->collection->findOne( array_merge($this->query, $query),
php
{ "resource": "" }
q12723
DocumentSelector.count
train
public function count(array $query = []): int { //Create options? return $this->collection->count( array_merge($this->query, $query),
php
{ "resource": "" }
q12724
DocumentSelector.normalizeDates
train
protected function normalizeDates(array $query): array { array_walk_recursive($query, function (&$value) { if ($value instanceof
php
{ "resource": "" }
q12725
DrupalCacheAdapter.cache_set
train
public function cache_set($cid, $data, $bin = 'cache', $expire = CACHE_PERMANENT) { return
php
{ "resource": "" }
q12726
DockerServiceBase.getService
train
public function getService() { if (!isset($this->service)) { $info = $this->getInfo(); $this->service = $this->service(); // Apply the overridden property values. foreach (static::PROPERTIES_OVERRIDE as $property) { if (!isset($info[$property]) || empty($info[$property])) { continue; }
php
{ "resource": "" }
q12727
DockerServiceBase.getEnvironmentValue
train
public function getEnvironmentValue($name) { $name = strtolower($name); $service = $this->getService(); foreach ($service->getEnvironment() as $environment)
php
{ "resource": "" }
q12728
DockerServiceBase.getHostPorts
train
public function getHostPorts() { $ports = []; $service = $this->getService(); foreach ($service->getPorts() as $port) { list($host,)
php
{ "resource": "" }
q12729
DockerServiceBase.getPorts
train
protected function getPorts($host = null) { $ports = $this->ports(); array_walk($ports, function (&$port) use ($host) { $host =
php
{ "resource": "" }
q12730
DockerServiceBase.getServiceNames
train
protected function getServiceNames() { $names = []; foreach ($this->getServices() as $name => $info) { if (!isset($info['type'])) { continue;
php
{ "resource": "" }
q12731
DockerServiceBase.alterService
train
protected function alterService(DockerService $service) { if ($this->internal) { $service ->setNetworks([ 'internal' ]) ->setlabels([ 'traefik.enable=false' ]); if ($this->bindPorts) { $service->setPorts(
php
{ "resource": "" }
q12732
DockerServiceBase.formatRunCommand
train
protected function formatRunCommand(array $commands) { $last = end($commands); return 'RUN ' . implode("\r\n && ", array_map( function ($value) use ($last) {
php
{ "resource": "" }
q12733
DockerServiceBase.mergeConfigVariable
train
protected function mergeConfigVariable($name, array $values) { if (in_array($name, static::DOCKER_VARIABLES)) {
php
{ "resource": "" }
q12734
Manager.launchNextTask
train
protected function launchNextTask() { if (! $this->numberOfThreadsToLaunch) { return false; } $taskInfos = $this->pool[$this->numberOfTasks - $this->numberOfThreadsToLaunch];
php
{ "resource": "" }
q12735
Router.match
train
public function match($segment, array $map) { foreach ($map as $index => $uriTemplate) { $matches = array(); if (preg_match($this->createRegEx($uriTemplate), $segment, $matches) === 1) { $matchedURI = array_shift($matches);
php
{ "resource": "" }
q12736
Router.createRegEx
train
private function createRegEx($uriTemplate) { $pattern = str_replace($this->getPlaceholders(), $this->getPatterns(), $uriTemplate);
php
{ "resource": "" }
q12737
CacheMapper.fetchAll
train
public function fetchAll() { $query = sprintf('SELECT * FROM `%s`', $this->table); $result = array(); foreach ($this->pdo->query($query) as $key => $value) {
php
{ "resource": "" }
q12738
CacheMapper.alter
train
private function alter($key, $operator, $step) { $query = sprintf('UPDATE `%s` SET `value` = value %s %s WHERE `key`
php
{ "resource": "" }
q12739
CacheMapper.insert
train
public function insert($key, $value, $ttl, $time) { if ($this->serializer->isSerializeable($value)) { $value = $this->serializer->serialize($value); } $query = sprintf('INSERT INTO `%s` (`key`, `value`, `ttl`, `created_on`) VALUES (:key, :value, :ttl, :created_on)', $this->table); $stmt = $this->pdo->prepare($query); return $stmt->execute(array(
php
{ "resource": "" }
q12740
CacheMapper.parse
train
private function parse(array $data) { $result = array(); foreach ($data as $index => $array) { if ($this->serializer->isSerialized($array[ConstProviderInterface::CACHE_PARAM_VALUE])) { $array[ConstProviderInterface::CACHE_PARAM_VALUE] = $this->serializer->unserialize($array[ConstProviderInterface::CACHE_PARAM_VALUE]);
php
{ "resource": "" }
q12741
PrimeTask.insertNewFileFunctions
train
private function insertNewFileFunctions(iterable $new): void { // early return when there is nothing to be added if (0 === \count($new)) { return; } $table = $this->getTable(); $db = $this->getDb(); foreach ($new as $file_function => $data) { $query = $db->prepare( "INSERT INTO $table (function, added_at, changed_at) VALUES (:file_function, NOW(), :changed_at)" );
php
{ "resource": "" }
q12742
Calculator.get
train
public function get(Carbon $dt = NULL) { if (!$dt) { $dt = new Carbon(); } /* Disregard times */ $dt->setTime(0, 0, 0); /* FY is based on the -end- of the FY, thus we will work backward to determine if we need to 'rollup' the FY from the input year */ $fyStart = Carbon::create($dt->year, $this->month, $this->day, 0,
php
{ "resource": "" }
q12743
NumberBase.buildDigitList
train
private function buildDigitList($digitList) { if (is_int($digitList)) { return new IntegerDigitList($digitList); } elseif (is_string($digitList)) { return new StringDigitList($digitList); } elseif (is_array($digitList)) {
php
{ "resource": "" }
q12744
NumberBase.hasDigit
train
public function hasDigit($digit) { try { $this->digits->getValue($digit); }
php
{ "resource": "" }
q12745
NumberBase.getValues
train
public function getValues(array $digits) { $values = []; foreach ($digits as $digit) { $values[] =
php
{ "resource": "" }
q12746
NumberBase.getDigits
train
public function getDigits(array $decimals) { $digits = []; foreach ($decimals as $decimal) { $digits[] =
php
{ "resource": "" }
q12747
NumberBase.findCommonRadixRoot
train
public function findCommonRadixRoot(NumberBase $base) { $common = array_intersect($this->getRadixRoots(),
php
{ "resource": "" }
q12748
NumberBase.getRadixRoots
train
private function getRadixRoots() { $radix = count($this->digits); $roots = [$radix]; for ($i = 2; ($root = (int) ($radix ** (1 / $i))) > 1; $i++) {
php
{ "resource": "" }
q12749
NumberBase.canonizeDigits
train
public function canonizeDigits(array $digits) { $result = $this->getDigits($this->getValues($digits));
php
{ "resource": "" }
q12750
NumberBase.splitString
train
public function splitString($string) { if ($this->digits->hasStringConflict()) { throw new \RuntimeException('The number base does not support string presentation'); } $pattern = $this->getDigitPattern(); if ((string) $string === '') { $digits = [];
php
{ "resource": "" }
q12751
NumberBase.getDigitPattern
train
private function getDigitPattern() { if (!isset($this->digitPattern)) { $lengths = array_map('strlen', $this->digits->getDigits()); if (count(array_flip($lengths)) === 1) { $this->digitPattern = array_pop($lengths); } else { $this->digitPattern = sprintf( '(%s|.+)s%s',
php
{ "resource": "" }
q12752
ValidatorChain.isValid
train
public function isValid() { foreach ($this->validators as $validator) { if (!$validator->isValid()) { // Prepare error messages foreach ($validator->getErrors() as $name => $messages) { if (!isset($this->errors[$name])) {
php
{ "resource": "" }
q12753
Href.replace
train
public function replace( $key, $value ) { if($value === "" || is_null($value) || $value === false) { $this->url = preg_replace("#/{"
php
{ "resource": "" }
q12754
Href.validate
train
public function validate() { if (!$this->isValid( $this->getUrl() )) { throw new InvalidUrl( sprintf( '"%s" is
php
{ "resource": "" }
q12755
EventTaskBase.executeCommandHook
train
protected function executeCommandHook($method, $event_type) { foreach ($this->getCommandsByMethodEventType($method, $event_type) as $command) { if (is_string($command)) { $command = (new CommandHook()) ->setType('raw') ->setCommand($command); } elseif (is_array($command)) { $command = CommandHook::createWithData($command); } if (!$command instanceof CommandHookInterface) { continue;
php
{ "resource": "" }
q12756
EventTaskBase.executeEngineCmdHook
train
protected function executeEngineCmdHook(CommandHookInterface $hook_command) { $options = $hook_command->getOptions(); // Determine the service the command should be ran inside. $service = isset($options['service']) ? $options['service'] : null; // Determine if the command should be ran locally.
php
{ "resource": "" }
q12757
EventTaskBase.resolveHookCommand
train
protected function resolveHookCommand(CommandHookInterface $command_hook) { $command = null; switch ($command_hook->getType()) { case 'raw': $command = $command_hook->getCommand(); break; case 'engine': $command = $this->getEngineCommand($command_hook); break;
php
{ "resource": "" }
q12758
EventTaskBase.executeSymfonyCmdHook
train
protected function executeSymfonyCmdHook(CommandHookInterface $command_hook, $method) { $command = $command_hook->getCommand(); $container = ProjectX::getContainer(); $application = $container->get('application'); try { $info = $this->getCommandInfo($method); $command = $application->find($command); if ($command->getName() === $info->getName()) { throw new \Exception(sprintf( 'Unable to call the %s command hook due to it ' . 'invoking the parent method.', $command->getName() )); } } catch (CommandNotFoundException $exception) { throw new CommandHookRuntimeException(sprintf( 'Unable to find %s command in the project-x command ' . 'hook.', $command )); } catch (\Exception $exception) { throw new CommandHookRuntimeException($exception->getMessage()); } $exec = $this->taskSymfonyCommand($command); $definition = $command->getDefinition(); // Support symfony command options. if ($command_hook->hasOptions()) {
php
{ "resource": "" }
q12759
EventTaskBase.getProjectCommand
train
protected function getProjectCommand(CommandHookInterface $command_hook) { $method = $command_hook->getCommand(); $project = $this->getProjectInstance(); if (!method_exists($project, $method)) {
php
{ "resource": "" }
q12760
EventTaskBase.getEngineCommand
train
protected function getEngineCommand(CommandHookInterface $command_hook) { $method = $command_hook->getCommand(); $engine = $this->getEngineInstance(); if (!method_exists($engine, $method)) { throw new CommandHookRuntimeException( sprintf("The %s method doesn't exist on the environment engine.", $method)
php
{ "resource": "" }
q12761
EventTaskBase.getCommandsByMethodEventType
train
protected function getCommandsByMethodEventType($method, $event_type) { $hooks = ProjectX::getProjectConfig()->getCommandHooks(); if (empty($hooks)) { return []; } $info = $this->getCommandInfo($method); list($command, $action) = explode(':', $info->getName());
php
{ "resource": "" }
q12762
RedisProxy.setDriversOrder
train
public function setDriversOrder(array $driversOrder) { foreach ($driversOrder as $driver) { if (!in_array($driver, $this->supportedDrivers)) { throw
php
{ "resource": "" }
q12763
RedisProxy.exists
train
public function exists($key) { $this->init(); $result
php
{ "resource": "" }
q12764
RedisProxy.get
train
public function get($key) { $this->init(); $result = $this->driver->get($key);
php
{ "resource": "" }
q12765
RedisProxy.getset
train
public function getset($key, $value) { $this->init(); $result = $this->driver->getset($key, $value);
php
{ "resource": "" }
q12766
RedisProxy.expire
train
public function expire($key, $seconds) { $this->init(); $result
php
{ "resource": "" }
q12767
RedisProxy.pexpire
train
public function pexpire($key, $miliseconds) { $this->init(); $result
php
{ "resource": "" }
q12768
RedisProxy.expireat
train
public function expireat($key, $timestamp) { $this->init(); $result
php
{ "resource": "" }
q12769
RedisProxy.pexpireat
train
public function pexpireat($key, $milisecondsTimestamp) { $this->init(); $result
php
{ "resource": "" }
q12770
RedisProxy.psetex
train
public function psetex($key, $miliseconds, $value) { $this->init(); $result = $this->driver->psetex($key, $miliseconds, $value); if ($result == '+OK') {
php
{ "resource": "" }
q12771
RedisProxy.persist
train
public function persist($key) { $this->init(); $result
php
{ "resource": "" }
q12772
RedisProxy.setnx
train
public function setnx($key, $value) { $this->init(); $result
php
{ "resource": "" }
q12773
RedisProxy.incrby
train
public function incrby($key, $increment = 1) { $this->init();
php
{ "resource": "" }
q12774
RedisProxy.incrbyfloat
train
public function incrbyfloat($key, $increment = 1) {
php
{ "resource": "" }
q12775
RedisProxy.decrby
train
public function decrby($key, $decrement = 1) { $this->init();
php
{ "resource": "" }
q12776
RedisProxy.dump
train
public function dump($key) { $this->init(); $result = $this->driver->dump($key);
php
{ "resource": "" }
q12777
RedisProxy.mset
train
public function mset(...$dictionary) { $this->init(); if (is_array($dictionary[0])) { $result = $this->driver->mset(...$dictionary);
php
{ "resource": "" }
q12778
RedisProxy.hdel
train
public function hdel($key, ...$fields) { $fields = $this->prepareArguments('hdel', ...$fields);
php
{ "resource": "" }
q12779
RedisProxy.hincrby
train
public function hincrby($key, $field, $increment = 1) { $this->init();
php
{ "resource": "" }
q12780
RedisProxy.hincrbyfloat
train
public function hincrbyfloat($key, $field, $increment = 1) {
php
{ "resource": "" }
q12781
RedisProxy.hmset
train
public function hmset($key, ...$dictionary) { $this->init(); if (is_array($dictionary[0])) { $result = $this->driver->hmset($key, ...$dictionary);
php
{ "resource": "" }
q12782
RedisProxy.hmget
train
public function hmget($key, ...$fields) { $fields = array_unique($this->prepareArguments('hmget', ...$fields)); $this->init(); $values = []; foreach ($this->driver->hmget($key, $fields) as $value) {
php
{ "resource": "" }
q12783
RedisProxy.sadd
train
public function sadd($key, ...$members) { $members = $this->prepareArguments('sadd', ...$members);
php
{ "resource": "" }
q12784
RedisProxy.spop
train
public function spop($key, $count = 1) { $this->init(); if ($count == 1 || $count === null) { $result = $this->driver->spop($key); return $this->convertFalseToNull($result);
php
{ "resource": "" }
q12785
RedisProxy.sscan
train
public function sscan($key, &$iterator, $pattern = null, $count = null) { if ((string)$iterator === '0') { return null; } $this->init(); if ($this->actualDriver() === self::DRIVER_PREDIS)
php
{ "resource": "" }
q12786
RedisProxy.rpush
train
public function rpush($key, ...$elements) { $elements = $this->prepareArguments('rpush', ...$elements);
php
{ "resource": "" }
q12787
RedisProxy.lpop
train
public function lpop($key) { $this->init(); $result = $this->driver->lpop($key);
php
{ "resource": "" }
q12788
RedisProxy.rpop
train
public function rpop($key) { $this->init(); $result = $this->driver->rpop($key);
php
{ "resource": "" }
q12789
RedisProxy.zadd
train
public function zadd($key, ...$dictionary) { $this->init(); if (is_array($dictionary[0])) { $return = 0; foreach ($dictionary[0] as $member => $score) { $res = $this->zadd($key, $score, $member);
php
{ "resource": "" }
q12790
RedisProxy.zrevrange
train
public function zrevrange($key, $start, $stop, $withscores = false) { $this->init(); if ($this->actualDriver() === self::DRIVER_PREDIS) { return $this->driver->zrevrange($key, $start, $stop, ['WITHSCORES'
php
{ "resource": "" }
q12791
RedisProxy.convertFalseToNull
train
private function convertFalseToNull($result) { return $this->actualDriver() ===
php
{ "resource": "" }
q12792
RedisProxy.transformResult
train
private function transformResult($result) { if ($this->actualDriver() === self::DRIVER_PREDIS && $result instanceof Status) { $result
php
{ "resource": "" }
q12793
RedisProxy.prepareKeyValue
train
private function prepareKeyValue(array $dictionary, $command) { $keys = array_values(array_filter($dictionary, function ($key) { return $key % 2 == 0; }, ARRAY_FILTER_USE_KEY)); $values = array_values(array_filter($dictionary, function ($key) { return $key % 2 == 1; }, ARRAY_FILTER_USE_KEY));
php
{ "resource": "" }
q12794
Dumper.dump
train
public static function dump($variable, $exit = true) { if (is_object($variable) && method_exists($variable, '__toString')) { echo $variable; } else { if (is_bool($variable)) { var_dump($variable);
php
{ "resource": "" }
q12795
Bootstrap.router
train
public static function router($directory, $config = 'config.yml') { $request = Server::get('PHP_SELF'); $root = Server::get('DOCUMENT_ROOT'); $file = $root . $request; if(file_exists($file) && !is_dir($file)) {
php
{ "resource": "" }
q12796
Bootstrap.init
train
public function init() { Profiler::start('init', 'init'); $this->initTime = microtime(true); $this->init = true; Log::d('Initializing framework...'); // $this->register_error_handler(); date_default_timezone_set('Europe/Madrid'); $this->setupLanguage(); Profiler::stop('init'); $this->manager = new ModuleManager($this->config, $this->directory); $this->manager->init();
php
{ "resource": "" }
q12797
Bootstrap.install
train
public function install() { define('GL_INSTALL', true); $this->init(); echo '<pre>'; $fail = false; $db = new DatabaseManager(); if ($db->connectAndSelect()) { $this->setDatabase($db); $this->log('Connection to database ok'); $this->log('Installing Database...'); $models = $this->getModels(); foreach ($models as $model) { $instance = new $model(null); if ($instance instanceof Model) { $diff = $instance->getStructureDifferences($db, isset($_GET['drop'])); $this->log('Installing table \'' . $instance->getTableName() . '\' generated by ' . get_class($instance) . '...', 2); foreach ($diff as $action) { $this->log('Action: ' . $action['sql'] . '...', 3, false); if (isset($_GET['exec'])) { try { DBStructure::runAction($db, $instance, $action); $this->log('[OK]', 0); } catch (\Exception $ex) { $this->log('[FAIL]', 0); $fail = true; } } echo "\n"; }
php
{ "resource": "" }
q12798
InstanceBuilder.build
train
public function build($class, array $args) { // Normalize class name $class = $this->normalizeClassName($class); if (isset($this->cache[$class])) { return $this->cache[$class]; } else { if (class_exists($class, true)) { $instance = $this->getInstance($class, $args); $this->cache[$class] = $instance; return $instance; }
php
{ "resource": "" }
q12799
InstanceBuilder.getInstance
train
private function getInstance($class, array $args) { // Hack to avoid Reflection for most cases switch (count($args)) { case 0: return new $class; case 1: return new $class($args[0]); case 2: return new $class($args[0], $args[1]); case 3: return new $class($args[0], $args[1], $args[2]); case 4: return new $class($args[0], $args[1], $args[2], $args[3]); case 5:
php
{ "resource": "" }