Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions doc/api/Definition/Item.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,11 @@ Item::getDefault($escape)

Name|Type|Description
----|----|-----------
$escape|[bool][php:bool]|Whether the special chars should be escaped<br/>
$escape|[bool][php:bool]|Whether the special chars should be escaped (default: `false`)<br/>

#### Return value

_Either the escaped or raw value_

> type: [mixed][php:mixed]

Expand Down Expand Up @@ -395,4 +396,4 @@ $hasDefault|[bool][php:bool]|

[&laquo; Back to Table Of Contents](/doc/api/index.md)

<!-- Generated: 2025-11-17 17:34:10 +01:00 -->
<!-- Generated: 2025-11-18 12:05:19 +01:00 -->
10 changes: 8 additions & 2 deletions src/Definition/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,14 @@ public function getType()
/**
* Getter for the item default value
*
* @param bool $escape Whether the special chars should be escaped
* @param bool $escape Whether the special chars should be escaped (default: `false`)
*
* @return mixed
* @return mixed Either the escaped or raw value
*/
public function getDefault($escape = false)
{
$default = $this->default;

return $escape ? $this->escape($default) : $default;
}

Expand Down Expand Up @@ -176,6 +177,11 @@ public function setHasDefault($hasDefault)
*/
public function escape($value)
{
// Special use-case: handle backslash character
if ($value == '\\') {
return '"\\\\"';
}

return str_replace(
["\r", "\n", "\t"],
['"\r"', '"\n"', '"\t"'],
Expand Down
Loading