Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

about fluent interface #33

Closed
yoander opened this Issue · 11 comments

5 participants

@yoander

Does PSR-2 accept fluent interface implementation and fluent constructor?

@dragoonis
Owner

@yoander there's nothing stopping you from doing "return $this" inside one of your methods.

@igorw

What is a fluent constructor?

@dragoonis
Owner

My presumption it is something like the 5.4+ feature of

$var = new ClassName()->someMethod();

Unsure though.

@yoander

@igorw

As @dragoonis said

Or simulate this behavior with php 5.3

public function __construc() {;}

public static function NewInstance()
{
return new static();
}

@Faryshta

I have a question about fluent interface.

Which way is the PSR compliant?

$longNameObject->longNameMethod($param)->anotherMethod($param, $var)->weKeepGoing($longVaraibleName)

$longNameObject->longNameMethod($param)
    ->anotherMethod($param, $var)
    ->weKeepGoing($longVaraibleName)

$longNameObject->longNameMethod($param)
               ->anotherMethod($param, $var)
               ->weKeepGoing($longVaraibleName)
@dragoonis
Owner
@Faryshta

my question is. after I make a new line which is the indentation? 4 spaces or till it reaches the height of the first method call?

@dragoonis
Owner
@dragoonis
Owner

Outdated conversation, questions answered, cleaning up.

@Faryshta if you still have coding standards questions please raise them on the PHP-FIG CS mailing list.

https://groups.google.com/forum/#!forum/php-fig-cs

Thanks

@dragoonis dragoonis closed this
@olekhy

@dragoonis please tell me where you take these?

My presumption it is something like the 5.4+ feature of

$var = new ClassName()->someMethod();

Unsure though.

@dragoonis
Owner

@olekhy Please talk on our coding standards mailing list, the link is above, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.