Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit 62508de

Browse files
committed
Implement Debug.exit() and Debug.die()
1 parent 0332cd8 commit 62508de

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

Classes/Debug.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,22 @@ public function fusionPath(AbstractFusionObject $fusionObject): string
8888
return $pathReflectionProperty->getValue($fusionObject);
8989
}
9090

91+
/**
92+
* @return void
93+
*/
94+
public function exit(): void
95+
{
96+
exit($this->buffer);
97+
}
98+
99+
/**
100+
* @return void
101+
*/
102+
public function die(): void
103+
{
104+
die($this->buffer);
105+
}
106+
91107
/**
92108
* @return string
93109
*/

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
> Provides simple methods to debug stuff in Fusion
44
5+
This package allows you to debug values in fusion as simple as:
6+
7+
```fusion
8+
debug = ${Debug.var_dump(node).var_dump(request).die()}
9+
```
510

611
## ⚠⚠⚠ Still under development ⚠⚠⚠
712

@@ -107,6 +112,24 @@ fusionPath = ${Debug.var_dump(Debug.fusionPath(this))}
107112

108113
* **$fusionObject : AbstractFusionObject** - The fusion object to get the fusion path from (when in doubt, use `this`)
109114

115+
## Interrupting program execution
116+
117+
### exit
118+
119+
You can use `Debug.exit()` to stop execution of the PHP Script entirely (just as with the `exit` function of the PHP standard library).
120+
121+
`Debug.exit()` takes no parameters.
122+
123+
`Debug.exit()` can be used in any chain of `Debug.var_dump(...)`, `Debug.print_r(...)`, `Debug.var_export(...)` or `Debug.xdebug_var_dump(...)` calls:
124+
125+
```fusion
126+
debug = ${Debug.var_dump(node).var_dump(request).die()}
127+
```
128+
129+
### die
130+
131+
`Debug.die()` is an alias for `Debug.exit()`.
132+
110133
## Contribution
111134

112135
We will gladly accept contributions. Please send us pull requests.

0 commit comments

Comments
 (0)