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

refactor: add declare strict_types to all classes in ./src #758

Merged
merged 4 commits into from
Nov 21, 2024
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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add ext-json to composer.json to ensure JSON extension available ([#759](https://github.com/jsonrainbow/json-schema/pull/759))
- Add visibility modifiers to class constants ([#757](https://github.com/jsonrainbow/json-schema/pull/757))
- Include PHP 8.4 in workflow ([#765](https://github.com/jsonrainbow/json-schema/pull/765))
- Add `strict_types=1` to all classes in ./src ([#758](https://github.com/jsonrainbow/json-schema/pull/758))

## [6.0.0] - 2024-07-30
### Added
Expand Down
2 changes: 2 additions & 0 deletions src/JsonSchema/ConstraintError.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace JsonSchema;

use JsonSchema\Exception\InvalidArgumentException;
Expand Down
2 changes: 2 additions & 0 deletions src/JsonSchema/Constraints/BaseConstraint.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the JsonSchema package.
*
Expand Down
2 changes: 2 additions & 0 deletions src/JsonSchema/Constraints/CollectionConstraint.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the JsonSchema package.
*
Expand Down
2 changes: 2 additions & 0 deletions src/JsonSchema/Constraints/ConstConstraint.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the JsonSchema package.
*
Expand Down
2 changes: 2 additions & 0 deletions src/JsonSchema/Constraints/Constraint.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the JsonSchema package.
*
Expand Down
2 changes: 2 additions & 0 deletions src/JsonSchema/Constraints/ConstraintInterface.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the JsonSchema package.
*
Expand Down
2 changes: 2 additions & 0 deletions src/JsonSchema/Constraints/EnumConstraint.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the JsonSchema package.
*
Expand Down
2 changes: 2 additions & 0 deletions src/JsonSchema/Constraints/Factory.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the JsonSchema package.
*
Expand Down
4 changes: 3 additions & 1 deletion src/JsonSchema/Constraints/FormatConstraint.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the JsonSchema package.
*
Expand Down Expand Up @@ -174,7 +176,7 @@ public function check(&$element, $schema = null, ?JsonPointer $path = null, $i =

protected function validateDateTime($datetime, $format)
{
$dt = \DateTime::createFromFormat($format, $datetime);
$dt = \DateTime::createFromFormat($format, (string) $datetime);

if (!$dt) {
return false;
Expand Down
2 changes: 2 additions & 0 deletions src/JsonSchema/Constraints/NumberConstraint.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the JsonSchema package.
*
Expand Down
2 changes: 2 additions & 0 deletions src/JsonSchema/Constraints/ObjectConstraint.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the JsonSchema package.
*
Expand Down
2 changes: 2 additions & 0 deletions src/JsonSchema/Constraints/SchemaConstraint.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the JsonSchema package.
*
Expand Down
2 changes: 2 additions & 0 deletions src/JsonSchema/Constraints/StringConstraint.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the JsonSchema package.
*
Expand Down
2 changes: 2 additions & 0 deletions src/JsonSchema/Constraints/TypeCheck/LooseTypeCheck.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace JsonSchema\Constraints\TypeCheck;

class LooseTypeCheck implements TypeCheckInterface
Expand Down
2 changes: 2 additions & 0 deletions src/JsonSchema/Constraints/TypeCheck/StrictTypeCheck.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace JsonSchema\Constraints\TypeCheck;

class StrictTypeCheck implements TypeCheckInterface
Expand Down
2 changes: 2 additions & 0 deletions src/JsonSchema/Constraints/TypeCheck/TypeCheckInterface.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace JsonSchema\Constraints\TypeCheck;

interface TypeCheckInterface
Expand Down
2 changes: 2 additions & 0 deletions src/JsonSchema/Constraints/TypeConstraint.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the JsonSchema package.
*
Expand Down
2 changes: 2 additions & 0 deletions src/JsonSchema/Constraints/UndefinedConstraint.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the JsonSchema package.
*
Expand Down
4 changes: 3 additions & 1 deletion src/JsonSchema/Entity/JsonPointer.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the JsonSchema package.
*
Expand Down Expand Up @@ -120,7 +122,7 @@ public function getPropertyPaths()
public function withPropertyPaths(array $propertyPaths)
{
$new = clone $this;
$new->propertyPaths = $propertyPaths;
$new->propertyPaths = array_map(function ($p): string { return (string) $p; }, $propertyPaths);

return $new;
}
Expand Down
2 changes: 2 additions & 0 deletions src/JsonSchema/Enum.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace JsonSchema;

abstract class Enum extends \MabeEnum\Enum
Expand Down
2 changes: 2 additions & 0 deletions src/JsonSchema/Exception/ExceptionInterface.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace JsonSchema\Exception;

interface ExceptionInterface
Expand Down
2 changes: 2 additions & 0 deletions src/JsonSchema/Exception/InvalidArgumentException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the JsonSchema package.
*
Expand Down
2 changes: 2 additions & 0 deletions src/JsonSchema/Exception/InvalidConfigException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the JsonSchema package.
*
Expand Down
2 changes: 2 additions & 0 deletions src/JsonSchema/Exception/InvalidSchemaException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the JsonSchema package.
*
Expand Down
2 changes: 2 additions & 0 deletions src/JsonSchema/Exception/InvalidSchemaMediaTypeException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the JsonSchema package.
*
Expand Down
2 changes: 2 additions & 0 deletions src/JsonSchema/Exception/InvalidSourceUriException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the JsonSchema package.
*
Expand Down
2 changes: 2 additions & 0 deletions src/JsonSchema/Exception/JsonDecodingException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the JsonSchema package.
*
Expand Down
2 changes: 2 additions & 0 deletions src/JsonSchema/Exception/ResourceNotFoundException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the JsonSchema package.
*
Expand Down
2 changes: 2 additions & 0 deletions src/JsonSchema/Exception/RuntimeException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the JsonSchema package.
*
Expand Down
2 changes: 2 additions & 0 deletions src/JsonSchema/Exception/UnresolvableJsonPointerException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the JsonSchema package.
*
Expand Down
2 changes: 2 additions & 0 deletions src/JsonSchema/Exception/UriResolverException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the JsonSchema package.
*
Expand Down
2 changes: 2 additions & 0 deletions src/JsonSchema/Exception/ValidationException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the JsonSchema package.
*
Expand Down
2 changes: 2 additions & 0 deletions src/JsonSchema/Iterator/ObjectIterator.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the JsonSchema package.
*
Expand Down
2 changes: 2 additions & 0 deletions src/JsonSchema/Rfc3339.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace JsonSchema;

class Rfc3339
Expand Down
2 changes: 2 additions & 0 deletions src/JsonSchema/SchemaStorage.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace JsonSchema;

use JsonSchema\Constraints\BaseConstraint;
Expand Down
2 changes: 2 additions & 0 deletions src/JsonSchema/SchemaStorageInterface.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace JsonSchema;

interface SchemaStorageInterface
Expand Down
3 changes: 3 additions & 0 deletions src/JsonSchema/Uri/Retrievers/AbstractRetriever.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

declare(strict_types=1);

/**
* JsonSchema
*
Expand Down
2 changes: 2 additions & 0 deletions src/JsonSchema/Uri/Retrievers/Curl.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the JsonSchema package.
*
Expand Down
2 changes: 2 additions & 0 deletions src/JsonSchema/Uri/Retrievers/FileGetContents.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the JsonSchema package.
*
Expand Down
2 changes: 2 additions & 0 deletions src/JsonSchema/Uri/Retrievers/PredefinedArray.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace JsonSchema\Uri\Retrievers;

use JsonSchema\Validator;
Expand Down
2 changes: 2 additions & 0 deletions src/JsonSchema/Uri/Retrievers/UriRetrieverInterface.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the JsonSchema package.
*
Expand Down
2 changes: 2 additions & 0 deletions src/JsonSchema/Uri/UriResolver.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the JsonSchema package.
*
Expand Down
2 changes: 2 additions & 0 deletions src/JsonSchema/Uri/UriRetriever.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the JsonSchema package.
*
Expand Down
2 changes: 2 additions & 0 deletions src/JsonSchema/UriResolverInterface.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the JsonSchema package.
*
Expand Down
2 changes: 2 additions & 0 deletions src/JsonSchema/UriRetrieverInterface.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the JsonSchema package.
*
Expand Down
2 changes: 2 additions & 0 deletions src/JsonSchema/Validator.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the JsonSchema package.
*
Expand Down