rackspace/php-opencloud — pull request #396 by ycombinator (2014-09-15 19:03:05+00:00)
Title: Allow null logger

When new nodes are added to an existing load balancer using the [`addNode` method of the LoadBalancer class](https://github.com/rackspace/php-opencloud/blob/working/lib/OpenCloud/LoadBalancer/Resource/LoadBalancer.php#L198-L238), no `logger` property is set for the new node objects (i.e. the `logger` property has the value `null`).

Subsequently, when the [`addNodes` method of the LoadBalancer class](https://github.com/rackspace/php-opencloud/blob/working/lib/OpenCloud/LoadBalancer/Resource/LoadBalancer.php#L246-L261) is called, each node object is repopulated.

During this repopulation, the [`setProperty` method of the `Base` class](https://github.com/rackspace/php-opencloud/blob/working/lib/OpenCloud/Common/Base.php#L106-L133) is called with arguments `"logger"` and `null`. This, in turn, calls the [`setLogger` method of the `Base` class](https://github.com/rackspace/php-opencloud/blob/working/lib/OpenCloud/Common/Base.php#L248-L253) with the argument `null`. Since this argument has the type hint `OpenCloud\Common\LoggerInterface`, it fails with this error: `Argument 1 passed to OpenCloud\Common\Base::setLogger() must implement interface Psr\Log\LoggerInterface, null given`.

This PR allows the argument to `setLogger` to be nullable, thereby allowing repopulation of objects that have no logger set.