- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
public function getObject()
{
$args = func_get_args();
if (empty($args)) {
$this->_throwException('wrong call of method - interface should be as 1st parameter');
}
$interface = array_shift($args);
$class = $this->getInjection($interface);
$argsCnt = count($args);
if ($argsCnt == 0) {
$object = new $class;
}
else if ($argsCnt == 1) {
$object = new $class($args[0]);
}
else if ($argsCnt == 2) {
$object = new $class($args[0], $args[1]);
}
else if ($argsCnt == 3) {
$object = new $class($args[0], $args[1], $args[2]);
}
else if ($argsCnt == 4) {
$object = new $class($args[0], $args[1], $args[2], $args[3]);
}
else if ($argsCnt == 5) {
$object = new $class($args[0], $args[1], $args[2], $args[3], $args[4]);
}
else if ($argsCnt == 6) {
$object = new $class($args[0], $args[1], $args[2], $args[3], $args[4], $args[5]);
}
else if ($argsCnt == 7) {
$object = new $class($args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6]);
}
else if ($argsCnt == 8) {
$object = new $class($args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7]);
}
else if ($argsCnt == 9) {
$object = new $class($args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7], $args[8]);
}
else if ($argsCnt == 10) {
$object = new $class($args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7], $args[8], $args[9]);
}
else if ($argsCnt == 11) {
$object = new $class($args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7], $args[8], $args[9], $args[10]);
}
else if ($argsCnt == 12) {
$object = new $class($args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7], $args[8], $args[9], $args[10], $args[11]);
}
else if ($argsCnt == 13) {
$object = new $class($args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7], $args[8], $args[9], $args[10], $args[11], $args[12]);
}
else if ($argsCnt == 14) {
$object = new $class($args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7], $args[8], $args[9], $args[10], $args[11], $args[12], $args[13]);
}
else if ($argsCnt == 15) {
$object = new $class($args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7], $args[8], $args[9], $args[10], $args[11], $args[12], $args[13], $args[14]);
}
else {
$this->_throwException('it looks like you use more than 15 arguments when trying to instantiate an object of class '.$class.' - that\'s ugly');
}
return $object;
}
> trying to instantiate an object of class '.$class.' - that\'s ugly'
воистину ugly
Это не гк, а микрооптимизация. Ибо call_user_func_array() - МЕДЛЕННЫЙ!
Потом если этот код конвертить в что-то бинарное, то скорее всего call_user_func* и прочие динамические фишки типа eval не пройдут.
Так что -1 тебе.
Update:
А, еп, там new $Class ... ну тогда хз.
автолоадеры пишутся не так. это два.
репозитории тоже пишутся не так. это три.
пишите интерфейсами, а не параметрами или именами классов/функций. это четыре.
если ты используешь eval, то, скорее всего, минус тебе. в принципе, по рейтингу комментария это заметно. это пять.
и да, во что бинарное ты собрался конвертить пхп? GUI приложения под винду - это моветон больший, чем твой сраный eval. это шесть.
2, 3, 4 - ниочем и мимо кассы
eval это не мой, не использую
> и да, во что бинарное ты собрался конвертить пхп
А о программах типа perl2exe, python2exe, etc. мы не слышали? лох...
2. муж моей жены смотрит на тебя, как на говно
3. чего же ты насчет eval'а так возмущался, если он не твой и ты его не используешь?
да и попроще бы вели беседы в интернетах с абсолютно незнакомыми людьми. глядишь - и минусов меньше было бы.
Где здесь php ?
Куда проще и лучше изучить с++ чем делать из php бинарные предложения, сама идея идиотизм ...
и кстати один call_user_func_array намного быстрее всей этой сабжевой хуеты - странно, что там нет циклов на закуску
причем уже 300 лет
$this->_throwException('it looks like you use more than 15 arguments when trying to instantiate an object of class '.$class.'. You can\'t do that because I don\'t want to write this ugly code any more');
I don't code it any more
Anymore
Nananana nananana nanana
В топ этот гк, в ТОП!!
http://govnokod.ru/3051
особенно в разделе PHP