getArguments(); // We'll call a specific method on the logger object, depending on the // severity passed in the original function call (if any). If there are // at least four arguments, a severity was passed. We check $arguments[3] // to ensure it's a valid severity constant, and if it's not, we default // to the notice() severity. // // @TODO Leave a FIXME for an invalid severity, since changing it to a // notice alters the intent of the original code. // if (sizeof($arguments) > 3 && $arguments[3] instanceof ConstantNode && in_array($arguments[3]->getConstantName()->getText(), static::$severityConstants)) { $method = strtolower(subStr($arguments[3], 9)); } else { $method = 'notice'; } // If there is a third argument, and it's an array, a context array // was passed. $context = (sizeof($arguments) > 2 && $arguments[2] instanceof ArrayNode) ? clone $arguments[2] : ArrayNode::create([]); return ClassMethodCallNode::create('\Drupal', 'logger') ->appendArgument(clone $arguments[0]) ->appendMethodCall($method) ->appendArgument(clone $arguments[1]) ->appendArgument($context); } }