How to get variadic parameters passed by reference from __call and __callStatic

I have following class using __callStatic.

Method name is used to get array with values used as pattern to which compared value must match. Parameters (that is handled as array) accepts compared value.

public static function __callStatic($  Method, $  Parameters) {      $  Options = array();     $  Correct= 0;     $  Result = preg_match('/(?<function>Is_)(?<option>([[:upper:]][[:lower:]]+)+)/', $  Method, $  Options); 

The first part of following try-catch block is (more or less) non-sense because __call and __callStatic are called only when desired method does not exists. But I wanted to beautify warning message.

    try     {             if(method_exists(get_called_class(), $  Method))             {                 if(MethodScope::Is_Public(get_called_class(), $  Method))                 {                     call_user_func_array($  Method, $  Parameters);                 }                 else                 {                     throw new Exception(Exception::CLASSNAME, Exception::MTD_ACCESS);                 }             } 

The second part contains all really needed for method.

  • conversion method name into name of key with patterns.
  • iteration through selected array and comparing argument
  • decision what to return

            else         {             if($  Result)             {                 $  Option = preg_split('/((?:^|[A-Z])[a-z]+)/', $  Options['option'], NULL, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);                 $  Option = strtolower(implode('_', $  Option));                  for($  Index = 0; $  Index < count(self::Load_Options($  Option)); $  Index ++)                 {                     if(preg_match(self::Load_Options($  Option)[$  Index], $  Parameters[0]))                     {                         $  Correct++;                     }                 }                  return $  Correct != 0 ? TRUE : FALSE;             }             else             {                 throw new Exception(Exception::CLASSNAME, Exception::MTD_SUPPORT);             }         }     }     catch(Exception $  Exception)     {         $  Exception -> ExceptionWarning(get_called_class(), $  Method);     } } 

I would like to extend this magic method to not only return TRUE or FALSE but also to pass matches and used pattern by reference.

However, __call and __callStatic cannot pass arguments by reference – and have exactly two arguments. So, I am worried about that I will have to let method to only return TRUE or FALSE.

Or is any way how to avoid described limitations – and pass arguments by reference? Thank you for any answer.