u/celtric
In this archive from Jan 2010 to Nov 2016
- 20
- posts
- 257
- comments
- 3
- media
- 1.1k
- score
How to implement third-party integrations in DDD?
Imagine a use-case where a store owner wants to request a new subscription, but that subscription depends on an external gateway (PayPal in this example). The path I've been following involves the StoreOwner to request things to a SubscriptionService. Is that the correct way to go? How do you handle...
Exceptions thrown by interfaces ignored by PhpStorm's @throw inspection w/ "Analyze immediate calls"?
I can't get it to work and have not found a single comment on Google or Jetbrain's bugtracker about this. Before creating a ticket, have you found this same problem? Or do I have something misconfigured? Example: <?php interface Gateway { / @param mixed $userId @return UserStatus @throws FailedGatew...
How to match a postal code to a country subdivision?
We want to save our customers the time to manually select the region they live in, and instead deduce their country subdivision from their postal code. We have found some sources and packages (example), but we haven't been able to find a source that covers all countries. Do you know about a way to o...
/r/php opinion on PHP scalar typehints - February 2015
docs.google.com/forms/d/1tUB2VdCL5u-MjBWROSYii1z.../r/php informal vote for "RFC: Scalar Type Hints"
docs.google.com/forms/d/1bjcZIbmdWaS__TlieyKeGPx...How to block modification of a locked object's children
Imagine we have a class that can be locked: class Foo { protected $name = "John"; protected $locked = false; public function isLocked() { return $this->locked; } public function lock() { $this->locked = true; } public function setName($name) { if ($this->isLocked()) {
Thinking about moving to Java
I've always been a big defender of the simplicity of PHP vs the overly-verbose Java approach. Lately though, as I write more packages for backend which don't allow margin of error (payments handling, etc.), I find myself writing lots of tests and writing the same verbose code that I hated from Java,...
State of named parameters RFC?
I haven't been able to find information about it in the last months, although it's one of the most demanded features in PHP. The last messages regarding this RFC point out that existing native functions should be updated one by one (some of them don't match the official documentation apparently), wi...
Method chaining: yes or no? Only for setters?
This makes sense: class Foo { protected $name; public function setName($name) { $this->name = $name; return $this; } } As it makes it easy to set multiple options. But, is it useful outside of setters? Imagine this: class Bar { protected $users = []; public function addUse
Too much verbosity?
I don't know who will be developing this code, and I'm getting paranoid about the requirements. Is this too much? Foo/Bar/Enum/States.php <?php namespace Foo\Bar\Enum; class States { const ACTIVE = 'active'; const COMPLETED = 'completed'; const CANCELLED = 'cancelled'; } Foo/Bar/Model/StateInterface...
Type hinting in `foreach` loops?
I've been checking the current RFCs but haven't seen anything. Does anyone know if has this been proposed in the past, or will not be implemented for x reason? Eg.: foreach ($sets as array $set) { ... } foreach ($sets as MyClass $set) { ... }
Integrating ActiveMerchant with PHP, best option to abstract payments?
We are looking to abstract our current payment platform, as we want to be able to change providers easily in the future and not get stuck with one. We have found that ActiveMerchant for ruby is one of the most widely used, and the one that appears to have the widest support of payment gateways. We p...
Why can't I use expressions when defining class properties?
It always bugged me, but I never knew the reason behind this behaviour. For example: $enabled = true; class Test { public $value0 = true; // Valid public $value1 = $enabled; // Not valid, as pointed by BTMPL public $value2 = !$enabled; // Not valid public $value3 = some_func(); // Not valid }
r/firstworldproblems: I'm missing all the benefits of the ternary shortcut because undefined vars keep throwing notices
I wish undefined vars and array indexes wouldn't throw notices, but instead return a null value, so I could use: $test = array('name' => "John"); print $test['surname'] ?: "No surname";
Is there a way to extend an existing class without creating a new one?
I always use class myobj extends myobj_default, but I'd want something like Javascript's prototype. I have some objects that may or may not be extended, so it would be a mess to have 20 object_default and then create the extended object. Any ideas? Update: First of all, sorry for not answering your...
How do you remember a user login?
If a user marks the option "Remember me", I generate a md5 identifier and store it in his/her account and in a cookie. Problem is, only one browser can be remembered at a time as I generate the identifier on the fly. If the same user wants to be remembered on another browser or computer, should I gi...
End of this list.
Back to top