Skip to content

Commit 43989ec

Browse files
committed
IMP: Whitespace fixes incl. indents.
1 parent e1a3955 commit 43989ec

File tree

15 files changed

+223
-226
lines changed

15 files changed

+223
-226
lines changed

docs/TODO

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@
2626
(?) Value Interface: add public function setParsed(array $parsed); (clash-
2727
es Parser)
2828
(?) Any chance to see RECURSION INDECIES numerically validated?
29-
- numeric index en parallel to parsing referencing array notations
30-
- own recursion validator/resolver class
29+
- numeric index en parallel to parsing referencing array notations
30+
- own recursion validator/resolver class

examples/01-hello-world/example-dump-a-simple.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
require_once(__DIR__.'/../../src/Serialized.php');
3030

3131
$data = array(
32-
'foo' => 1,
33-
'bar' => range(2,20,3),
32+
'foo' => 1,
33+
'bar' => range(2,20,3),
3434
'baz' => new Parser
3535
);
3636

@@ -42,9 +42,5 @@
4242

4343
// dump with default dumper (text) on array notation
4444
Dumper::factory()->dump(
45-
Parser::parse(
46-
serialize(
47-
range(1,10)
48-
)
49-
)
45+
Parser::parse(serialize(range(1,10)))
5046
);

examples/serialized.dtd

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<http://www.gnu.org/licenses/> and please report back to the original
2020
author.
2121

22-
============
22+
============
2323

2424
This is Serialized DTD.
2525

@@ -49,34 +49,34 @@
4949
<!--====== named values ======-->
5050

5151
<!ENTITY % Int "CDATA" >
52-
<!-- an integer value -->
52+
<!-- an integer value -->
5353

5454
<!ENTITY % AbsInt "%Int;" >
55-
<!-- a positive integer value or 0 -->
55+
<!-- a positive integer value or 0 -->
5656

5757
<!ENTITY % PositiveInt "%Int;" >
58-
<!-- a positive integer value greater 0 -->
58+
<!-- a positive integer value greater 0 -->
5959

6060
<!ENTITY % Count "%AbsInt;" >
61-
<!-- Count, 0 or positive integer -->
61+
<!-- Count, 0 or positive integer -->
6262

6363
<!ENTITY % Bool "(true|false)" >
64-
<!-- a boolean value -->
64+
<!-- a boolean value -->
6565

6666
<!ENTITY % Float "CDATA" >
67-
<!-- a float value -->
67+
<!-- a float value -->
6868

6969
<!ENTITY % Strlen "%AbsInt;" >
70-
<!-- Length of a string, 0 or positive integer -->
70+
<!-- Length of a string, 0 or positive integer -->
7171

7272
<!ENTITY % Ref "%PositiveInt;" >
73-
<!-- Reference index of/to an existing element, a positive integer -->
73+
<!-- Reference index of/to an existing element, a positive integer -->
7474

7575
<!ENTITY % KeyType "(string|int)" >
76-
<!-- Array keys can be either string or integer -->
76+
<!-- Array keys can be either string or integer -->
7777

7878
<!ENTITY % PropAccess "(public|protected|private)" >
79-
<!-- Property Access can either be public, protected or private -->
79+
<!-- Property Access can either be public, protected or private -->
8080

8181
<!--====== root ======-->
8282

examples/serialized.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<http://www.gnu.org/licenses/> and please report back to the original
2121
author.
2222
23-
============
23+
============
2424
2525
This is a XML dump of a more complex serialized array created
2626
with Serialized and the XML Dumper.

examples/session.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<http://www.gnu.org/licenses/> and please report back to the original
2121
author.
2222
23-
============
23+
============
2424
2525
This is a XML dump of a more complex serialized array created
2626
with Serialized and the XML Dumper.

