Skip to content

Commit

Permalink
Merge pull request #266 from ergebnis/fix/default
Browse files Browse the repository at this point in the history
Fix: Initialize fields with default values
  • Loading branch information
localheinz authored Apr 19, 2020
2 parents b556041 + 98c2ee3 commit 1ddecc1
Show file tree
Hide file tree
Showing 25 changed files with 101 additions and 79 deletions.
66 changes: 1 addition & 65 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="3.10.1@eeed5ecccc10131397f0eb7ee6da810c0be3a7fc">
<files psalm-version="3.11.2@d470903722cfcbc1cd04744c5491d3e6d13ec3d9">
<file src="src/CallableNormalizer.php">
<MixedInferredReturnType occurrences="1">
<code>Json</code>
Expand All @@ -8,66 +8,6 @@
<code>$callable($json)</code>
</MixedReturnStatement>
</file>
<file src="src/Exception/InvalidIndentSizeException.php">
<MissingConstructor occurrences="1">
<code>$size</code>
</MissingConstructor>
</file>
<file src="src/Exception/InvalidIndentStringException.php">
<MissingConstructor occurrences="1">
<code>$string</code>
</MissingConstructor>
</file>
<file src="src/Exception/InvalidIndentStyleException.php">
<MissingConstructor occurrences="1">
<code>$style</code>
</MissingConstructor>
</file>
<file src="src/Exception/InvalidJsonEncodeOptionsException.php">
<MissingConstructor occurrences="1">
<code>$jsonEncodeOptions</code>
</MissingConstructor>
</file>
<file src="src/Exception/InvalidJsonEncodedException.php">
<MissingConstructor occurrences="1">
<code>$encoded</code>
</MissingConstructor>
</file>
<file src="src/Exception/InvalidNewLineStringException.php">
<MissingConstructor occurrences="1">
<code>$string</code>
</MissingConstructor>
</file>
<file src="src/Exception/NormalizedInvalidAccordingToSchemaException.php">
<MissingConstructor occurrences="1">
<code>$schemaUri</code>
</MissingConstructor>
</file>
<file src="src/Exception/OriginalInvalidAccordingToSchemaException.php">
<MissingConstructor occurrences="1">
<code>$schemaUri</code>
</MissingConstructor>
</file>
<file src="src/Exception/SchemaUriCouldNotBeReadException.php">
<MissingConstructor occurrences="1">
<code>$schemaUri</code>
</MissingConstructor>
</file>
<file src="src/Exception/SchemaUriCouldNotBeResolvedException.php">
<MissingConstructor occurrences="1">
<code>$schemaUri</code>
</MissingConstructor>
</file>
<file src="src/Exception/SchemaUriReferencesDocumentWithInvalidMediaTypeException.php">
<MissingConstructor occurrences="1">
<code>$schemaUri</code>
</MissingConstructor>
</file>
<file src="src/Exception/SchemaUriReferencesInvalidJsonDocumentException.php">
<MissingConstructor occurrences="1">
<code>$schemaUri</code>
</MissingConstructor>
</file>
<file src="src/Json.php">
<DocblockTypeContradiction occurrences="1">
<code>null === $this-&gt;format</code>
Expand Down Expand Up @@ -120,10 +60,6 @@
</MixedAssignment>
</file>
<file src="src/Vendor/Composer/PackageHashNormalizer.php">
<MixedArgumentTypeCoercion occurrences="2">
<code>$packages</code>
<code>$packages</code>
</MixedArgumentTypeCoercion>
<MixedAssignment occurrences="1">
<code>$value</code>
</MixedAssignment>
Expand Down
4 changes: 2 additions & 2 deletions src/Exception/InvalidIndentSizeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ final class InvalidIndentSizeException extends \InvalidArgumentException impleme
/**
* @var int
*/
private $size;
private $size = 0;

/**
* @var int
*/
private $minimumSize;
private $minimumSize = 0;

