Skip to content

Commit

Permalink
Added support for null inserts
Browse files Browse the repository at this point in the history
  • Loading branch information
jaxwilko committed Dec 2, 2021
1 parent 0581fc6 commit a010a9c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/Config/ConfigFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,6 @@ public function set($key, $value = null): ConfigFile
return $this;
}

if ($key && is_null($value)) {
throw new ApplicationException('You must specify a value to set for the given key.');
}

// try to find a reference to ast object
list($target, $remaining) = $this->seek(explode('.', $key), $this->ast[0]->expr);

Expand Down Expand Up @@ -178,7 +174,7 @@ protected function makeArrayItem(string $key, string $valueType, $value): ArrayI
*/
protected function makeAstNode(string $type, $value)
{
switch ($type) {
switch (strtolower($type)) {
case 'string':
return new String_($value);
case 'boolean':
Expand All @@ -192,6 +188,9 @@ protected function makeAstNode(string $type, $value)
return new Arg($this->makeAstNode(gettype($arg), $arg));
}, $value->getArgs())
);
case 'null':
return new ConstFetch(new Name('null'));
break;
default:
throw new \RuntimeException('not implemented replacement type: ' . $type);
}
Expand Down

0 comments on commit a010a9c

Please sign in to comment.