Skip to content

Commit 6b5fda4

Browse files
committed
Address readme issues
1 parent 9c8aaf8 commit 6b5fda4

File tree

2 files changed

+52
-45
lines changed

2 files changed

+52
-45
lines changed

README.md

Lines changed: 47 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ provides more options to customize the output, which makes it easier to generate
77
code for different kinds of purposes such as readable configuration files or
88
optimized cache files.
99

10-
The purpose of this library is to address some of the shortcomings with the
10+
The purpose of this library is to address some of the shortcomings with the
1111
built in `var_export()`. For example, there is no way to control the amount of
1212
whitespace in the output and there is no way to choose between different array
1313
notations. This library also provides functionality to convert objects into PHP
@@ -24,13 +24,15 @@ at: http://kit.riimu.net/api/phpencoder/
2424
[![Build Status](https://img.shields.io/travis/Riimu/Kit-PHPEncoder.svg?style=flat)](https://travis-ci.org/Riimu/Kit-PHPEncoder)
2525
[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/Riimu/Kit-PHPEncoder.svg?style=flat)](https://scrutinizer-ci.com/g/Riimu/Kit-PHPEncoder/)
2626
[![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/Riimu/Kit-PHPEncoder.svg?style=flat)](https://scrutinizer-ci.com/g/Riimu/Kit-PHPEncoder/)
27+
[![HHVM Status](https://img.shields.io/hhvm/riimu/kit-phpencoder.svg)](http://hhvm.h4cc.de/package/riimu/kit-phpencoder)
28+
![PHP7 Status](https://img.shields.io/badge/PHP7-tested-brightgreen.svg)
2729

2830
## Requirements ##
2931

3032
In order to use this library, the following requirements must be met:
3133

3234
* PHP version 5.4
33-
35+
3436
## Installation ##
3537

3638
This library can be installed by using [Composer](http://getcomposer.org/). In
@@ -87,7 +89,7 @@ echo $encoder->encode(['foo' => 'bar', [1, true, false, null, 1.0]]);
8789

8890
This would create the following output:
8991

90-
```
92+
```
9193
[
9294
'foo' => 'bar',
9395
[1, true, false, null, 1.0],
@@ -137,107 +139,107 @@ is possible to set these options in three different ways:
137139
* Option values can be set via the `setOption()` method.
138140
* Options can be passed as an array as the second argument to the `encode()`
139141
method.
140-
142+
141143
Note that options passed to the `encode()` method are only temporary and do not
142144
apply to following calls.
143145

144146
#### List of Options ####
145147

146-
* **whitespace** : <boolean> (true)
148+
* **whitespace** : &lt;boolean&gt; (true)<br>
147149
When set to `false`, generation of all extra whitespace is disabled and all
148150
other settings that affect whitespace are ignored.
149-
150-
* **null.capitalize** : &lt;boolean&gt; (false)
151+
152+
* **null.capitalize** : &lt;boolean&gt; (false)<br>
151153
When set to `true`, all `null` values are written in upper case instead of
152-
lower case.
153-
154-
* **boolean.capitalize** : &lt;boolean&gt; (false)
154+
lower case.
155+
156+
* **boolean.capitalize** : &lt;boolean&gt; (false)<br>
155157
When set to `true`, all `true` and `false` values are written in upper case
156158
instead of lower case.
157-
158-
* **float.integers** : &lt;boolean|"all"&gt; (false)
159+
160+
* **float.integers** : &lt;boolean|"all"&gt; (false)<br>
159161
When set to `true`, any float that represents an integer and has a value
160162
that is accurately represented by the floating point number will be encoded
161163
as an integer instead of a float. (e.g. the value `2.0` will be encoded as
162164
`2`). To include the values that are not accurately represented, you may set
163165
option to `"all"`.
164-
165-
* **float.precision** : &lt;integer|false&gt; (17)
166+
167+
* **float.precision** : &lt;integer|false&gt; (17)<br>
166168
The maximum precision of encoded floating point values, which usually also
167169
means the maximum number of digits in encoded floats. If the value is set to
168170
`false`, the PHP ini setting `serialize_precision` will be used instead.
169171
Note that due to the way floating point values work, a value greater than 17
170172
does not provide any additional precision.
171-
172-
* **string.escape** : &lt;boolean&gt; (true)
173+
174+
* **string.escape** : &lt;boolean&gt; (true)<br>
173175
When set to `true`, all strings containing bytes outside the 32-126 ASCII
174176
range will be written with double quotes and the characters outside the
175177
range will be escaped.
176-
177-
* **array.short** : &lt;boolean&gt; (true)
178+
179+
* **array.short** : &lt;boolean&gt; (true)<br>
178180
When set to `true`, arrays are enclosed using square brackets `[]` instead
179181
using of the long array notation `array()`.
180-
181-
* **array.base** : &lt;integer|string&gt; (0)
182+
183+
* **array.base** : &lt;integer|string&gt; (0)<br>
182184
Base indentation for arrays as a number of spaces or as a string. Provides
183185
convenience when you need to output code to a file with specific level of
184186
indentation.
185-
186-
* **array.indent** : &lt;integer|string&gt; (4)
187+
188+
* **array.indent** : &lt;integer|string&gt; (4)<br>
187189
Amount of indentation for single level of indentation as a number of spaces
188190
or a string.
189-
190-
* **array.align** : &lt;boolean&gt; (false)
191+
192+
* **array.align** : &lt;boolean&gt; (false)<br>
191193
When set to `true`, array assignment operators `=>` are aligned to the same
192194
column using spaces. Even if enabled, `array.omit` and `array.inline`
193-
options are still respected, but only if all the keys in the specific array
195+
options are still respected, but only if all the keys in the specific array
194196
can be omitted.
195-
196-
* **array.inline** : &lt;boolean|integer&gt; (70)
197+
198+
* **array.inline** : &lt;boolean|integer&gt; (70)<br>
197199
When set to `true`, any array that can be written without any array keys
198200
will be written in a single line. If an integer is provided instead, the
199201
array will be written as a single line only if it does not exceed that
200202
number of characters. This option has no effect when `array.omit` is set to
201203
false.
202-
203-
* **array.omit** : &lt;boolean&gt; (true)
204+
205+
* **array.omit** : &lt;boolean&gt; (true)<br>
204206
When set to `true`, any redundant array keys will not be included (e.g. the
205207
array `[0 => 'a', 1 => 'b']` would be encoded just as `['a', 'b']`).
206-
207-
* **array.eol** : &lt;string|false&gt; (false)
208+
209+
* **array.eol** : &lt;string|false&gt; (false)<br>
208210
The end of line character used by array output. When set to `false`, the
209211
default `PHP_EOL` will be used instead.
210-
211-
* **object.method** : &lt;boolean&gt; (true)
212+
213+
* **object.method** : &lt;boolean&gt; (true)<br>
212214
When set to `true`, any encoded object will be checked for methods `toPHP()`
213215
and `toPHPValue()`. If the method `toPHP()` exists, the returned string will
214216
be used as the PHP code representation of the object. If the method
215217
`toPHPValue()` exists instead, the returned value will be encoded as PHP and
216218
used as the code representation of the object.
217-
218-
* **object.format** : &lt;string&gt; ('vars')
219+
220+
* **object.format** : &lt;string&gt; ('vars')<br>
219221
Default object encoding format. The possible values are:
220-
222+
221223
* `string` casts the object to string and then encodes that string as PHP.
222224
* `serialize` serializes the object and wraps it with `unserialize()`
223225
* `export` mimics the `var_export()` object representation
224-
* `array` casts the object to an array and encodes that array
226+
* `array` casts the object to an array and encodes that array
225227
* `vars` turns object into an array using `get_object_vars()`
226228
* `iterate` turns the object into an array by iterating over it with `foreach`
227-
228-
* **object.cast** : &lt;boolean&gt; (true)
229+
230+
* **object.cast** : &lt;boolean&gt; (true)<br>
229231
Whether to add an `(object)` cast in front of arrays generated from objects
230232
or not when using the object encoding formats `vars`, `array` or `iterate`.
231-
232-
* **recursion.detect** : &lt;boolean&gt; (true)
233+
234+
* **recursion.detect** : &lt;boolean&gt; (true)<br>
233235
When set to `true`, the encoder will attempt to detect circular references
234236
in arrays and objects to avoid infinite loops.
235-
236-
* **recursion.ignore** : &lt;boolean&gt; (false)
237+
238+
* **recursion.ignore** : &lt;boolean&gt; (false)<br>
237239
When set to `true`, any circular reference will be replaced with `null`
238240
instead of throwing an exception.
239-
240-
* **recursion.max** : &lt;integer|false&gt; (false)
241+
242+
* **recursion.max** : &lt;integer|false&gt; (false)<br>
241243
Maximum number of levels when encoding arrays and objects. Exception is
242244
thrown when the maximum is exceeded. Set to `false` to have no limit.
243245

tests/extra/StringObject.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
class StringObject
66
{
7+
public function toPHPValue()
8+
{
9+
return 'Wrong';
10+
}
11+
712
public function __toString()
813
{
914
return 'Stringed';

0 commit comments

Comments
 (0)