Question

I just found this in a laravel bundle that I just installed, and really have no idea what with() is... as it isn't declared any where

public static function of($query)
{
    $ins = with(new static); // What is with(new static) ?
    $ins->save_query($query);
    return $ins;
}
Was it helpful?

Solution

with() is not a statement but a user defined function in Laravel framework.

From laravel documentation :

490: /**
491:  * Short-cut for constructor method chaining.
492:  *
493:  * @param  mixed  $object
494:  * @return mixed
495:  */
496: function with($object)
497: {
498:     return $object;
499: }

OTHER TIPS

First, answer to the title:

In computer programming a statement is the smallest standalone element of an imperative programming language. A program written in such a language is formed by a sequence of one or more statements. A statement will have internal components (e.g., expressions).source

Second, with() is a user defined function in Laravel framework.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top