first commit

This commit is contained in:
Claudecio Martins
2026-06-16 10:04:10 -03:00
commit a951944997
4463 changed files with 419677 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) Henrique Moody
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+45
View File
@@ -0,0 +1,45 @@
# Respect\Stringifier
[![Build Status](https://img.shields.io/github/actions/workflow/status/Respect/Stringifier/continuous-integration.yml?branch=master&style=flat-square)](https://github.com/Respect/Stringifier/actions/workflows/continuous-integration.yml)
[![Code Coverage](https://img.shields.io/codecov/c/github/Respect/Stringifier?style=flat-square)](https://codecov.io/gh/Respect/Stringifier)
[![Latest Stable Version](https://img.shields.io/packagist/v/respect/stringifier.svg?style=flat-square)](https://packagist.org/packages/respect/stringifier)
[![Total Downloads](https://img.shields.io/packagist/dt/respect/stringifier.svg?style=flat-square)](https://packagist.org/packages/respect/stringifier)
[![License](https://img.shields.io/packagist/l/respect/stringifier.svg?style=flat-square)](https://packagist.org/packages/respect/stringifier)
Converts any PHP value into a string.
## Installation
Package is available on [Packagist](https://packagist.org/packages/respect/stringifier), you can install it
using [Composer](http://getcomposer.org).
```bash
composer require respect/stringifier
```
This library requires PHP >= 8.1.
## Feature Guide
Below a quick guide of how to use the library.
### Namespace import
Respect\Stringifier is namespaced, and you can make your life easier by importing
a single function into your context:
```php
use function Respect\Stringifier\stringify;
```
Stringifier was built using objects, the `stringify()` is a easy way to use it.
### Usage
Simply use the function to convert any value you want to:
```php
echo stringify($value);
```
To see more examples of how to use the library check the [integration tests](tests/integration).
+56
View File
@@ -0,0 +1,56 @@
{
"name": "respect/stringifier",
"description": "Converts any value to a string",
"keywords": ["respect", "stringifier", "stringify"],
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Respect/Stringifier Contributors",
"homepage": "https://github.com/Respect/Stringifier/graphs/contributors"
}
],
"require": {
"php": "^8.1"
},
"require-dev": {
"malukenho/docheader": "^0.1.7",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-deprecation-rules": "^1.1",
"phpstan/phpstan-phpunit": "^1.3",
"phpstan/phpstan-strict-rules": "^1.5",
"phpunit/phpunit": "^10.0",
"respect/coding-standard": "^4.0",
"squizlabs/php_codesniffer": "^3.7"
},
"autoload": {
"psr-4": {
"Respect\\Stringifier\\": "src/",
"Respect\\Stringifier\\Test\\": "tests/src/",
"Respect\\Stringifier\\Test\\Unit\\": "tests/unit"
},
"files": [
"src/stringify.php"
]
},
"scripts": {
"docheader": "vendor/bin/docheader check src/ tests/",
"phpcs": "vendor/bin/phpcs",
"phpstan": "vendor/bin/phpstan",
"phpunit": "vendor/bin/phpunit",
"phpunit-integration": "vendor/bin/phpunit --testsuite=integration",
"phpunit-unit": "vendor/bin/phpunit --testsuite=unit",
"qa": [
"@docheader",
"@phpcs",
"@phpstan",
"@phpunit"
]
},
"config": {
"sort-packages": true,
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
+8
View File
@@ -0,0 +1,8 @@
parameters:
level: max
paths:
- src/
- tests/
fileExtensions:
- php
- phpt
+16
View File
@@ -0,0 +1,16 @@
<?php
/*
* This file is part of Respect/Stringifier.
* Copyright (c) Henrique Moody <henriquemoody@gmail.com>
* SPDX-License-Identifier: MIT
*/
declare(strict_types=1);
namespace Respect\Stringifier;
interface Quoter
{
public function quote(string $string, int $depth): string;
}
+27
View File
@@ -0,0 +1,27 @@
<?php
/*
* This file is part of Respect/Stringifier.
* Copyright (c) Henrique Moody <henriquemoody@gmail.com>
* SPDX-License-Identifier: MIT
*/
declare(strict_types=1);
namespace Respect\Stringifier\Quoters;
use Respect\Stringifier\Quoter;
use function sprintf;
final class CodeQuoter implements Quoter
{
public function quote(string $string, int $depth): string
{
if ($depth === 0) {
return sprintf('`%s`', $string);
}
return $string;
}
}
+16
View File
@@ -0,0 +1,16 @@
<?php
/*
* This file is part of Respect/Stringifier.
* Copyright (c) Henrique Moody <henriquemoody@gmail.com>
* SPDX-License-Identifier: MIT
*/
declare(strict_types=1);
namespace Respect\Stringifier;
interface Stringifier
{
public function stringify(mixed $raw, int $depth): ?string;
}
@@ -0,0 +1,73 @@
<?php
/*
* This file is part of Respect/Stringifier.
* Copyright (c) Henrique Moody <henriquemoody@gmail.com>
* SPDX-License-Identifier: MIT
*/
declare(strict_types=1);
namespace Respect\Stringifier\Stringifiers;
use Respect\Stringifier\Quoter;
use Respect\Stringifier\Stringifier;
use function array_keys;
use function count;
use function implode;
use function is_array;
use function range;
use function sprintf;
final class ArrayStringifier implements Stringifier
{
public function __construct(
private readonly Stringifier $stringifier,
private readonly Quoter $quoter,
private readonly int $maximumDepth,
private readonly int $itemsLimit
) {
}
public function stringify(mixed $raw, int $depth): ?string
{
if (!is_array($raw)) {
return null;
}
if (empty($raw)) {
return $this->quoter->quote('{ }', $depth);
}
if ($depth >= $this->maximumDepth) {
return '...';
}
$items = [];
$itemsCount = 0;
$isSequential = $this->isSequential($raw);
foreach ($raw as $key => $value) {
if (++$itemsCount > $this->itemsLimit) {
$items[$itemsCount] = '...';
break;
}
$items[$itemsCount] = '';
if ($isSequential === false) {
$items[$itemsCount] .= sprintf('%s: ', $this->stringifier->stringify($key, $depth + 1));
}
$items[$itemsCount] .= $this->stringifier->stringify($value, $depth + 1);
}
return $this->quoter->quote(sprintf('{ %s }', implode(', ', $items)), $depth);
}
/**
* @param mixed[] $array
*/
private function isSequential(array $array): bool
{
return array_keys($array) === range(0, count($array) - 1);
}
}
@@ -0,0 +1,33 @@
<?php
/*
* This file is part of Respect/Stringifier.
* Copyright (c) Henrique Moody <henriquemoody@gmail.com>
* SPDX-License-Identifier: MIT
*/
declare(strict_types=1);
namespace Respect\Stringifier\Stringifiers;
use Respect\Stringifier\Quoter;
use Respect\Stringifier\Stringifier;
use function is_bool;
final class BoolStringifier implements Stringifier
{
public function __construct(
private readonly Quoter $quoter
) {
}
public function stringify(mixed $raw, int $depth): ?string
{
if (!is_bool($raw)) {
return null;
}
return $this->quoter->quote($raw ? 'TRUE' : 'FALSE', $depth);
}
}
@@ -0,0 +1,85 @@
<?php
/*
* This file is part of Respect/Stringifier.
* Copyright (c) Henrique Moody <henriquemoody@gmail.com>
* SPDX-License-Identifier: MIT
*/
declare(strict_types=1);
namespace Respect\Stringifier\Stringifiers;
use Respect\Stringifier\Quoters\CodeQuoter;
use Respect\Stringifier\Stringifier;
final class ClusterStringifier implements Stringifier
{
/**
* @var Stringifier[]
*/
private array $stringifiers = [];
/**
* @param Stringifier[] ...$stringifiers
*/
public function __construct(Stringifier ...$stringifiers)
{
$this->setStringifiers($stringifiers);
}
public static function createDefault(): self
{
$quoter = new CodeQuoter();
$stringifier = new self();
$stringifier->setStringifiers([
new TraversableStringifier($stringifier, $quoter),
new DateTimeStringifier($stringifier, $quoter, 'c'),
new ThrowableStringifier($stringifier, $quoter),
new StringableObjectStringifier($stringifier),
new JsonSerializableStringifier($stringifier, $quoter),
new ObjectStringifier($stringifier, $quoter),
new ArrayStringifier($stringifier, $quoter, 3, 5),
new InfiniteStringifier($quoter),
new NanStringifier($quoter),
new ResourceStringifier($quoter),
new BoolStringifier($quoter),
new NullStringifier($quoter),
new JsonParsableStringifier(),
]);
return $stringifier;
}
/**
* @param Stringifier[] $stringifiers
*/
public function setStringifiers(array $stringifiers): void
{
$this->stringifiers = [];
foreach ($stringifiers as $stringifier) {
$this->addStringifier($stringifier);
}
}
public function addStringifier(Stringifier $stringifier): void
{
$this->stringifiers[] = $stringifier;
}
public function stringify(mixed $raw, int $depth): ?string
{
foreach ($this->stringifiers as $stringifier) {
$string = $stringifier->stringify($raw, $depth);
if ($string === null) {
continue;
}
return $string;
}
return null;
}
}
@@ -0,0 +1,43 @@
<?php
/*
* This file is part of Respect/Stringifier.
* Copyright (c) Henrique Moody <henriquemoody@gmail.com>
* SPDX-License-Identifier: MIT
*/
declare(strict_types=1);
namespace Respect\Stringifier\Stringifiers;
use DateTimeInterface;
use Respect\Stringifier\Quoter;
use Respect\Stringifier\Stringifier;
use function sprintf;
final class DateTimeStringifier implements Stringifier
{
public function __construct(
private readonly Stringifier $stringifier,
private readonly Quoter $quoter,
private readonly string $format
) {
}
public function stringify(mixed $raw, int $depth): ?string
{
if (!$raw instanceof DateTimeInterface) {
return null;
}
return $this->quoter->quote(
sprintf(
'[date-time] (%s: %s)',
$raw::class,
$this->stringifier->stringify($raw->format($this->format), $depth + 1)
),
$depth
);
}
}
@@ -0,0 +1,38 @@
<?php
/*
* This file is part of Respect/Stringifier.
* Copyright (c) Henrique Moody <henriquemoody@gmail.com>
* SPDX-License-Identifier: MIT
*/
declare(strict_types=1);
namespace Respect\Stringifier\Stringifiers;
use Respect\Stringifier\Quoter;
use Respect\Stringifier\Stringifier;
use function is_float;
use function is_infinite;
final class InfiniteStringifier implements Stringifier
{
public function __construct(
private readonly Quoter $quoter
) {
}
public function stringify(mixed $raw, int $depth): ?string
{
if (!is_float($raw)) {
return null;
}
if (!is_infinite($raw)) {
return null;
}
return $this->quoter->quote(($raw > 0 ? '' : '-') . 'INF', $depth);
}
}
@@ -0,0 +1,32 @@
<?php
/*
* This file is part of Respect/Stringifier.
* Copyright (c) Henrique Moody <henriquemoody@gmail.com>
* SPDX-License-Identifier: MIT
*/
declare(strict_types=1);
namespace Respect\Stringifier\Stringifiers;
use Respect\Stringifier\Stringifier;
use function json_encode;
use const JSON_PRESERVE_ZERO_FRACTION;
use const JSON_UNESCAPED_SLASHES;
use const JSON_UNESCAPED_UNICODE;
final class JsonParsableStringifier implements Stringifier
{
public function stringify(mixed $raw, int $depth): ?string
{
$string = json_encode($raw, (JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRESERVE_ZERO_FRACTION));
if ($string === false) {
return null;
}
return $string;
}
}
@@ -0,0 +1,42 @@
<?php
/*
* This file is part of Respect/Stringifier.
* Copyright (c) Henrique Moody <henriquemoody@gmail.com>
* SPDX-License-Identifier: MIT
*/
declare(strict_types=1);
namespace Respect\Stringifier\Stringifiers;
use JsonSerializable;
use Respect\Stringifier\Quoter;
use Respect\Stringifier\Stringifier;
use function sprintf;
final class JsonSerializableStringifier implements Stringifier
{
public function __construct(
private readonly Stringifier $stringifier,
private readonly Quoter $quoter
) {
}
public function stringify(mixed $raw, int $depth): ?string
{
if (!$raw instanceof JsonSerializable) {
return null;
}
return $this->quoter->quote(
sprintf(
'[json-serializable] (%s: %s)',
$raw::class,
$this->stringifier->stringify($raw->jsonSerialize(), $depth + 1)
),
$depth
);
}
}
@@ -0,0 +1,38 @@
<?php
/*
* This file is part of Respect/Stringifier.
* Copyright (c) Henrique Moody <henriquemoody@gmail.com>
* SPDX-License-Identifier: MIT
*/
declare(strict_types=1);
namespace Respect\Stringifier\Stringifiers;
use Respect\Stringifier\Quoter;
use Respect\Stringifier\Stringifier;
use function is_float;
use function is_nan;
final class NanStringifier implements Stringifier
{
public function __construct(
private readonly Quoter $quoter
) {
}
public function stringify(mixed $raw, int $depth): ?string
{
if (!is_float($raw)) {
return null;
}
if (!is_nan($raw)) {
return null;
}
return $this->quoter->quote('NaN', $depth);
}
}
@@ -0,0 +1,31 @@
<?php
/*
* This file is part of Respect/Stringifier.
* Copyright (c) Henrique Moody <henriquemoody@gmail.com>
* SPDX-License-Identifier: MIT
*/
declare(strict_types=1);
namespace Respect\Stringifier\Stringifiers;
use Respect\Stringifier\Quoter;
use Respect\Stringifier\Stringifier;
final class NullStringifier implements Stringifier
{
public function __construct(
private readonly Quoter $quoter
) {
}
public function stringify(mixed $raw, int $depth): ?string
{
if ($raw !== null) {
return null;
}
return $this->quoter->quote('NULL', $depth);
}
}
@@ -0,0 +1,43 @@
<?php
/*
* This file is part of Respect/Stringifier.
* Copyright (c) Henrique Moody <henriquemoody@gmail.com>
* SPDX-License-Identifier: MIT
*/
declare(strict_types=1);
namespace Respect\Stringifier\Stringifiers;
use Respect\Stringifier\Quoter;
use Respect\Stringifier\Stringifier;
use function get_object_vars;
use function is_object;
use function sprintf;
final class ObjectStringifier implements Stringifier
{
public function __construct(
private readonly Stringifier $stringifier,
private readonly Quoter $quoter
) {
}
public function stringify(mixed $raw, int $depth): ?string
{
if (!is_object($raw)) {
return null;
}
return $this->quoter->quote(
sprintf(
'[object] (%s: %s)',
$raw::class,
$this->stringifier->stringify(get_object_vars($raw), $depth + 1)
),
$depth
);
}
}
@@ -0,0 +1,41 @@
<?php
/*
* This file is part of Respect/Stringifier.
* Copyright (c) Henrique Moody <henriquemoody@gmail.com>
* SPDX-License-Identifier: MIT
*/
declare(strict_types=1);
namespace Respect\Stringifier\Stringifiers;
use Respect\Stringifier\Quoter;
use Respect\Stringifier\Stringifier;
use function get_resource_type;
use function is_resource;
use function sprintf;
final class ResourceStringifier implements Stringifier
{
public function __construct(
private readonly Quoter $quoter
) {
}
public function stringify(mixed $raw, int $depth): ?string
{
if (!is_resource($raw)) {
return null;
}
return $this->quoter->quote(
sprintf(
'[resource] (%s)',
get_resource_type($raw)
),
$depth
);
}
}
@@ -0,0 +1,37 @@
<?php
/*
* This file is part of Respect/Stringifier.
* Copyright (c) Henrique Moody <henriquemoody@gmail.com>
* SPDX-License-Identifier: MIT
*/
declare(strict_types=1);
namespace Respect\Stringifier\Stringifiers;
use Respect\Stringifier\Stringifier;
use function is_object;
use function method_exists;
final class StringableObjectStringifier implements Stringifier
{
public function __construct(
private readonly Stringifier $stringifier
) {
}
public function stringify(mixed $raw, int $depth): ?string
{
if (!is_object($raw)) {
return null;
}
if (!method_exists($raw, '__toString')) {
return null;
}
return $this->stringifier->stringify($raw->__toString(), $depth);
}
}
@@ -0,0 +1,60 @@
<?php
/*
* This file is part of Respect/Stringifier.
* Copyright (c) Henrique Moody <henriquemoody@gmail.com>
* SPDX-License-Identifier: MIT
*/
declare(strict_types=1);
namespace Respect\Stringifier\Stringifiers;
use Respect\Stringifier\Quoter;
use Respect\Stringifier\Stringifier;
use Throwable;
use function getcwd;
use function sprintf;
use function str_replace;
final class ThrowableStringifier implements Stringifier
{
public function __construct(
private readonly Stringifier $stringifier,
private readonly Quoter $quoter
) {
}
public function stringify(mixed $raw, int $depth): ?string
{
if (!$raw instanceof Throwable) {
return null;
}
return $this->quoter->quote(
sprintf(
'[throwable] (%s: %s)',
$raw::class,
$this->stringifier->stringify($this->getData($raw), $depth + 1)
),
$depth
);
}
/**
* @return mixed[]
*/
private function getData(Throwable $throwable): array
{
return [
'message' => $throwable->getMessage(),
'code' => $throwable->getCode(),
'file' => sprintf(
'%s:%d',
str_replace(getcwd() . '/', '', $throwable->getFile()),
$throwable->getLine()
),
];
}
}
@@ -0,0 +1,43 @@
<?php
/*
* This file is part of Respect/Stringifier.
* Copyright (c) Henrique Moody <henriquemoody@gmail.com>
* SPDX-License-Identifier: MIT
*/
declare(strict_types=1);
namespace Respect\Stringifier\Stringifiers;
use Respect\Stringifier\Quoter;
use Respect\Stringifier\Stringifier;
use Traversable;
use function iterator_to_array;
use function sprintf;
final class TraversableStringifier implements Stringifier
{
public function __construct(
private readonly Stringifier $stringifier,
private readonly Quoter $quoter
) {
}
public function stringify(mixed $raw, int $depth): ?string
{
if (!$raw instanceof Traversable) {
return null;
}
return $this->quoter->quote(
sprintf(
'[traversable] (%s: %s)',
$raw::class,
$this->stringifier->stringify(iterator_to_array($raw), $depth + 1)
),
$depth
);
}
}
+24
View File
@@ -0,0 +1,24 @@
<?php
/*
* This file is part of Respect/Stringifier.
* Copyright (c) Henrique Moody <henriquemoody@gmail.com>
* SPDX-License-Identifier: MIT
*/
declare(strict_types=1);
namespace Respect\Stringifier;
use Respect\Stringifier\Stringifiers\ClusterStringifier;
function stringify(mixed $value): string
{
static $stringifier;
if ($stringifier === null) {
$stringifier = ClusterStringifier::createDefault();
}
return $stringifier->stringify($value, 0) ?? '#ERROR#';
}
+164
View File
@@ -0,0 +1,164 @@
# Changes in Respect\Validation 2.x
## 2.3
Versioning Changes:
- Dropped support for PHP 8.0 and below.
- Updated dev dependencies
Deprecations:
- Symfony façade validators are no longer supported and were
removed.
Fixes:
- `KeySet` now reports which extra keys are causing the rule to fail.
- Ensure empty strings are never a valid currency code
- Do not hide messages on EachException
- Dot not throw exception when validating an uninitialized property
Changes:
- You can no longer wrap `KeySet` in `Not`.
- `Phone` now uses `giggsey/libphonenumber-for-php`, this package needs
to be installed if you want to use this validator.
- `Phone` now supports the parameter `$countryCode` to validate phones
of a specific country.
## 2.2.4
Meta:
- CHANGELOG.md is being written once again to provide an overview
of active changes to the API and codebase.
Versioning Changes:
- Dropped PHP 7.3 support.
- Added support for PHP 8.0 and PHP 8.1. This will be the
last release with PHP 7.4 support. Support for PHP 8.2 is considered
experimental, local development should be done at 8.1.
Deprecations:
- Zend Framework façade validators are no longer supported and were
removed.
- Symfony façade validators are no longer suggested, and will be
removed in release 2.3.
- v::dateTime('z') is not supported anymore in PHP8, and should not be relied upon
Fixes:
- Updated bin/update-currency-codes to fetch XML from another source.
- Updated bin/update-iso-codes to new file format.
- Updated regionals (CountryCode.php, CurrencyCode.php, Tld.php) (2023-02-13).
- Added RuPay card validation (thanks @rakshit087)
- Fixed `v::decimal()` for float values (thanks @scruwi)
- Added `v::portugueseNif()` to validate _Número de Identificação Fiscal_ in Portugal (thanks @goncalo-andrade).
- Allow 5-digit and 6-digit postal codes for Cambodia (thanks @omega3000)
- `v::intval()` now handles negative values with trailing zeroes better (thanks @l-x)
## 2.2.x
Changelogs between 1.1.0 and 2.2.4 are available only through `git log` and GitHub Releases.
# Changes in Respect\Validation 1.x
All notable changes of the Respect\Validation releases are documented in this file.
## 1.1.0 - 2016-04-24
### Added
- Create "Fibonacci" rule (#637)
- Create "IdentityCard" rule (#632)
- Create "Image" rule (#621)
- Create "LanguageCode" rule (#597)
- Create "Pesel" rule (#616)
- Create "PhpLabel" rule (#652)
### Changed
- Allow the define brands for credit card validation (#661)
- Define names for the child of Not rule (#641)
- Ensure namespace separator on appended prefixes (#666)
- Length gets length of integers (#643)
- Set template for the only rule in the chain (#663)
- Throw an exception when age is not an integer (#667)
- Use "{less/greater} than or equal to" phrasing (#604)
## 1.0.0 - 2015-10-24
### Added
- Add "alpha-3" and "numeric" formats for "CountryCode" rule (#530)
- Add support for PHP 7 (#426)
- Create "BoolVal" rule (#583)
- Create "Bsn" rule (#450)
- Create "CallableType" rule (#397)
- Create "Countable" rule (#566)
- Create "CurrencyCode" rule (#567)
- Create "Extension" rule (#360)
- Create "Factor" rule (#405)
- Create "Finite" rule (#397)
- Create "FloatType" rule (#565)
- Create "Identical" rule (#442)
- Create "Imei" rule (#590)
- Create "Infinite" rule (#397)
- Create "IntType" rule (#451)
- Create "Iterable" rule (#570)
- Create "KeyNested" rule (#429)
- Create "KeySet" rule (#374)
- Create "KeyValue" rule (#441)
- Create "Mimetype" rule (#361)
- Create "NotBlank" rule (#443)
- Create "NotOptional" rule (#448)
- Create "Optional" rule (#423)
- Create "ResourceType" rule (#397)
- Create "ScalarVal" rule (#397)
- Create "Size" rule (#359)
- Create "SubdivisionCode" rule for 252 countries (#411)
- Create "VideoUrl" rule (#410)
- Create method `getMessages()` for nested exceptions (#406)
### Changed
- Add country code to the message of "PostalCode" exception rule (#413)
- Make "ArrayVal" validate only if the input can be used as an array (#574)
- Make "Between" rule inclusive (#445)
- Make "Max" rule inclusive (#445)
- Make "Min" rule inclusive (#445)
- New generic top-level domains (#368)
- On `AbstractRelated` (`Attribute`, `Call` and `Key`) define names for child rules (#365)
- On exceptions, convert `Array` to string (#387)
- On exceptions, convert `Exception` to string (#399)
- On exceptions, convert `Traversable` to string (#399)
- On exceptions, convert resources to string (#399)
- On exceptions, do not display parent message then rule has only one child (#407)
- On exceptions, improve `Object` conversion to string (#399)
- On exceptions, improve conversion of all values by using JSON (#399)
- On exceptions, nested messages are displayed in a Markdown list (#588)
- Rename exception class "AbstractGroupedException" to "GroupedValidationException" (#591)
- Rename exception class "AbstractNestedException" to "NestedValidationException" (#591)
- Rename rule "Arr" to "ArrayVal"
- Rename rule "Bool" to "BoolType" (#426)
- Rename rule "False" to "FalseVal" (#426)
- Rename rule "Float" to "FloatVal" (#426)
- Rename rule "Int" to "IntVal" (#426)
- Rename rule "NullValue" to "NullType"
- Rename rule "Object" to "ObjectType"
- Rename rule "String" to "StringType" (#426)
- Rename rule "True" to "TrueVal" (#426)
- Use `filter_var()` on "TrueVal" and "FalseVal" rules (#409)
### Removed
- Drop support for PHP 5.3 (#466)
- Remove `addOr()` shortcut (#444)
- Remove `NestedValidationExceptionInterface` interface (#591)
- Remove `not()` shortcut (#444)
- Remove `ValidationExceptionInterface` interface (#591)
- Remove identical checking from "Equals" rule (#442)
- Removed Deprecated Rules (#277)
- Validation rules do not accept an empty string by default (#422)
+205
View File
@@ -0,0 +1,205 @@
# Contributing
Contributions to Respect\Validation are always welcome. You make our lives
easier by sending us your contributions through [pull requests][].
Pull requests for bug fixes must be based on the oldest stable version's branch
whereas pull requests for new features must be based on the `master` branch.
Due to time constraints, we are not always able to respond as quickly as we
would like. Please do not take delays personal and feel free to remind us here,
on IRC, or on Gitter if you feel that we forgot to respond.
Please see the [project documentation][] before proceeding. You should also know
about [PHP-FIG][]'s standards and basic unit testing, but we're sure you can
learn that just by looking at other rules. Pick the simple ones like `ArrayType`
to begin.
Before writing anything, feature or bug fix:
- Check if there is already an issue related to it (opened or closed) and if
someone is already working on that;
- If there is not, [open an issue][] and notify everybody that you're going
to work on that;
- If there is, create a comment to notify everybody that you're going to
work on that.
- Make sure that what you need is not done yet
## Adding a new validator
A common validator (rule) on Respect\Validation is composed of three classes:
* `library/Rules/YourRuleName.php`: the rule itself
* `library/Exceptions/YourRuleNameException.php`: the exception thrown by the rule
* `tests/unit/Rules/YourRuleNameTest.php`: tests for the rule
The classes are pretty straightforward. In the sample below, we're going to
create a validator that validates if a string is equal to "Hello World".
- Classes should be `final` unless they are used in a different scope;
- Properties should be `private` unless they are used in a different scope;
- Classes should use strict typing;
- Some docblocks are required.
### Creating the rule
The rule itself needs to implement the `Validatable` interface but, it is
convenient to just extend the `AbstractRule` class.
Doing that, you'll only need to declare one method: `isValid(mixed $input): bool`.
This method must return `true` or `false`.
If your validator class is `HelloWorld`, it will be available as `v::helloWorld()`
and will natively have support for chaining and everything else.
```php
<?php
/*
* Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
* SPDX-License-Identifier: MIT
*/
declare(strict_types=1);
namespace Respect\Validation\Rules;
use Respect\Validation\Rules\Core\Simple;
/**
* Explain in one sentence what this rule does.
*
* @author Your Name <youremail@yourdomain.tld>
*/
final class HelloWorld extends Simple
{
public function isValid(mixed $input): bool
{
return $input === 'Hello World';
}
}
```
### Creating unit tests
Finally, we need to test if everything is running smooth. We have `RuleTestCase`
that allows us to make easier to test rules, but you fell free to use the
`PHPUnit\Framework\TestCase` if you want or you need it's necessary.
The `RuleTestCase` extends PHPUnit's `PHPUnit\Framework\TestCase` class, so you
are able to use any methods of it. By extending `RuleTestCase` you should
implement two methods that should return a [data provider][] with the rule as
first item of the arrays:
- `providerForValidInput`: Will test when `isValid()` should return `true`
- `providerForInvalidInput`: Will test when `isValid()` should return `false`
```php
<?php
/*
* Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
* SPDX-License-Identifier: MIT
*/
declare(strict_types=1);
namespace Respect\Validation\Rules;
use Respect\Validation\Test\RuleTestCase;
/**
* @group rule
*
* @covers \Respect\Validation\Rules\HelloWorld
*
* @author Your Name <youremail@yourdomain.tld>
*/
final class HelloWorldTest extends RuleTestCase
{
/**
* {@inheritDoc}
*/
public static function providerForValidInput(): array
{
$rule = new HelloWorld();
return [
[$rule, 'Hello World'],
];
}
/**
* {@inheritDoc}
*/
public static function providerForInvalidInput(): array
{
$rule = new HelloWorld();
return [
[$rule, 'Not a hello'],
[$rule, 'Hello darkness, my old friend'],
[$rule, 'Hello is it me you\'re looking for?'],
];
}
}
```
If the constructor of your rule accepts arguments you may create specific tests
for it other than what is covered by `RuleTestCase`.
### Helping us a little bit more
You rule will be accepted only with these 3 files (rule, exception and unit test),
but if you really want to help us, you can follow the example of [ArrayType][] by:
- Adding your new rule on the `Validator`'s class docblock;
- Writing a documentation for your new rule;
- Creating integration tests with PHPT.
As we already said, none of them are required but you will help us a lot.
## Documentation
Our docs at https://respect-validation.readthedocs.io are generated from our
Markdown files. Add your brand new rule and it should be soon available.
## Running Tests
After run `composer install` on the library's root directory you must run PHPUnit.
### Linux
You can test the project using the commands:
```sh
$ vendor/bin/phpunit
```
or
```sh
$ composer phpunit
```
### Windows
You can test the project using the commands:
```sh
> vendor\bin\phpunit
```
or
```sh
> composer phpunit
```
No test should fail.
You can tweak the PHPUnit's settings by copying `phpunit.xml.dist` to `phpunit.xml`
and changing it according to your needs.
[ArrayType]: https://github.com/Respect/Validation/commit/f08a1fa
[data provider]: https://phpunit.de/manual/current/en/writing-tests-for-phpunit.html#writing-tests-for-phpunit.data-providers "PHPUnit Data Providers"
[open an issue]: http://github.com/Respect/Validation/issues
[PHP-FIG]: http://www.php-fig.org "PHP Framework Interop Group"
[project documentation]: https://respect-validation.readthedocs.io/ "Respect\Validation documentation"
[pull requests]: http://help.github.com/pull-requests "GitHub pull requests"
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
+19
View File
@@ -0,0 +1,19 @@
# Respect\Validation
[![Build Status](https://img.shields.io/github/actions/workflow/status/Respect/Validation/continuous-integration.yml?branch=master&style=flat-square)](https://github.com/Respect/Validation/actions/workflows/continuous-integration.yml)
[![Code Coverage](https://img.shields.io/codecov/c/github/Respect/Validation?style=flat-square)](https://codecov.io/gh/Respect/Validation)
[![Latest Stable Version](https://img.shields.io/packagist/v/respect/validation.svg?style=flat-square)](https://packagist.org/packages/respect/validation)
[![Total Downloads](https://img.shields.io/packagist/dt/respect/validation.svg?style=flat-square)](https://packagist.org/packages/respect/validation)
[![License](https://img.shields.io/packagist/l/respect/validation.svg?style=flat-square)](https://packagist.org/packages/respect/validation)
The most awesome validation engine ever created for PHP.
- Complex rules made simple: `v::numericVal()->positive()->between(1, 255)->isValid($input)`.
- [Granularity control](docs/02-feature-guide.md#validation-methods) for advanced reporting.
- [More than 150](docs/08-list-of-rules-by-category.md) (fully tested) validation rules.
- [A concrete API](docs/05-concrete-api.md) for non fluent usage.
Learn More:
* [Documentation](https://respect-validation.readthedocs.io)
* [How to contribute](CONTRIBUTING.md)
+73
View File
@@ -0,0 +1,73 @@
{
"name": "respect/validation",
"description": "The most awesome validation engine ever created for PHP",
"keywords": ["respect", "validation", "validator"],
"type": "library",
"homepage": "http://respect.github.io/Validation/",
"license": "MIT",
"authors": [
{
"name": "Respect/Validation Contributors",
"homepage": "https://github.com/Respect/Validation/graphs/contributors"
}
],
"config": {
"sort-packages": true,
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"require": {
"php": ">=8.1",
"respect/stringifier": "^0.2.0 || ^1.0",
"symfony/polyfill-mbstring": "^1.2"
},
"require-dev": {
"egulias/email-validator": "^3.0 || ^4.0",
"giggsey/libphonenumber-for-php-lite": "^8.13 || ^9.0",
"malukenho/docheader": "^1.0",
"mikey179/vfsstream": "^1.6",
"phpstan/phpstan": "^1.9",
"phpstan/phpstan-deprecation-rules": "^1.1",
"phpstan/phpstan-phpunit": "^1.3",
"phpunit/phpunit": "^9.6",
"psr/http-message": "^1.0",
"respect/coding-standard": "^4.0",
"squizlabs/php_codesniffer": "^3.7"
},
"suggest": {
"ext-bcmath": "Arbitrary Precision Mathematics",
"ext-fileinfo": "File Information",
"ext-mbstring": "Multibyte String Functions",
"egulias/email-validator": "Improves the Email rule if available",
"giggsey/libphonenumber-for-php-lite": "Enables the phone rule if available"
},
"autoload": {
"psr-4": {
"Respect\\Validation\\": "library/"
}
},
"autoload-dev": {
"psr-4": {
"Respect\\Validation\\": "tests/unit/",
"Respect\\Validation\\Test\\": "tests/library/"
},
"files": [
"tests/integration/lib/helpers.php"
]
},
"scripts": {
"docheader": "vendor/bin/docheader check library/ tests/",
"phpcs": "vendor/bin/phpcs",
"phpstan": "vendor/bin/phpstan analyze",
"phpunit": "vendor/bin/phpunit",
"phpunit-integration": "vendor/bin/phpunit --testsuite=integration",
"phpunit-unit": "vendor/bin/phpunit --testsuite=unit",
"qa": [
"@docheader",
"@phpcs",
"@phpstan",
"@phpunit"
]
}
}
@@ -0,0 +1,11 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'COM.AC',
'EDU.AC',
'GOV.AC',
'MIL.AC',
'NET.AC',
'ORG.AC',
];
@@ -0,0 +1,12 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'AC.AE',
'CO.AE',
'GOV.AE',
'MIL.AE',
'NET.AE',
'ORG.AE',
'SCH.AE',
];
@@ -0,0 +1,93 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'ACCIDENT-INVESTIGATION.AERO',
'ACCIDENT-PREVENTION.AERO',
'AEROBATIC.AERO',
'AEROCLUB.AERO',
'AERODROME.AERO',
'AGENTS.AERO',
'AIR-SURVEILLANCE.AERO',
'AIR-TRAFFIC-CONTROL.AERO',
'AIRCRAFT.AERO',
'AIRLINE.AERO',
'AIRPORT.AERO',
'AIRTRAFFIC.AERO',
'AMBULANCE.AERO',
'ASSOCIATION.AERO',
'AUTHOR.AERO',
'BALLOONING.AERO',
'BROKER.AERO',
'CAA.AERO',
'CARGO.AERO',
'CATERING.AERO',
'CERTIFICATION.AERO',
'CHAMPIONSHIP.AERO',
'CHARTER.AERO',
'CIVILAVIATION.AERO',
'CLUB.AERO',
'CONFERENCE.AERO',
'CONSULTANT.AERO',
'CONSULTING.AERO',
'CONTROL.AERO',
'COUNCIL.AERO',
'CREW.AERO',
'DESIGN.AERO',
'DGCA.AERO',
'EDUCATOR.AERO',
'EMERGENCY.AERO',
'ENGINE.AERO',
'ENGINEER.AERO',
'ENTERTAINMENT.AERO',
'EQUIPMENT.AERO',
'EXCHANGE.AERO',
'EXPRESS.AERO',
'FEDERATION.AERO',
'FLIGHT.AERO',
'FREIGHT.AERO',
'FUEL.AERO',
'GLIDING.AERO',
'GOVERNMENT.AERO',
'GROUNDHANDLING.AERO',
'GROUP.AERO',
'HANGGLIDING.AERO',
'HOMEBUILT.AERO',
'INSURANCE.AERO',
'JOURNAL.AERO',
'JOURNALIST.AERO',
'LEASING.AERO',
'LOGISTICS.AERO',
'MAGAZINE.AERO',
'MAINTENANCE.AERO',
'MARKETPLACE.AERO',
'MEDIA.AERO',
'MICROLIGHT.AERO',
'MODELLING.AERO',
'NAVIGATION.AERO',
'PARACHUTING.AERO',
'PARAGLIDING.AERO',
'PASSENGER-ASSOCIATION.AERO',
'PILOT.AERO',
'PRESS.AERO',
'PRODUCTION.AERO',
'RECREATION.AERO',
'REPBODY.AERO',
'RES.AERO',
'RESEARCH.AERO',
'ROTORCRAFT.AERO',
'SAFETY.AERO',
'SCIENTIST.AERO',
'SERVICES.AERO',
'SHOW.AERO',
'SKYDIVING.AERO',
'SOFTWARE.AERO',
'STUDENT.AERO',
'TAXI.AERO',
'TRADER.AERO',
'TRADING.AERO',
'TRAINER.AERO',
'UNION.AERO',
'WORKINGGROUP.AERO',
'WORKS.AERO',
];
@@ -0,0 +1,10 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'COM.AF',
'EDU.AF',
'GOV.AF',
'NET.AF',
'ORG.AF',
];
@@ -0,0 +1,10 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'CO.AG',
'COM.AG',
'NET.AG',
'NOM.AG',
'ORG.AG',
];
@@ -0,0 +1,9 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'COM.AI',
'NET.AI',
'OFF.AI',
'ORG.AI',
];
@@ -0,0 +1,11 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'COM.AL',
'EDU.AL',
'GOV.AL',
'MIL.AL',
'NET.AL',
'ORG.AL',
];
@@ -0,0 +1,10 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'CO.AM',
'COM.AM',
'COMMUNE.AM',
'NET.AM',
'ORG.AM',
];
@@ -0,0 +1,14 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'CO.AO',
'ED.AO',
'EDU.AO',
'GOV.AO',
'GV.AO',
'IT.AO',
'OG.AO',
'ORG.AO',
'PB.AO',
];
@@ -0,0 +1,20 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'BET.AR',
'COM.AR',
'COOP.AR',
'EDU.AR',
'GOB.AR',
'GOV.AR',
'INT.AR',
'MIL.AR',
'MUSICA.AR',
'MUTUAL.AR',
'NET.AR',
'ORG.AR',
'SEG.AR',
'SENASA.AR',
'TUR.AR',
];
@@ -0,0 +1,12 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'E164.ARPA',
'HOME.ARPA',
'IN-ADDR.ARPA',
'IP6.ARPA',
'IRIS.ARPA',
'URI.ARPA',
'URN.ARPA',
];
@@ -0,0 +1,6 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'GOV.AS',
];
@@ -0,0 +1,10 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'AC.AT',
'CO.AT',
'GV.AT',
'OR.AT',
'STH.AC.AT',
];
@@ -0,0 +1,36 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'ACT.AU',
'ACT.EDU.AU',
'ASN.AU',
'CATHOLIC.EDU.AU',
'COM.AU',
'CONF.AU',
'EDU.AU',
'GOV.AU',
'ID.AU',
'NET.AU',
'NSW.AU',
'NSW.EDU.AU',
'NT.AU',
'NT.EDU.AU',
'ORG.AU',
'OZ.AU',
'QLD.AU',
'QLD.EDU.AU',
'QLD.GOV.AU',
'SA.AU',
'SA.EDU.AU',
'SA.GOV.AU',
'TAS.AU',
'TAS.EDU.AU',
'TAS.GOV.AU',
'VIC.AU',
'VIC.EDU.AU',
'VIC.GOV.AU',
'WA.AU',
'WA.EDU.AU',
'WA.GOV.AU',
];
@@ -0,0 +1,6 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'COM.AW',
];
@@ -0,0 +1,18 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'BIZ.AZ',
'CO.AZ',
'COM.AZ',
'EDU.AZ',
'GOV.AZ',
'INFO.AZ',
'INT.AZ',
'MIL.AZ',
'NAME.AZ',
'NET.AZ',
'ORG.AZ',
'PP.AZ',
'PRO.AZ',
];
@@ -0,0 +1,11 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'COM.BA',
'EDU.BA',
'GOV.BA',
'MIL.BA',
'NET.BA',
'ORG.BA',
];
@@ -0,0 +1,15 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'BIZ.BB',
'CO.BB',
'COM.BB',
'EDU.BB',
'GOV.BB',
'INFO.BB',
'NET.BB',
'ORG.BB',
'STORE.BB',
'TV.BB',
];
@@ -0,0 +1,19 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'AC.BD',
'AI.BD',
'CO.BD',
'COM.BD',
'EDU.BD',
'GOV.BD',
'ID.BD',
'INFO.BD',
'IT.BD',
'MIL.BD',
'NET.BD',
'ORG.BD',
'SCH.BD',
'TV.BD',
];
@@ -0,0 +1,6 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'AC.BE',
];
@@ -0,0 +1,6 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'GOV.BF',
];
@@ -0,0 +1,41 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'0.BG',
'1.BG',
'2.BG',
'3.BG',
'4.BG',
'5.BG',
'6.BG',
'7.BG',
'8.BG',
'9.BG',
'A.BG',
'B.BG',
'C.BG',
'D.BG',
'E.BG',
'F.BG',
'G.BG',
'H.BG',
'I.BG',
'J.BG',
'K.BG',
'L.BG',
'M.BG',
'N.BG',
'O.BG',
'P.BG',
'Q.BG',
'R.BG',
'S.BG',
'T.BG',
'U.BG',
'V.BG',
'W.BG',
'X.BG',
'Y.BG',
'Z.BG',
];
@@ -0,0 +1,10 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'COM.BH',
'EDU.BH',
'GOV.BH',
'NET.BH',
'ORG.BH',
];
@@ -0,0 +1,10 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'CO.BI',
'COM.BI',
'EDU.BI',
'OR.BI',
'ORG.BI',
];
@@ -0,0 +1,25 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'AFRICA.BJ',
'AGRO.BJ',
'ARCHITECTES.BJ',
'ASSUR.BJ',
'AVOCATS.BJ',
'CO.BJ',
'COM.BJ',
'ECO.BJ',
'ECONO.BJ',
'EDU.BJ',
'INFO.BJ',
'LOISIRS.BJ',
'MONEY.BJ',
'NET.BJ',
'ORG.BJ',
'OTE.BJ',
'RESTAURANT.BJ',
'RESTO.BJ',
'TOURISM.BJ',
'UNIV.BJ',
];
@@ -0,0 +1,10 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'COM.BM',
'EDU.BM',
'GOV.BM',
'NET.BM',
'ORG.BM',
];
@@ -0,0 +1,10 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'COM.BN',
'EDU.BN',
'GOV.BN',
'NET.BN',
'ORG.BN',
];
@@ -0,0 +1,46 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'ACADEMIA.BO',
'AGRO.BO',
'ARTE.BO',
'BLOG.BO',
'BOLIVIA.BO',
'CIENCIA.BO',
'COM.BO',
'COOPERATIVA.BO',
'DEMOCRACIA.BO',
'DEPORTE.BO',
'ECOLOGIA.BO',
'ECONOMIA.BO',
'EDU.BO',
'EMPRESA.BO',
'GOB.BO',
'INDIGENA.BO',
'INDUSTRIA.BO',
'INFO.BO',
'INT.BO',
'MEDICINA.BO',
'MIL.BO',
'MOVIMIENTO.BO',
'MUSICA.BO',
'NATURAL.BO',
'NET.BO',
'NOMBRE.BO',
'NOTICIAS.BO',
'ORG.BO',
'PATRIA.BO',
'PLURINACIONAL.BO',
'POLITICA.BO',
'PROFESIONAL.BO',
'PUEBLO.BO',
'REVISTA.BO',
'SALUD.BO',
'TECNOLOGIA.BO',
'TKSAT.BO',
'TRANSPORTE.BO',
'TV.BO',
'WEB.BO',
'WIKI.BO',
];
@@ -0,0 +1,179 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'9GUACU.BR',
'ABC.BR',
'AC.GOV.BR',
'ADM.BR',
'ADV.BR',
'AGR.BR',
'AJU.BR',
'AL.GOV.BR',
'AM.BR',
'AM.GOV.BR',
'ANANI.BR',
'AP.GOV.BR',
'APARECIDA.BR',
'API.BR',
'APP.BR',
'ARQ.BR',
'ART.BR',
'ATO.BR',
'B.BR',
'BA.GOV.BR',
'BARUERI.BR',
'BELEM.BR',
'BET.BR',
'BHZ.BR',
'BIB.BR',
'BIO.BR',
'BLOG.BR',
'BMD.BR',
'BOAVISTA.BR',
'BSB.BR',
'CAMPINAGRANDE.BR',
'CAMPINAS.BR',
'CAXIAS.BR',
'CE.GOV.BR',
'CIM.BR',
'CNG.BR',
'CNT.BR',
'COM.BR',
'CONTAGEM.BR',
'COOP.BR',
'COZ.BR',
'CRI.BR',
'CUIABA.BR',
'CURITIBA.BR',
'DEF.BR',
'DES.BR',
'DET.BR',
'DEV.BR',
'DF.GOV.BR',
'ECN.BR',
'ECO.BR',
'EDU.BR',
'EMP.BR',
'ENF.BR',
'ENG.BR',
'ES.GOV.BR',
'ESP.BR',
'ETC.BR',
'ETI.BR',
'FAR.BR',
'FEIRA.BR',
'FLOG.BR',
'FLORIPA.BR',
'FM.BR',
'FND.BR',
'FORTAL.BR',
'FOT.BR',
'FOZ.BR',
'FST.BR',
'G12.BR',
'GEO.BR',
'GGF.BR',
'GO.GOV.BR',
'GOIANIA.BR',
'GOV.BR',
'GRU.BR',
'IA.BR',
'IMB.BR',
'IND.BR',
'INF.BR',
'JAB.BR',
'JAMPA.BR',
'JDF.BR',
'JOINVILLE.BR',
'JOR.BR',
'JUS.BR',
'LEG.BR',
'LEILAO.BR',
'LEL.BR',
'LOG.BR',
'LONDRINA.BR',
'MA.GOV.BR',
'MACAPA.BR',
'MACEIO.BR',
'MANAUS.BR',
'MARINGA.BR',
'MAT.BR',
'MED.BR',
'MG.GOV.BR',
'MIL.BR',
'MORENA.BR',
'MP.BR',
'MS.GOV.BR',
'MT.GOV.BR',
'MUS.BR',
'NATAL.BR',
'NET.BR',
'NITEROI.BR',
'NOM.BR',
'NOT.BR',
'NTR.BR',
'ODO.BR',
'ONG.BR',
'ORG.BR',
'OSASCO.BR',
'PA.GOV.BR',
'PALMAS.BR',
'PB.GOV.BR',
'PE.GOV.BR',
'PI.GOV.BR',
'POA.BR',
'PPG.BR',
'PR.GOV.BR',
'PRO.BR',
'PSC.BR',
'PSI.BR',
'PVH.BR',
'QSL.BR',
'RADIO.BR',
'REC.BR',
'RECIFE.BR',
'REP.BR',
'RIBEIRAO.BR',
'RIO.BR',
'RIOBRANCO.BR',
'RIOPRETO.BR',
'RJ.GOV.BR',
'RN.GOV.BR',
'RO.GOV.BR',
'RR.GOV.BR',
'RS.GOV.BR',
'SALVADOR.BR',
'SAMPA.BR',
'SANTAMARIA.BR',
'SANTOANDRE.BR',
'SAOBERNARDO.BR',
'SAOGONCA.BR',
'SC.GOV.BR',
'SE.GOV.BR',
'SEG.BR',
'SJC.BR',
'SLG.BR',
'SLZ.BR',
'SOCIAL.BR',
'SOROCABA.BR',
'SP.GOV.BR',
'SRV.BR',
'TAXI.BR',
'TC.BR',
'TEC.BR',
'TEO.BR',
'THE.BR',
'TMP.BR',
'TO.GOV.BR',
'TRD.BR',
'TUR.BR',
'TV.BR',
'UDI.BR',
'VET.BR',
'VIX.BR',
'VLOG.BR',
'WIKI.BR',
'XYZ.BR',
'ZLG.BR',
];
@@ -0,0 +1,10 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'COM.BS',
'EDU.BS',
'GOV.BS',
'NET.BS',
'ORG.BS',
];
@@ -0,0 +1,10 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'COM.BT',
'EDU.BT',
'GOV.BT',
'NET.BT',
'ORG.BT',
];
@@ -0,0 +1,10 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'AC.BW',
'CO.BW',
'GOV.BW',
'NET.BW',
'ORG.BW',
];
@@ -0,0 +1,9 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'COM.BY',
'GOV.BY',
'MIL.BY',
'OF.BY',
];
@@ -0,0 +1,11 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'CO.BZ',
'COM.BZ',
'EDU.BZ',
'GOV.BZ',
'NET.BZ',
'ORG.BZ',
];
@@ -0,0 +1,20 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'AB.CA',
'BC.CA',
'GC.CA',
'MB.CA',
'NB.CA',
'NF.CA',
'NL.CA',
'NS.CA',
'NT.CA',
'NU.CA',
'ON.CA',
'PE.CA',
'QC.CA',
'SK.CA',
'YK.CA',
];
@@ -0,0 +1,6 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'GOV.CD',
];
@@ -0,0 +1,18 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'AC.CI',
'ASSO.CI',
'CO.CI',
'COM.CI',
'ED.CI',
'EDU.CI',
'GO.CI',
'GOUV.CI',
'INT.CI',
'NET.CI',
'OR.CI',
'ORG.CI',
'XN--AROPORT-BYA.CI',
];
@@ -0,0 +1,6 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'WWW.CK',
];
@@ -0,0 +1,9 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'CO.CL',
'GOB.CL',
'GOV.CL',
'MIL.CL',
];
@@ -0,0 +1,9 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'CO.CM',
'COM.CM',
'GOV.CM',
'NET.CM',
];
@@ -0,0 +1,49 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'AC.CN',
'AH.CN',
'BJ.CN',
'COM.CN',
'CQ.CN',
'EDU.CN',
'FJ.CN',
'GD.CN',
'GOV.CN',
'GS.CN',
'GX.CN',
'GZ.CN',
'HA.CN',
'HB.CN',
'HE.CN',
'HI.CN',
'HK.CN',
'HL.CN',
'HN.CN',
'JL.CN',
'JS.CN',
'JX.CN',
'LN.CN',
'MIL.CN',
'MO.CN',
'NET.CN',
'NM.CN',
'NX.CN',
'ORG.CN',
'QH.CN',
'SC.CN',
'SD.CN',
'SH.CN',
'SN.CN',
'SX.CN',
'TJ.CN',
'TW.CN',
'XJ.CN',
'XN--55QX5D.CN',
'XN--IO0A7I.CN',
'XN--OD0ALG.CN',
'XZ.CN',
'YN.CN',
'ZJ.CN',
];
@@ -0,0 +1,12 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'COM.CO',
'EDU.CO',
'GOV.CO',
'MIL.CO',
'NET.CO',
'NOM.CO',
'ORG.CO',
];
@@ -0,0 +1,12 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'AC.CR',
'CO.CR',
'ED.CR',
'FI.CR',
'GO.CR',
'OR.CR',
'SA.CR',
];
@@ -0,0 +1,12 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'COM.CU',
'EDU.CU',
'GOB.CU',
'INF.CU',
'NAT.CU',
'NET.CU',
'ORG.CU',
];
@@ -0,0 +1,13 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'COM.CV',
'EDU.CV',
'ID.CV',
'INT.CV',
'NET.CV',
'NOME.CV',
'ORG.CV',
'PUBL.CV',
];
@@ -0,0 +1,9 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'COM.CW',
'EDU.CW',
'NET.CW',
'ORG.CW',
];
@@ -0,0 +1,6 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'GOV.CX',
];
@@ -0,0 +1,17 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'AC.CY',
'BIZ.CY',
'COM.CY',
'EKLOGES.CY',
'GOV.CY',
'LTD.CY',
'MIL.CY',
'NET.CY',
'ORG.CY',
'PRESS.CY',
'PRO.CY',
'TM.CY',
];
@@ -0,0 +1,6 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'GOV.CZ',
];
@@ -0,0 +1,11 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'CO.DM',
'COM.DM',
'EDU.DM',
'GOV.DM',
'NET.DM',
'ORG.DM',
];
@@ -0,0 +1,15 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'ART.DO',
'COM.DO',
'EDU.DO',
'GOB.DO',
'GOV.DO',
'MIL.DO',
'NET.DO',
'ORG.DO',
'SLD.DO',
'WEB.DO',
];
@@ -0,0 +1,15 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'ART.DZ',
'ASSO.DZ',
'COM.DZ',
'EDU.DZ',
'GOV.DZ',
'NET.DZ',
'ORG.DZ',
'POL.DZ',
'SOC.DZ',
'TM.DZ',
];
@@ -0,0 +1,56 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'ABG.EC',
'ADM.EC',
'AGRON.EC',
'ARQT.EC',
'ART.EC',
'BAR.EC',
'CHEF.EC',
'COM.EC',
'CONT.EC',
'CPA.EC',
'CUE.EC',
'DENT.EC',
'DGN.EC',
'DISCO.EC',
'DOC.EC',
'EDU.EC',
'ENG.EC',
'ESM.EC',
'FIN.EC',
'FOT.EC',
'GAL.EC',
'GOB.EC',
'GOV.EC',
'GYE.EC',
'IBR.EC',
'INFO.EC',
'K12.EC',
'LAT.EC',
'LOJ.EC',
'MED.EC',
'MIL.EC',
'MKTG.EC',
'MON.EC',
'NET.EC',
'NTR.EC',
'ODONT.EC',
'ORG.EC',
'PRO.EC',
'PROF.EC',
'PSIC.EC',
'PSIQ.EC',
'PUB.EC',
'RIO.EC',
'RRPP.EC',
'SAL.EC',
'TECH.EC',
'TUL.EC',
'TUR.EC',
'UIO.EC',
'VET.EC',
'XXX.EC',
];
@@ -0,0 +1,15 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'AIP.EE',
'COM.EE',
'EDU.EE',
'FIE.EE',
'GOV.EE',
'LIB.EE',
'MED.EE',
'ORG.EE',
'PRI.EE',
'RIIK.EE',
];
@@ -0,0 +1,19 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'AC.EG',
'COM.EG',
'EDU.EG',
'EUN.EG',
'GOV.EG',
'INFO.EG',
'ME.EG',
'MIL.EG',
'NAME.EG',
'NET.EG',
'ORG.EG',
'SCI.EG',
'SPORT.EG',
'TV.EG',
];
@@ -0,0 +1,10 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'COM.ES',
'EDU.ES',
'GOB.ES',
'NOM.ES',
'ORG.ES',
];
@@ -0,0 +1,13 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'BIZ.ET',
'COM.ET',
'EDU.ET',
'GOV.ET',
'INFO.ET',
'NAME.ET',
'NET.ET',
'ORG.ET',
];
@@ -0,0 +1,6 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'ALAND.FI',
];
@@ -0,0 +1,17 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'AC.FJ',
'BIZ.FJ',
'COM.FJ',
'EDU.FJ',
'GOV.FJ',
'ID.FJ',
'INFO.FJ',
'MIL.FJ',
'NAME.FJ',
'NET.FJ',
'ORG.FJ',
'PRO.FJ',
];
@@ -0,0 +1,9 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'COM.FM',
'EDU.FM',
'NET.FM',
'ORG.FM',
];
@@ -0,0 +1,15 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'ASSO.FR',
'AVOUES.FR',
'CCI.FR',
'COM.FR',
'GOUV.FR',
'GRETA.FR',
'HUISSIER-JUSTICE.FR',
'NOM.FR',
'PRD.FR',
'TM.FR',
];
@@ -0,0 +1,7 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'EDU.GD',
'GOV.GD',
];
@@ -0,0 +1,12 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'COM.GE',
'EDU.GE',
'GOV.GE',
'NET.GE',
'ORG.GE',
'PVT.GE',
'SCHOOL.GE',
];
@@ -0,0 +1,8 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'CO.GG',
'NET.GG',
'ORG.GG',
];
@@ -0,0 +1,12 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'BIZ.GH',
'COM.GH',
'EDU.GH',
'GOV.GH',
'MIL.GH',
'NET.GH',
'ORG.GH',
];
@@ -0,0 +1,11 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'COM.GI',
'EDU.GI',
'GOV.GI',
'LTD.GI',
'MOD.GI',
'ORG.GI',
];
@@ -0,0 +1,10 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'CO.GL',
'COM.GL',
'EDU.GL',
'NET.GL',
'ORG.GL',
];
@@ -0,0 +1,11 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'AC.GN',
'COM.GN',
'EDU.GN',
'GOV.GN',
'NET.GN',
'ORG.GN',
];
@@ -0,0 +1,11 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'ASSO.GP',
'COM.GP',
'EDU.GP',
'MOBI.GP',
'NET.GP',
'ORG.GP',
];
@@ -0,0 +1,10 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'COM.GR',
'EDU.GR',
'GOV.GR',
'NET.GR',
'ORG.GR',
];
@@ -0,0 +1,12 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'COM.GT',
'EDU.GT',
'GOB.GT',
'IND.GT',
'MIL.GT',
'NET.GT',
'ORG.GT',
];
@@ -0,0 +1,13 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'COM.GU',
'EDU.GU',
'GOV.GU',
'GUAM.GU',
'INFO.GU',
'NET.GU',
'ORG.GU',
'WEB.GU',
];
@@ -0,0 +1,11 @@
<?php declare(strict_types=1);
// Copyright (c) https://publicsuffix.org
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
return [
'CO.GY',
'COM.GY',
'EDU.GY',
'GOV.GY',
'NET.GY',
'ORG.GY',
];

Some files were not shown because too many files have changed in this diff Show More