Skip to content

Commit

Permalink
Less strict types (#72)
Browse files Browse the repository at this point in the history
* Nullable values

* Set nullable values to empty strings
  • Loading branch information
g105b authored Jul 17, 2019
1 parent ebf2a97 commit 0d4ce7d
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Bindable.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ trait Bindable {
/**
* Alias of bindKeyValue.
*/
public function bind(?string $key, string $value):void {
public function bind(?string $key, ?string $value):void {
$this->bindKeyValue($key, $value);
}

Expand All @@ -26,8 +26,12 @@ public function bind(?string $key, string $value):void {
*/
public function bindKeyValue(
?string $key,
string $value
?string $value
):void {
if(is_null($value)) {
$value = "";
}

$this->injectBoundProperty($key, $value);
$this->injectAttributePlaceholder($key, $value);
}
Expand All @@ -37,7 +41,7 @@ public function bindKeyValue(
* attribute vale. For example, <p data-bind:text>Your text here</p>
* does not have an addressable attribute value for data-bind:text.
*/
public function bindValue(string $value):void {
public function bindValue(?string $value):void {
$this->bindKeyValue(null, $value);
// Note, it's impossible to inject attribute placeholders without a key.
}
Expand Down Expand Up @@ -157,7 +161,7 @@ public function bindNestedList(
*/
protected function injectBoundProperty(
?string $key,
string $value
?string $value
):void {
$children = $this->getChildrenWithBindAttribute();

Expand Down

0 comments on commit 0d4ce7d

Please sign in to comment.