Skip to content

Commit aec5acd

Browse files
committed
CS Fix
1 parent 450ce8a commit aec5acd

File tree

7 files changed

+145
-131
lines changed

7 files changed

+145
-131
lines changed

.php_cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
$config = new SlamCsFixer\Config(SlamCsFixer\Config::LIB);
4+
$config->getFinder()
5+
->in(__DIR__ . '/lib')
6+
->in(__DIR__ . '/tests')
7+
;
8+
9+
return $config;

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ matrix:
66
fast_finish: true
77
include:
88
- php: 7.1
9+
env: CS_CHECK=1
910
- php: 7.2
1011
env: CODE_COVERAGE=1
1112

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"require-dev": {
2323
"doctrine/common": "^2.9",
2424
"phpunit/phpunit": "^7.2",
25-
"roave/security-advisories": "dev-master"
25+
"roave/security-advisories": "dev-master",
26+
"slam/php-cs-fixer-extensions": "^1.16"
2627
}
2728
}

lib/Doctrine/Debug.php

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
<?php
2+
3+
declare(strict_types=1);
4+
25
namespace Slam\Debug\Doctrine
36
{
4-
57
use Doctrine\Common\Collections\Collection;
68
use Doctrine\Common\Persistence\Proxy;
79

810
/**
911
* Static class containing most used debug methods.
1012
*
11-
* @link www.doctrine-project.org
13+
* @see www.doctrine-project.org
1214
* @since 2.0
15+
*
1316
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
1417
* @author Jonathan Wage <jonwage@gmail.com>
1518
* @author Roman Borschel <roman@code-factory.org>
1619
* @author Giorgio Sironi <piccoloprincipeazzurro@gmail.com>
1720
*
18-
* @deprecated The Debug class is deprecated, please use symfony/var-dumper instead.
21+
* @deprecated the Debug class is deprecated, please use symfony/var-dumper instead
1922
*/
2023
final class Debug
2124
{
@@ -29,39 +32,39 @@ private function __construct()
2932
/**
3033
* Prints a dump of the public, protected and private properties of $var.
3134
*
32-
* @link https://xdebug.org/
35+
* @see https://xdebug.org/
3336
*
34-
* @param mixed $var The variable to dump.
35-
* @param integer $maxDepth The maximum nesting level for object properties.
36-
* @param boolean $stripTags Whether output should strip HTML tags.
37-
* @param boolean $echo Send the dumped value to the output buffer
37+
* @param mixed $var the variable to dump
38+
* @param int $maxDepth the maximum nesting level for object properties
39+
* @param bool $stripTags whether output should strip HTML tags
40+
* @param bool $echo Send the dumped value to the output buffer
3841
*
3942
* @return string
4043
*/
4144
public static function dump($var, $maxDepth = 2, $stripTags = true, $echo = true)
4245
{
43-
$html = ini_get('html_errors');
46+
$html = \ini_get('html_errors');
4447

45-
if ($html !== true) {
46-
ini_set('html_errors', true);
48+
if (true !== $html) {
49+
\ini_set('html_errors', true);
4750
}
4851

49-
if (extension_loaded('xdebug')) {
50-
ini_set('xdebug.var_display_max_depth', $maxDepth);
52+
if (\extension_loaded('xdebug')) {
53+
\ini_set('xdebug.var_display_max_depth', $maxDepth);
5154
}
5255

5356
$var = self::export($var, $maxDepth);
5457

55-
ob_start();
56-
var_dump($var);
58+
\ob_start();
59+
\var_dump($var);
5760

58-
$dump = ob_get_contents();
61+
$dump = \ob_get_contents();
5962

60-
ob_end_clean();
63+
\ob_end_clean();
6164

62-
$dumpText = ($stripTags ? strip_tags(html_entity_decode($dump)) : $dump);
65+
$dumpText = ($stripTags ? \strip_tags(\html_entity_decode($dump)) : $dump);
6366

64-
ini_set('html_errors', $html);
67+
\ini_set('html_errors', $html);
6568

6669
if ($echo) {
6770
echo $dumpText;
@@ -79,18 +82,18 @@ public static function dump($var, $maxDepth = 2, $stripTags = true, $echo = true
7982
public static function export($var, $maxDepth)
8083
{
8184
$return = null;
82-
$isObj = is_object($var);
85+
$isObj = \is_object($var);
8386

8487
if ($var instanceof Collection) {
8588
$var = $var->toArray();
8689
}
8790

88-
if ( ! $maxDepth) {
89-
return is_object($var) ? get_class($var)
90-
: (is_array($var) ? 'Array(' . count($var) . ')' : $var);
91+
if (! $maxDepth) {
92+
return \is_object($var) ? \get_class($var)
93+
: (\is_array($var) ? 'Array(' . \count($var) . ')' : $var);
9194
}
9295

93-
if (is_array($var)) {
96+
if (\is_array($var)) {
9497
$return = [];
9598

9699
foreach ($var as $k => $v) {
@@ -100,13 +103,13 @@ public static function export($var, $maxDepth)
100103
return $return;
101104
}
102105

103-
if ( ! $isObj) {
106+
if (! $isObj) {
104107
return $var;
105108
}
106109

107110
$return = new \stdclass();
108111
if ($var instanceof \DateTimeInterface) {
109-
$return->__CLASS__ = get_class($var);
112+
$return->__CLASS__ = \get_class($var);
110113
$return->date = $var->format('c');
111114
$return->timezone = $var->getTimezone()->getName();
112115

@@ -129,26 +132,25 @@ public static function export($var, $maxDepth)
129132

130133
/**
131134
* Fill the $return variable with class attributes
132-
* Based on obj2array function from {@see https://secure.php.net/manual/en/function.get-object-vars.php#47075}
135+
* Based on obj2array function from {@see https://secure.php.net/manual/en/function.get-object-vars.php#47075}.
133136
*
134-
* @param object $var
137+
* @param object $var
135138
* @param \stdClass $return
136-
* @param int $maxDepth
139+
* @param int $maxDepth
137140
*
138141
* @return mixed
139142
*/
140143
private static function fillReturnWithClassAttributes($var, \stdClass $return, $maxDepth)
141144
{
142145
$clone = (array) $var;
143146

144-
foreach (array_keys($clone) as $key) {
145-
$aux = explode("\0", $key);
146-
$name = end($aux);
147-
if ($aux[0] === '') {
148-
$name .= ':' . ($aux[1] === '*' ? 'protected' : $aux[1] . ':private');
147+
foreach (\array_keys($clone) as $key) {
148+
$aux = \explode("\0", $key);
149+
$name = \end($aux);
150+
if ('' === $aux[0]) {
151+
$name .= ':' . ('*' === $aux[1] ? 'protected' : $aux[1] . ':private');
149152
}
150-
$return->$name = self::export($clone[$key], $maxDepth - 1);
151-
;
153+
$return->{$name} = self::export($clone[$key], $maxDepth - 1);
152154
}
153155

154156
return $return;
@@ -163,7 +165,7 @@ private static function fillReturnWithClassAttributes($var, \stdClass $return, $
163165
*/
164166
public static function toString($obj)
165167
{
166-
return method_exists($obj, '__toString') ? (string) $obj : get_class($obj) . '@' . spl_object_hash($obj);
168+
return \method_exists($obj, '__toString') ? (string) $obj : \get_class($obj) . '@' . \spl_object_hash($obj);
167169
}
168170
}
169171
}

lib/r.php

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ private function __construct()
4343

4444
public static function debug($var, bool $exit = true, int $level = 0, bool $fullstack = false): void
4545
{
46-
if (null === $var or \is_scalar($var)) {
46+
if (null === $var || \is_scalar($var)) {
4747
\ob_start();
4848
\var_dump($var);
4949
$output = \trim(\ob_get_clean());
@@ -107,14 +107,15 @@ private static function formatDb(bool $fullstack): string
107107
/**
108108
* Static class containing most used debug methods.
109109
*
110-
* @link www.doctrine-project.org
110+
* @see www.doctrine-project.org
111111
* @since 2.0
112+
*
112113
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
113114
* @author Jonathan Wage <jonwage@gmail.com>
114115
* @author Roman Borschel <roman@code-factory.org>
115116
* @author Giorgio Sironi <piccoloprincipeazzurro@gmail.com>
116117
*
117-
* @deprecated The Debug class is deprecated, please use symfony/var-dumper instead.
118+
* @deprecated the Debug class is deprecated, please use symfony/var-dumper instead
118119
*/
119120
final class Debug
120121
{
@@ -128,31 +129,31 @@ private function __construct()
128129
/**
129130
* Prints a dump of the public, protected and private properties of $var.
130131
*
131-
* @link https://xdebug.org/
132+
* @see https://xdebug.org/
132133
*
133-
* @param mixed $var The variable to dump.
134-
* @param integer $maxDepth The maximum nesting level for object properties.
135-
* @param boolean $stripTags Whether output should strip HTML tags.
136-
* @param boolean $echo Send the dumped value to the output buffer
134+
* @param mixed $var the variable to dump
135+
* @param int $maxDepth the maximum nesting level for object properties
136+
* @param bool $stripTags whether output should strip HTML tags
137+
* @param bool $echo Send the dumped value to the output buffer
137138
*
138139
* @return string
139140
*/
140141
public static function dump($var, $maxDepth = 2, $stripTags = true, $echo = true)
141142
{
142-
if (extension_loaded('xdebug')) {
143-
ini_set('xdebug.var_display_max_depth', $maxDepth);
143+
if (\extension_loaded('xdebug')) {
144+
\ini_set('xdebug.var_display_max_depth', $maxDepth);
144145
}
145146

146147
$var = self::export($var, $maxDepth);
147148

148-
ob_start();
149-
var_dump($var);
149+
\ob_start();
150+
\var_dump($var);
150151

151-
$dump = ob_get_contents();
152+
$dump = \ob_get_contents();
152153

153-
ob_end_clean();
154+
\ob_end_clean();
154155

155-
$dumpText = ($stripTags ? strip_tags(html_entity_decode($dump)) : $dump);
156+
$dumpText = ($stripTags ? \strip_tags(\html_entity_decode($dump)) : $dump);
156157

157158
if ($echo) {
158159
echo $dumpText;
@@ -170,18 +171,18 @@ public static function dump($var, $maxDepth = 2, $stripTags = true, $echo = true
170171
public static function export($var, $maxDepth)
171172
{
172173
$return = null;
173-
$isObj = is_object($var);
174+
$isObj = \is_object($var);
174175

175176
if ($var instanceof Collection) {
176177
$var = $var->toArray();
177178
}
178179

179-
if ( ! $maxDepth) {
180-
return is_object($var) ? get_class($var)
181-
: (is_array($var) ? 'Array(' . count($var) . ')' : $var);
180+
if (! $maxDepth) {
181+
return \is_object($var) ? \get_class($var)
182+
: (\is_array($var) ? 'Array(' . \count($var) . ')' : $var);
182183
}
183184

184-
if (is_array($var)) {
185+
if (\is_array($var)) {
185186
$return = [];
186187

187188
foreach ($var as $k => $v) {
@@ -191,13 +192,13 @@ public static function export($var, $maxDepth)
191192
return $return;
192193
}
193194

194-
if ( ! $isObj) {
195+
if (! $isObj) {
195196
return $var;
196197
}
197198

198199
$return = new \stdclass();
199200
if ($var instanceof \DateTimeInterface) {
200-
$return->__CLASS__ = get_class($var);
201+
$return->__CLASS__ = \get_class($var);
201202
$return->date = $var->format('c');
202203
$return->timezone = $var->getTimezone()->getName();
203204

@@ -220,25 +221,25 @@ public static function export($var, $maxDepth)
220221

221222
/**
222223
* Fill the $return variable with class attributes
223-
* Based on obj2array function from {@see https://secure.php.net/manual/en/function.get-object-vars.php#47075}
224+
* Based on obj2array function from {@see https://secure.php.net/manual/en/function.get-object-vars.php#47075}.
224225
*
225-
* @param object $var
226+
* @param object $var
226227
* @param \stdClass $return
227-
* @param int $maxDepth
228+
* @param int $maxDepth
228229
*
229230
* @return mixed
230231
*/
231232
private static function fillReturnWithClassAttributes($var, \stdClass $return, $maxDepth)
232233
{
233234
$clone = (array) $var;
234235

235-
foreach (array_keys($clone) as $key) {
236-
$aux = explode("\0", (string) $key);
237-
$name = end($aux);
238-
if ($aux[0] === '') {
239-
$name .= ':' . ($aux[1] === '*' ? 'protected' : $aux[1] . ':private');
236+
foreach (\array_keys($clone) as $key) {
237+
$aux = \explode("\0", (string) $key);
238+
$name = \end($aux);
239+
if ('' === $aux[0]) {
240+
$name .= ':' . ('*' === $aux[1] ? 'protected' : $aux[1] . ':private');
240241
}
241-
$return->$name = self::export($clone[$key], $maxDepth - 1);
242+
$return->{$name} = self::export($clone[$key], $maxDepth - 1);
242243
}
243244

244245
return $return;
@@ -253,11 +254,11 @@ private static function fillReturnWithClassAttributes($var, \stdClass $return, $
253254
*/
254255
private static function getRealClass($class)
255256
{
256-
if (! class_exists(Proxy::class) || false === ($pos = strrpos($class, '\\' . Proxy::MARKER . '\\'))) {
257+
if (! \class_exists(Proxy::class) || false === ($pos = \strrpos($class, '\\' . Proxy::MARKER . '\\'))) {
257258
return $class;
258259
}
259260

260-
return substr($class, $pos + Proxy::MARKER_LENGTH + 2);
261+
return \substr($class, $pos + Proxy::MARKER_LENGTH + 2);
261262
}
262263

263264
/**
@@ -269,7 +270,7 @@ private static function getRealClass($class)
269270
*/
270271
private static function getClass($object)
271272
{
272-
return self::getRealClass(get_class($object));
273+
return self::getRealClass(\get_class($object));
273274
}
274275
}
275276
}

0 commit comments

Comments
 (0)