Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: Update localheinz/php-cs-fixer-config #56

Merged
merged 2 commits into from
Jun 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ EOF;

$config = Config\Factory::fromRuleSet(new Config\RuleSet\Php71($header), [
'mb_str_functions' => false,
'no_unset_on_property' => false,
]);

$config->getFinder()->in(__DIR__);
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"require-dev": {
"infection/infection": "~0.8.1",
"localheinz/php-cs-fixer-config": "~1.13.1",
"localheinz/php-cs-fixer-config": "~1.14.0",
"localheinz/test-util": "0.6.1",
"phpbench/phpbench": "~0.14.0",
"phpspec/prophecy": "^1.7.1",
Expand Down
270 changes: 186 additions & 84 deletions composer.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/AutoFormatNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct(

public function normalize(string $json): string
{
if (null === \json_decode($json) && JSON_ERROR_NONE !== \json_last_error()) {
if (null === \json_decode($json) && \JSON_ERROR_NONE !== \json_last_error()) {
throw new \InvalidArgumentException(\sprintf(
'"%s" is not valid JSON.',
$json
Expand Down
2 changes: 1 addition & 1 deletion src/CallableNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct(callable $callable)

public function normalize(string $json): string
{
if (null === \json_decode($json) && JSON_ERROR_NONE !== \json_last_error()) {
if (null === \json_decode($json) && \JSON_ERROR_NONE !== \json_last_error()) {
throw new \InvalidArgumentException(\sprintf(
'"%s" is not valid JSON.',
$json
Expand Down
2 changes: 1 addition & 1 deletion src/ChainNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct(NormalizerInterface ...$normalizers)

public function normalize(string $json): string
{
if (null === \json_decode($json) && JSON_ERROR_NONE !== \json_last_error()) {
if (null === \json_decode($json) && \JSON_ERROR_NONE !== \json_last_error()) {
throw new \InvalidArgumentException(\sprintf(
'"%s" is not valid JSON.',
$json
Expand Down
4 changes: 2 additions & 2 deletions src/FinalNewLineNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ final class FinalNewLineNormalizer implements NormalizerInterface
{
public function normalize(string $json): string
{
if (null === \json_decode($json) && JSON_ERROR_NONE !== \json_last_error()) {
if (null === \json_decode($json) && \JSON_ERROR_NONE !== \json_last_error()) {
throw new \InvalidArgumentException(\sprintf(
'"%s" is not valid JSON.',
$json
));
}

return \rtrim($json) . PHP_EOL;
return \rtrim($json) . \PHP_EOL;
}
}
2 changes: 1 addition & 1 deletion src/FixedFormatNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct(

public function normalize(string $json): string
{
if (null === \json_decode($json) && JSON_ERROR_NONE !== \json_last_error()) {
if (null === \json_decode($json) && \JSON_ERROR_NONE !== \json_last_error()) {
throw new \InvalidArgumentException(\sprintf(
'"%s" is not valid JSON.',
$json
Expand Down
2 changes: 1 addition & 1 deletion src/Format/Formatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function format(string $json, FormatInterface $format): string
{
$decoded = \json_decode($json);

if (null === $decoded && JSON_ERROR_NONE !== \json_last_error()) {
if (null === $decoded && \JSON_ERROR_NONE !== \json_last_error()) {
throw new \InvalidArgumentException(\sprintf(
'"%s" is not valid JSON.',
$json
Expand Down
8 changes: 4 additions & 4 deletions src/Format/Sniffer.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ final class Sniffer implements SnifferInterface
{
public function sniff(string $json): FormatInterface
{
if (null === \json_decode($json) && JSON_ERROR_NONE !== \json_last_error()) {
if (null === \json_decode($json) && \JSON_ERROR_NONE !== \json_last_error()) {
throw new \InvalidArgumentException(\sprintf(
'"%s" is not valid JSON.',
$json
Expand All @@ -37,11 +37,11 @@ private function jsonEncodeOptions(string $json): int
$jsonEncodeOptions = 0;

if (false === \strpos($json, '\/')) {
$jsonEncodeOptions |= JSON_UNESCAPED_SLASHES;
$jsonEncodeOptions |= \JSON_UNESCAPED_SLASHES;
}

if (1 !== \preg_match('/(\\\\+)u([0-9a-f]{4})/i', $json)) {
$jsonEncodeOptions |= JSON_UNESCAPED_UNICODE;
$jsonEncodeOptions |= \JSON_UNESCAPED_UNICODE;
}

return $jsonEncodeOptions;
Expand All @@ -62,7 +62,7 @@ private function newLine(string $json): string
return $match['newLine'];
}

return PHP_EOL;
return \PHP_EOL;
}

private function hasFinalNewLine(string $json): bool
Expand Down
2 changes: 1 addition & 1 deletion src/IndentNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function __construct(string $indent, PrinterInterface $printer = null)

public function normalize(string $json): string
{
if (null === \json_decode($json) && JSON_ERROR_NONE !== \json_last_error()) {
if (null === \json_decode($json) && \JSON_ERROR_NONE !== \json_last_error()) {
throw new \InvalidArgumentException(\sprintf(
'"%s" is not valid JSON.',
$json
Expand Down
2 changes: 1 addition & 1 deletion src/JsonEncodeNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct(int $jsonEncodeOptions)

public function normalize(string $json): string
{
if (null === \json_decode($json) && JSON_ERROR_NONE !== \json_last_error()) {
if (null === \json_decode($json) && \JSON_ERROR_NONE !== \json_last_error()) {
throw new \InvalidArgumentException(\sprintf(
'"%s" is not valid JSON.',
$json
Expand Down
2 changes: 1 addition & 1 deletion src/NoFinalNewLineNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ final class NoFinalNewLineNormalizer implements NormalizerInterface
{
public function normalize(string $json): string
{
if (null === \json_decode($json) && JSON_ERROR_NONE !== \json_last_error()) {
if (null === \json_decode($json) && \JSON_ERROR_NONE !== \json_last_error()) {
throw new \InvalidArgumentException(\sprintf(
'"%s" is not valid JSON.',
$json
Expand Down
2 changes: 1 addition & 1 deletion src/SchemaNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function normalize(string $json): string
{
$decoded = \json_decode($json);

if (null === $decoded && JSON_ERROR_NONE !== \json_last_error()) {
if (null === $decoded && \JSON_ERROR_NONE !== \json_last_error()) {
throw new \InvalidArgumentException(\sprintf(
'"%s" is not valid JSON.',
$json
Expand Down
3 changes: 3 additions & 0 deletions test/Unit/AbstractNormalizerTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
use Localheinz\Test\Util\Helper;
use PHPUnit\Framework;

/**
* @internal
*/
abstract class AbstractNormalizerTestCase extends Framework\TestCase
{
use Helper;
Expand Down
3 changes: 3 additions & 0 deletions test/Unit/AutoFormatNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
use Localheinz\Json\Normalizer\NormalizerInterface;
use Prophecy\Argument;

/**
* @internal
*/
final class AutoFormatNormalizerTest extends AbstractNormalizerTestCase
{
public function testNormalizeUsesSnifferToSniffFormatNormalizesAndFormatsUsingSniffedFormat(): void
Expand Down
3 changes: 3 additions & 0 deletions test/Unit/CallableNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

use Localheinz\Json\Normalizer\CallableNormalizer;

/**
* @internal
*/
final class CallableNormalizerTest extends AbstractNormalizerTestCase
{
/**
Expand Down
3 changes: 3 additions & 0 deletions test/Unit/ChainNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
use Localheinz\Json\Normalizer\NormalizerInterface;
use Prophecy\Argument;

/**
* @internal
*/
final class ChainNormalizerTest extends AbstractNormalizerTestCase
{
public function testNormalizePassesJsonThroughNormalizers(): void
Expand Down
7 changes: 5 additions & 2 deletions test/Unit/FinalNewLineNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

use Localheinz\Json\Normalizer\FinalNewLineNormalizer;

/**
* @internal
*/
final class FinalNewLineNormalizerTest extends AbstractNormalizerTestCase
{
/**
Expand All @@ -33,7 +36,7 @@ public function testNormalizeEnsuresSingleFinalNewLine(string $whitespace): void

$json .= $whitespace;

$normalized = \rtrim($json) . PHP_EOL;
$normalized = \rtrim($json) . \PHP_EOL;

$normalizer = new FinalNewLineNormalizer();

Expand All @@ -46,7 +49,7 @@ public function providerWhitespace(): \Generator
'',
' ',
"\t",
PHP_EOL,
\PHP_EOL,
];

foreach ($values as $value) {
Expand Down
5 changes: 4 additions & 1 deletion test/Unit/FixedFormatNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
use Localheinz\Json\Normalizer\NormalizerInterface;
use Prophecy\Argument;

/**
* @internal
*/
final class FixedFormatNormalizerTest extends AbstractNormalizerTestCase
{
public function testNormalizeNormalizesAndFormatsUsingFormat(): void
Expand Down Expand Up @@ -80,7 +83,7 @@ public function providerFinalNewLine(): \Generator
],
'with-final-new-line' => [
true,
PHP_EOL,
\PHP_EOL,
],
];

Expand Down
37 changes: 20 additions & 17 deletions test/Unit/Format/FormatTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
use Localheinz\Test\Util\Helper;
use PHPUnit\Framework;

/**
* @internal
*/
final class FormatTest extends Framework\TestCase
{
use Helper;
Expand All @@ -31,7 +34,7 @@ public function testConstructorRejectsInvalidEncodeOptions(): void
{
$jsonEncodeOptions = -1;
$indent = ' ';
$newLine = PHP_EOL;
$newLine = \PHP_EOL;
$hasFinalNewLine = true;

$this->expectException(\InvalidArgumentException::class);
Expand All @@ -56,7 +59,7 @@ public function testConstructorRejectsInvalidEncodeOptions(): void
public function testConstructorRejectsInvalidIndent(string $indent): void
{
$jsonEncodeOptions = 0;
$newLine = PHP_EOL;
$newLine = \PHP_EOL;
$hasFinalNewLine = true;

$this->expectException(\InvalidArgumentException::class);
Expand Down Expand Up @@ -141,7 +144,7 @@ public function providerInvalidNewLine(): \Generator
*/
public function testConstructorSetsValues(string $indent, string $newLine, bool $hasFinalNewLine): void
{
$jsonEncodeOptions = JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES;
$jsonEncodeOptions = \JSON_UNESCAPED_UNICODE | \JSON_UNESCAPED_SLASHES;

$format = new Format(
$jsonEncodeOptions,
Expand Down Expand Up @@ -176,9 +179,9 @@ public function testWithJsonEncodeOptionsRejectsInvalidJsonEncodeOptions(): void
$jsonEncodeOptions = -1;

$format = new Format(
JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES,
\JSON_UNESCAPED_UNICODE | \JSON_UNESCAPED_SLASHES,
' ',
PHP_EOL,
\PHP_EOL,
true
);

Expand All @@ -194,9 +197,9 @@ public function testWithJsonEncodeOptionsRejectsInvalidJsonEncodeOptions(): void
public function testWithJsonEncodeOptionsClonesFormatAndSetsJsonEncodeOptions(): void
{
$format = new Format(
JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES,
\JSON_UNESCAPED_UNICODE | \JSON_UNESCAPED_SLASHES,
' ',
PHP_EOL,
\PHP_EOL,
true
);

Expand All @@ -217,9 +220,9 @@ public function testWithJsonEncodeOptionsClonesFormatAndSetsJsonEncodeOptions():
public function testWithIndentRejectsInvalidIndent(string $indent): void
{
$format = new Format(
JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES,
\JSON_UNESCAPED_UNICODE | \JSON_UNESCAPED_SLASHES,
' ',
PHP_EOL,
\PHP_EOL,
true
);

Expand All @@ -240,9 +243,9 @@ public function testWithIndentRejectsInvalidIndent(string $indent): void
public function testWithIndentClonesFormatAndSetsIndent(string $indent): void
{
$format = new Format(
JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES,
\JSON_UNESCAPED_UNICODE | \JSON_UNESCAPED_SLASHES,
' ',
PHP_EOL,
\PHP_EOL,
true
);

Expand Down Expand Up @@ -270,9 +273,9 @@ public function providerIndent(): \Generator
public function testWithNewLineRejectsInvalidNewLine(string $newLine): void
{
$format = new Format(
JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES,
\JSON_UNESCAPED_UNICODE | \JSON_UNESCAPED_SLASHES,
' ',
PHP_EOL,
\PHP_EOL,
true
);

Expand All @@ -293,9 +296,9 @@ public function testWithNewLineRejectsInvalidNewLine(string $newLine): void
public function testWithNewLineClonesFormatAndSetsNewLine(string $newLine): void
{
$format = new Format(
JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES,
\JSON_UNESCAPED_UNICODE | \JSON_UNESCAPED_SLASHES,
' ',
PHP_EOL,
\PHP_EOL,
true
);

Expand Down Expand Up @@ -323,9 +326,9 @@ public function providerNewLine(): \Generator
public function testWithHasFinalNewLineClonesFormatAndSetsFinalNewLine(bool $hasFinalNewLine): void
{
$format = new Format(
JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES,
\JSON_UNESCAPED_UNICODE | \JSON_UNESCAPED_SLASHES,
' ',
PHP_EOL,
\PHP_EOL,
false
);

Expand Down
5 changes: 4 additions & 1 deletion test/Unit/Format/FormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
use PHPUnit\Framework;
use Prophecy\Argument;

/**
* @internal
*/
final class FormatterTest extends Framework\TestCase
{
use Helper;
Expand Down Expand Up @@ -138,7 +141,7 @@ public function providerFinalNewLine(): \Generator
],
'with-final-new-line' => [
true,
PHP_EOL,
\PHP_EOL,
],
];

Expand Down
Loading