public static function fromSizeAndMinimumSize(int $size, int $minimumSize): self
{
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/InvalidIndentStringException.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class InvalidIndentStringException extends \InvalidArgumentException imple
/**
* @var string
*/
private $string;
private $string = '';

public static function fromString(string $string): self
{
Expand Down
4 changes: 2 additions & 2 deletions src/Exception/InvalidIndentStyleException.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ final class InvalidIndentStyleException extends \InvalidArgumentException implem
/**
* @var string
*/
private $style;
private $style = '';

/**
* @var string[]
*/
private $allowedStyles;
private $allowedStyles = [];

public static function fromStyleAndAllowedStyles(string $style, string ...$allowedStyles): self
{
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/InvalidJsonEncodeOptionsException.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class InvalidJsonEncodeOptionsException extends \InvalidArgumentException
/**
* @var int
*/
private $jsonEncodeOptions;
private $jsonEncodeOptions = 0;

public static function fromJsonEncodeOptions(int $jsonEncodeOptions): self
{
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/InvalidJsonEncodedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class InvalidJsonEncodedException extends \InvalidArgumentException implem
/**
* @var string
*/
private $encoded;
private $encoded = '';

public static function fromEncoded(string $encoded): self
{
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/InvalidNewLineStringException.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class InvalidNewLineStringException extends \InvalidArgumentException impl
/**
* @var string
*/
private $string;
private $string = '';

public static function fromString(string $string): self
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class NormalizedInvalidAccordingToSchemaException extends \RuntimeExceptio
/**
* @var string
*/
private $schemaUri;
private $schemaUri = '';

public static function fromSchemaUri(string $schemaUri): self
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class OriginalInvalidAccordingToSchemaException extends \RuntimeException
/**
* @var string
*/
private $schemaUri;
private $schemaUri = '';

public static function fromSchemaUri(string $schemaUri): self
{
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/SchemaUriCouldNotBeReadException.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class SchemaUriCouldNotBeReadException extends \RuntimeException implement
/**
* @var string
*/
private $schemaUri;
private $schemaUri = '';

public static function fromSchemaUri(string $schemaUri): self
{
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/SchemaUriCouldNotBeResolvedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class SchemaUriCouldNotBeResolvedException extends \RuntimeException imple
/**
* @var string
*/
private $schemaUri;
private $schemaUri = '';

public static function fromSchemaUri(string $schemaUri): self
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class SchemaUriReferencesDocumentWithInvalidMediaTypeException extends \Ru
/**
* @var string
*/
private $schemaUri;
private $schemaUri = '';

public static function fromSchemaUri(string $schemaUri): self
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class SchemaUriReferencesInvalidJsonDocumentException extends \RuntimeExce
/**
* @var string
*/
private $schemaUri;
private $schemaUri = '';

public static function fromSchemaUri(string $schemaUri): self
{
Expand Down
8 changes: 8 additions & 0 deletions test/Unit/Exception/InvalidIndentSizeExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@
*/
final class InvalidIndentSizeExceptionTest extends AbstractExceptionTestCase
{
public function testDefaults(): void
{
$exception = new InvalidIndentSizeException();

self::assertSame(0, $exception->minimumSize());
self::assertSame(0, $exception->size());
}

public function testFromSizeAndMinimumSizeReturnsInvalidIndentSizeException(): void
{
$faker = self::faker();
Expand Down
7 changes: 7 additions & 0 deletions test/Unit/Exception/InvalidIndentStringExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
*/
final class InvalidIndentStringExceptionTest extends AbstractExceptionTestCase
{
public function testDefaults(): void
{
$exception = new InvalidIndentStringException();

self::assertSame('', $exception->string());
}

public function testFromSizeAndMinimumSizeReturnsInvalidIndentStringException(): void
{
$string = self::faker()->word;
Expand Down
8 changes: 8 additions & 0 deletions test/Unit/Exception/InvalidIndentStyleExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@
*/
final class InvalidIndentStyleExceptionTest extends AbstractExceptionTestCase
{
public function testDefaults(): void
{
$exception = new InvalidIndentStyleException();

self::assertSame([], $exception->allowedStyles());
self::assertSame('', $exception->style());
}

public function testExtendsInvalidArgumentException(): void
{
self::assertClassExtends(\InvalidArgumentException::class, InvalidIndentStyleException::class);
Expand Down
7 changes: 7 additions & 0 deletions test/Unit/Exception/InvalidJsonEncodeOptionsExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
*/
final class InvalidJsonEncodeOptionsExceptionTest extends AbstractExceptionTestCase
{
public function testDefaults(): void
{
$exception = new InvalidJsonEncodeOptionsException();

self::assertSame(0, $exception->jsonEncodeOptions());
}

public function testFromJsonEncodeOptionsReturnsInvalidJsonEncodeOptionsException(): void
{
$jsonEncodeOptions = self::faker()->randomNumber();
Expand Down
7 changes: 7 additions & 0 deletions test/Unit/Exception/InvalidJsonEncodedExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
*/
final class InvalidJsonEncodedExceptionTest extends AbstractExceptionTestCase
{
public function testDefaults(): void
{
$exception = new InvalidJsonEncodedException();

self::assertSame('', $exception->encoded());
}

public function testFromEncodedReturnsInvalidJsonEncodedException(): void
{
$encoded = self::faker()->sentence;
Expand Down
7 changes: 7 additions & 0 deletions test/Unit/Exception/InvalidNewLineStringExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
*/
final class InvalidNewLineStringExceptionTest extends AbstractExceptionTestCase
{
public function testDefaults(): void
{
$exception = new InvalidNewLineStringException();

self::assertSame('', $exception->string());
}

public function testFromSizeAndMinimumSizeReturnsInvalidIndentStringException(): void
{
$string = self::faker()->word;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
*/
final class NormalizedInvalidAccordingToSchemaExceptionTest extends AbstractExceptionTestCase
{
public function testDefaults(): void
{
$exception = new NormalizedInvalidAccordingToSchemaException();

self::assertSame('', $exception->schemaUri());
}

public function testFromSchemaUriReturnsNormalizedInvalidAccordingToSchemaException(): void
{
$schemaUri = self::faker()->url;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
*/
final class OriginalInvalidAccordingToSchemaExceptionTest extends AbstractExceptionTestCase
{
public function testDefaults(): void
{
$exception = new OriginalInvalidAccordingToSchemaException();

self::assertSame('', $exception->schemaUri());
}

public function testFromSchemaUriReturnsOriginalInvalidAccordingToSchemaException(): void
{
$schemaUri = self::faker()->url;
Expand Down
7 changes: 7 additions & 0 deletions test/Unit/Exception/SchemaUriCouldNotBeReadExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
*/
final class SchemaUriCouldNotBeReadExceptionTest extends AbstractExceptionTestCase
{
public function testDefaults(): void
{
$exception = new SchemaUriCouldNotBeReadException();

self::assertSame('', $exception->schemaUri());
}

public function testFromSchemaUriReturnsSchemaUriCouldNotBeReadException(): void
{
$schemaUri = self::faker()->url;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
*/
final class SchemaUriCouldNotBeResolvedExceptionTest extends AbstractExceptionTestCase
{
public function testDefaults(): void
{
$exception = new SchemaUriCouldNotBeResolvedException();

self::assertSame('', $exception->schemaUri());
}

public function testFromSchemaUriReturnsSchemaUriCouldNotBeResolvedException(): void
{
$schemaUri = self::faker()->url;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
*/
final class SchemaUriReferencesDocumentWithInvalidMediaTypeExceptionTest extends AbstractExceptionTestCase
{
public function testDefaults(): void
{
$exception = new SchemaUriReferencesDocumentWithInvalidMediaTypeException();

self::assertSame('', $exception->schemaUri());
}

public function testFromSchemaUriReturnsSchemaUriReferencesDocumentWithInvalidMediaType(): void
{
$schemaUri = self::faker()->url;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
*/
final class SchemaUriReferencesInvalidJsonDocumentExceptionTest extends AbstractExceptionTestCase
{
public function testDefaults(): void
{
$exception = new SchemaUriReferencesInvalidJsonDocumentException();

self::assertSame('', $exception->schemaUri());
}

public function testFromSchemaUriReturnsSchemaUriReferencesDocumentWithInvalidMediaType(): void
{
$schemaUri = self::faker()->url;
Expand Down

0 comments on commit 1ddecc1

Please sign in to comment.