Skip to content

Commit b1a7108

Browse files
committed
Minor fixes
1 parent a384225 commit b1a7108

18 files changed

+213
-173
lines changed

.github/img/simple-mode.png

13.2 KB
Loading

composer.json

+3-11
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
11
{
22
"name": "php-sage/sage",
33
"description": "☯ Insightful PHP debugging assistant.",
4-
"keywords": [
5-
"sage",
6-
"php",
7-
"debug",
8-
"dump",
9-
"var_dup",
10-
"debug_backtrace",
11-
"json_decode"
12-
],
4+
"keywords": ["sage", "php", "dumper", "debug", "dump", "var_dup", "debug_backtrace", "json_decode"],
135
"type": "library",
14-
"homepage": "https://github.com/phpsage/sage",
6+
"homepage": "https://github.com/php-sage/sage",
157
"license": "MIT",
168
"authors": [
179
{
@@ -20,7 +12,7 @@
2012
},
2113
{
2214
"name": "Contributors",
23-
"homepage": "https://github.com/phpsage/sage/contributors"
15+
"homepage": "https://github.com/php-sage/sage/contributors"
2416
}
2517
],
2618
"require": {

decorators/SageDecoratorsPlain.php

+8-28
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public static function decorateTrace($traceData)
102102

103103
if (! empty($step['object'])) {
104104
$output .= self::_colorize(
105-
' ' . self::_char('', 27) . ' Callee object ' . self::_char('', 34),
105+
' ' . str_repeat('', 27) . ' Callee object ' . str_repeat('', 34),
106106
'title'
107107
);
108108

@@ -120,7 +120,7 @@ public static function decorateTrace($traceData)
120120
}
121121

122122
if ($stepNo !== $lastStep) {
123-
$output .= self::_colorize(self::_char('', 80), 'title');
123+
$output .= self::_colorize(str_repeat('', 80), 'title');
124124
}
125125
}
126126

@@ -175,45 +175,29 @@ private static function _colorize($text, $type, $nlAfter = true)
175175
}
176176
}
177177

178-
private static function _char($char, $repeat = null)
179-
{
180-
return $repeat ? str_repeat($char, $repeat) : $char;
181-
}
182-
183178
private static function _title($text)
184179
{
185180
$escaped = SageHelper::decodeStr($text);
186181
$lengthDifference = strlen($escaped) - strlen($text);
187182

188183
return
189-
self::_colorize(
190-
self::_char('') . self::_char('', 78) . self::_char('') . PHP_EOL
191-
. self::_char(''),
192-
'title',
193-
false
194-
)
195-
184+
self::_colorize('' . str_repeat('', 78) . '' . PHP_EOL . '', 'title', false)
196185
. self::_colorize(str_pad($escaped, 78 + $lengthDifference, ' ', STR_PAD_BOTH), 'title', false)
197-
198-
. self::_colorize(
199-
self::_char('') . PHP_EOL
200-
. self::_char('') . self::_char('', 78) . self::_char(''),
201-
'title'
202-
);
186+
. self::_colorize('' . PHP_EOL . '' . str_repeat('', 78) . '', 'title');
203187
}
204188

205189
public static function wrapStart()
206190
{
207191
if (Sage::enabled() === Sage::MODE_PLAIN) {
208-
return '<pre class="-_sage">';
192+
return '<pre class="_sage">';
209193
}
210194

211195
return '';
212196
}
213197

214198
public static function wrapEnd($callee, $miniTrace, $prevCaller)
215199
{
216-
$lastLine = self::_colorize(self::_char("", 80), 'title');
200+
$lastLine = self::_colorize(str_repeat('', 80), 'title');
217201
$lastChar = Sage::enabled() === Sage::MODE_PLAIN ? '</pre>' : '';
218202

219203
if (! Sage::$displayCalledFrom) {
@@ -251,11 +235,7 @@ private static function _drawHeader(SageVariableData $varData)
251235
}
252236

253237
if ($varData->value !== null && $varData->value !== '') {
254-
$output .= ' ' . self::_colorize(
255-
$varData->value, // escape shell
256-
'value',
257-
false
258-
);
238+
$output .= ' ' . self::_colorize($varData->value, 'value', false);
259239
}
260240

261241
return ltrim($output);
@@ -280,7 +260,7 @@ function_exists('sapi_windows_vt100_support')
280260
}
281261

282262
return Sage::enabled() === Sage::MODE_PLAIN
283-
? '<style>.-_sage i{color:#d00;font-style:normal}.-_sage u{color:#030;text-decoration:none;font-weight:bold}</style>'
263+
? '<style>._sage i{color:#d00;font-style:normal}._sage u{color:#030;text-decoration:none;font-weight:bold}</style>'
284264
: '';
285265
}
286266
}

decorators/SageDecoratorsRich.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,8 @@ public static function init()
270270
}
271271

272272
return
273-
'<script class="-_sage-js">' . file_get_contents($baseDir . 'sage.js') . '</script>'
274-
. '<style class="-_sage-css">' . file_get_contents($cssFile) . "</style>\n";
273+
'<script class="_sage-js">' . file_get_contents($baseDir . 'sage.js') . '</script>'
274+
. '<style class="_sage-css">' . file_get_contents($cssFile) . "</style>\n";
275275
}
276276

277277
private static function decorateAlternativeView($alternative)

phpunit.xml

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
44
bootstrap="vendor/autoload.php"
5+
cacheResult="false"
56
colors="true"
67
>
78
<testsuites>

resources/base.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ if (typeof _sageInitialized === 'undefined') {
157157
+ _sage.tag('head')
158158
+ '<title>Sage ☯ (' + new Date().toISOString() + ')</title>'
159159
+ _sage.tag('meta charset="utf-8"')
160-
+ document.getElementsByClassName('-_sage-js')[0].outerHTML
161-
+ document.getElementsByClassName('-_sage-css')[0].outerHTML
160+
+ document.getElementsByClassName('_sage-js')[0].outerHTML
161+
+ document.getElementsByClassName('_sage-css')[0].outerHTML
162162
+ _sage.tag('/head')
163163
+ _sage.tag('body')
164164
+ '<input style="width: 100%" placeholder="Take some notes!">'
@@ -430,4 +430,4 @@ function clg(i) {
430430
const l = arguments.length;
431431
let o = 0;
432432
while (o < l) console.log(arguments[o++])
433-
}
433+
}

resources/compiled/sage.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/Pest.php

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
uses()
4+
->beforeEach(function() {
5+
Sage::$returnOutput = true;
6+
Sage::$expandedByDefault = true;
7+
})
8+
->in('all')
9+
;
10+
11+
function assertSageSnapshot($sageOutput)
12+
{
13+
Spatie\Snapshots\assertMatchesHtmlSnapshot(
14+
'<meta charset="utf-8">' . $sageOutput
15+
);
16+
}

0 commit comments

Comments
 (0)