Skip to content

Commit 5b12ea1

Browse files
committed
Updated callback functions to use callable native php objects.
1 parent 0a63838 commit 5b12ea1

File tree

1 file changed

+69
-22
lines changed

1 file changed

+69
-22
lines changed

src/class.uploader.php

Lines changed: 69 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -441,34 +441,81 @@ private function formatSize($bytes){
441441
return $bytes;
442442
}
443443

444-
private function _onCheck(){
445-
$arguments = func_get_args();
446-
return $this->options['onCheck'] != null && function_exists($this->options['onCheck']) ? $this->options['onCheck'](@$arguments[0]) : null;
447-
}
448444

449-
private function _onSuccess(){
450-
$arguments = func_get_args();
451-
return $this->options['onSuccess'] != null && function_exists($this->options['onSuccess']) ? $this->options['onSuccess'](@$arguments[0], @$arguments[1]) : null;
452-
}
445+
private function _onCheck(){
446+
$arguments = func_get_args();
447+
if (is_callable($this->options['onCheck'])) {
448+
return call_user_func_array($this->options['onCheck'], $arguments);
449+
}
450+
}
453451

454-
private function _onError(){
455-
$arguments = func_get_args();
456-
return $this->options['onError'] && function_exists($this->options['onError']) ? $this->options['onError'](@$arguments[0], @$arguments[1]) : null;
457-
}
452+
private function _onSuccess(){
453+
$arguments = func_get_args();
454+
if (is_callable($this->options['onSuccess'])) {
455+
return call_user_func_array($this->options['onSuccess'], $arguments);
456+
}
457+
}
458458

459-
private function _onUpload(){
460-
$arguments = func_get_args();
461-
return $this->options['onUpload'] && function_exists($this->options['onUpload']) ? $this->options['onUpload'](@$arguments[0], @$arguments[1]) : null;
462-
}
459+
private function _onError(){
460+
$arguments = func_get_args();
461+
if (is_callable($this->options['onError'])) {
462+
return call_user_func_array($this->options['onError'], $arguments);
463+
}
464+
}
465+
466+
private function _onUpload(){
467+
$arguments = func_get_args();
468+
if (is_callable($this->options['onUpload'])) {
469+
return call_user_func_array($this->options['onUpload'], $arguments);
470+
}
471+
}
463472

464473
private function _onComplete(){
465-
$arguments = func_get_args();
466-
return $this->options['onComplete'] != null && function_exists($this->options['onComplete']) ? $this->options['onComplete'](@$arguments[0], @$arguments[1]) : null;
467-
}
474+
$arguments = func_get_args();
475+
if (is_callable($this->options['onComplete'])) {
476+
return call_user_func_array($this->options['onComplete'], $arguments);
477+
}
478+
}
468479

469480
private function _onRemove(){
470-
$arguments = func_get_args();
471-
return $this->options['onRemove'] && function_exists($this->options['onRemove']) ? $this->options['onRemove'](@$arguments[0], @$arguments[1]) : null;
472-
}
481+
$arguments = func_get_args();
482+
if (is_callable($this->options['onRemove'])) {
483+
return call_user_func_array($this->options['onRemove'], $arguments);
484+
}
485+
}
486+
487+
488+
489+
/*
490+
private function _onCheck(){
491+
$arguments = func_get_args();
492+
return $this->options['onCheck'] != null && function_exists($this->options['onCheck']) ? $this->options['onCheck'](@$arguments[0]) : null;
493+
}
494+
495+
private function _onSuccess(){
496+
$arguments = func_get_args();
497+
return $this->options['onSuccess'] != null && function_exists($this->options['onSuccess']) ? $this->options['onSuccess'](@$arguments[0], @$arguments[1]) : null;
498+
}
499+
500+
private function _onError(){
501+
$arguments = func_get_args();
502+
return $this->options['onError'] && function_exists($this->options['onError']) ? $this->options['onError'](@$arguments[0], @$arguments[1]) : null;
503+
}
504+
505+
private function _onUpload(){
506+
$arguments = func_get_args();
507+
return $this->options['onUpload'] && function_exists($this->options['onUpload']) ? $this->options['onUpload'](@$arguments[0], @$arguments[1]) : null;
508+
}
509+
510+
private function _onComplete(){
511+
$arguments = func_get_args();
512+
return $this->options['onComplete'] != null && function_exists($this->options['onComplete']) ? $this->options['onComplete'](@$arguments[0], @$arguments[1]) : null;
513+
}
514+
515+
private function _onRemove(){
516+
$arguments = func_get_args();
517+
return $this->options['onRemove'] && function_exists($this->options['onRemove']) ? $this->options['onRemove'](@$arguments[0], @$arguments[1]) : null;
518+
}
519+
*/
473520
}
474521
?>

0 commit comments

Comments
 (0)