delight-im / PHP-Cookie

Modern cookie management for PHP
MIT License
165 stars 48 forks source link

Constructor's parameter order #4

Closed gregmartyn closed 8 years ago

gregmartyn commented 8 years ago

The constructor's parameter list is mostly the same as setcookie(), with the exception of httpOnly and secureOnly, which are swapped. Would you consider swapping them in a future version so that they align with setcookie()?

I was porting some code that was using setcookie() to using the PHP-Cookie constructor and noticed that it's very easy to miss that.

ocram commented 8 years ago

Thanks a lot for your feedback on this!

What method's signature are you talking about, exactly?

The Cookie::setcookie(...) method, which has been added as a replacement for PHP's native function of the same name, is fully compatible with the PHP function, as you can see here.

The constructor, on the other hand, has only one parameter, which is the cookie's name, as you can see here. All the other attributes on instances are set via the setters which cannot really be mixed up, right?

gregmartyn commented 8 years ago

Oh, oops, you're right. I saw it doing $this->name = ... $this->value = ... etc and I guess I assumed the constructor was being passed all those parameters in order. Nothing to see here..

ocram commented 8 years ago

No problem, thank you!