src/Serialized.php

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,17 @@ public static function fileNameOfClassName($className) {
4646
$classNameSeparator = '_';
4747
$fileSuffix = '.php';
4848

49-
$lineup = explode($nameSpaceSeparator, $className);
50-
if(!count($lineup) || !$lineup[0]) {
51-
throw new \InvalidArgumentException(sprintf('%s is not a valid classname.', $className));
52-
}
53-
$nonNamespacedClassName = array_pop($lineup);
54-
if(!$nonNamespacedClassName) {
55-
throw new \InvalidArgumentException(sprintf('%s is not a valid classname.', $className));
56-
}
57-
$lineup[] = str_replace($classNameSeparator, DIRECTORY_SEPARATOR, $nonNamespacedClassName);
58-
$fileName = implode(DIRECTORY_SEPARATOR, $lineup) . $fileSuffix;
59-
return $fileName;
49+
$lineup = explode($nameSpaceSeparator, $className);
50+
if(!count($lineup) || !$lineup[0]) {
51+
throw new \InvalidArgumentException(sprintf('%s is not a valid classname.', $className));
52+
}
53+
$nonNamespacedClassName = array_pop($lineup);
54+
if(!$nonNamespacedClassName) {
55+
throw new \InvalidArgumentException(sprintf('%s is not a valid classname.', $className));
56+
}
57+
$lineup[] = str_replace($classNameSeparator, DIRECTORY_SEPARATOR, $nonNamespacedClassName);
58+
$fileName = implode(DIRECTORY_SEPARATOR, $lineup) . $fileSuffix;
59+
return $fileName;
6060
}
6161
public static function autoloadCallback() {
6262
return array(get_called_class(), 'loadClass');
@@ -74,7 +74,8 @@ public static function autoloadRegistered() {
7474
$autoloadCallback = self::autoloadCallback();
7575
$autoloadFunctions = spl_autoload_functions();
7676
$registered = in_array($autoloadCallback, $autoloadFunctions, true)
77-
|| in_array(get_called_class().'::loadClass', $autoloadFunctions, true);
77+
|| in_array(get_called_class().'::loadClass', $autoloadFunctions, true)
78+
;
7879
return $registered;
7980
}
8081
/**
@@ -105,9 +106,9 @@ public static function loadLibrary() {
105106
* @return bool did require(class)
106107
*/
107108
public static function loadClass($className) {
108-
if (strpos($className, get_called_class().'\\') !== 0) {
109-
return false;
110-
}
109+
if (strpos($className, get_called_class().'\\') !== 0) {
110+
return false;
111+
}
111112
$fileName = self::fileNameOfClassName($className);
112113
if (self::undefined($className)) {
113114
require($fileName);

src/Serialized/Dumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ abstract protected function dumpConcrete(array $parsed);
182182
*/
183183
public static function factory($type = null, array $config = array()) {
184184
if (!is_string($type) && null !== $type) {
185-
throw new InvalidArgumentException(sprintf('Type expected be string, %s given.', gettype($type)));
185+
throw new InvalidArgumentException(sprintf('Type expected string, %s given (%s).', gettype($type), $type));
186186
}
187187
null === $type && $type = 'text';
188188
$dumperClass = ucfirst(strtolower($type));

src/Serialized/Dumper/Text.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -118,17 +118,17 @@ private function dumpVariables($value) {
118118
private function phpEncodeString($string) {
119119
static $seq = array(0x09 => 't', 0x0A => 'n', 0x0B => 'v', 0x0C => 'f', 0x0D => 'r');
120120
for(
121-
$r = '',
122-
$l = strlen($string),
123-
$i = 0
124-
;
125-
$i < $l
126-
;
127-
$c = $string[$i++],
128-
$o = ord($c),
129-
($f = 0x08 < $o && $o < 0x0E) && $c = $seq[$o],
130-
($b = $f || (0x1F < $o && $o < 0x7F)) && ($f || 0x22 === $o || 0x24 === $o || 0x5C === $o) && $c = '\\'.$c,
131-
$r.= $b ? $c : '\x'.strtoupper(substr('0'.dechex($o),-2))
121+
$r = '',
122+
$l = strlen($string),
123+
$i = 0
124+
;
125+
$i < $l
126+
;
127+
$c = $string[$i++],
128+
$o = ord($c),
129+
($f = 0x08 < $o && $o < 0x0E) && $c = $seq[$o],
130+
($b = $f || (0x1F < $o && $o < 0x7F)) && ($f || 0x22 === $o || 0x24 === $o || 0x5C === $o) && $c = '\\'.$c,
131+
$r.= $b ? $c : '\x'.strtoupper(substr('0'.dechex($o),-2))
132132
);
133133
return $r;
134134
}

src/Serialized/Dumper/XML.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,17 @@ protected function statePush() {
6464
private function xmlAttributeEncode($string) {
6565
static $seq = array(0x22 => 'quot', 0x26 => 'amp', 0x3c => 'lt', 0x3e => 'gt');
6666
for(
67-
$r = '',
68-
$l = strlen($string),
69-
$i = 0
70-
;
71-
$i < $l
72-
;
73-
$c = $string[$i++],
74-
$o = ord($c),
75-
$h = dechex($o),
76-
($f = (0x22 === $o || 0x26 === $o || 0x3c === $o || 0x3e === $o)) && $c = '&'.$seq[$o].';',
77-
$r.= ($f || (0x1F < $o && $o < 0x7F)) ? $c : '&#x'.strtoupper(dechex($o)).';'
67+
$r = '',
68+
$l = strlen($string),
69+
$i = 0
70+
;
71+
$i < $l
72+
;
73+
$c = $string[$i++],
74+
$o = ord($c),
75+
$h = dechex($o),
76+
($f = (0x22 === $o || 0x26 === $o || 0x3c === $o || 0x3e === $o)) && $c = '&'.$seq[$o].';',
77+
$r.= ($f || (0x1F < $o && $o < 0x7F)) ? $c : '&#x'.strtoupper(dechex($o)).';'
7878
);
7979
return $r;
8080
}

0 commit comments

Comments
 (0)