Skip to content

Commit dd00bd5

Browse files
committed
Initial commit
0 parents  commit dd00bd5

15 files changed

+501
-0
lines changed

.github/ISSUE_TEMPLATE.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
| Q | A
2+
| ---------------- | -----
3+
| Bug report? | yes/no
4+
| Feature request? | yes/no
5+
| BC break report? | yes/no
6+
7+
<!--
8+
- Replace this comment by the description of your issue.
9+
-->

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
| Q | A
2+
| ------------- | ---
3+
| Bug fix? | yes/no
4+
| New feature? | yes/no
5+
| BC break | yes/no
6+
| Tests passed? | yes/no
7+
| Fixed tickets | #... <!-- #-prefixed issue number(s), if any -->
8+
| License | MIT
9+
10+
<!--
11+
Add description of what your PR is solving.
12+
-->

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
vendor/
2+
composer.lock
3+
.php_cs.cache
4+
.php_cs

.php_cs.dist

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
$header = <<<EOF
4+
(c) Antal Áron <antalaron@antalaron.hu>
5+
6+
For the full copyright and license information, please view the LICENSE
7+
file that was distributed with this source code.
8+
EOF;
9+
10+
return PhpCsFixer\Config::create()
11+
->setRiskyAllowed(true)
12+
->setUsingCache(false)
13+
->setRules([
14+
'@Symfony' => true,
15+
'@Symfony:risky' => true,
16+
'array_syntax' => ['syntax' => 'short'],
17+
'header_comment' => ['header' => $header],
18+
'heredoc_to_nowdoc' => true,
19+
'linebreak_after_opening_tag' => true,
20+
'no_extra_consecutive_blank_lines' => ['break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block'],
21+
'no_multiline_whitespace_before_semicolons' => false,
22+
'no_unreachable_default_argument_value' => true,
23+
'no_useless_else' => true,
24+
'no_useless_return' => true,
25+
'ordered_imports' => true,
26+
'phpdoc_order' => true,
27+
'psr4' => true,
28+
'simplified_null_return' => true,
29+
'strict_comparison' => true,
30+
'strict_param' => true,
31+
])
32+
->setFinder(
33+
PhpCsFixer\Finder::create()
34+
->in(__DIR__)
35+
->exclude([
36+
'vendor',
37+
'bin/.ci',
38+
'bin/.travis',
39+
'doc',
40+
'var',
41+
])
42+
);

.travis.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
language: php
2+
3+
sudo: false
4+
5+
dist: trusty
6+
7+
php:
8+
- 5.6
9+
- 7.0
10+
- 7.1
11+
- 7.2
12+
13+
env:
14+
- VALIDATOR_VERSION="2.7.*"
15+
- VALIDATOR_VERSION="2.8.*"
16+
- VALIDATOR_VERSION="3.3.*"
17+
- VALIDATOR_VERSION="3.4.*"
18+
- VALIDATOR_VERSION="4.0.*"
19+
20+
matrix:
21+
exclude:
22+
- php: 5.6
23+
env: VALIDATOR_VERSION="4.0.*"
24+
- php: 7.0
25+
env: VALIDATOR_VERSION="4.0.*"
26+
27+
before_script:
28+
- mkdir -p build/logs
29+
- composer require symfony/validator:${VALIDATOR_VERSION} --prefer-dist --no-interaction --no-progress
30+
31+
script:
32+
- vendor/bin/phpunit -v --coverage-clover build/logs/clover.xml
33+
- travis_retry wget -q https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar && travis_retry php coveralls.phar -v
34+
35+
notifications:
36+
email:
37+
- antalaron@antalaron.hu
38+
39+
cache:
40+
directories:
41+
- $HOME/.composer/cache

LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2017 Antal Áron
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is furnished
8+
to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
Regular expression validator
2+
============================
3+
4+
PHP library to validate regular expressions.
5+
6+
Installation
7+
------------
8+
9+
Open a command console, enter your project directory and execute the
10+
following command to download the latest stable version of this library:
11+
12+
```bash
13+
$ composer require antalaron/regex-validator
14+
```
15+
16+
This command requires you to have Composer installed globally, as explained
17+
in the [installation chapter](https://getcomposer.org/doc/00-intro.md)
18+
of the Composer documentation.
19+
20+
Basic usage
21+
-----------
22+
23+
To validate a regular expression:
24+
25+
```php
26+
use Antalaron\RegexValidator\Regex;
27+
use Symfony\Component\Validator\Validation;
28+
29+
$validator = Validation::createValidator();
30+
$violations = $validator->validate('/foo/', new Regex());
31+
32+
if (0 !== count($violations)) {
33+
foreach ($violations as $violation) {
34+
echo $violation->getMessage().'<br>';
35+
}
36+
}
37+
```
38+
39+
License
40+
-------
41+
42+
This library is under [MIT License](http://opensource.org/licenses/mit-license.php).

appveyor.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
build: false
2+
3+
platform:
4+
- x64
5+
6+
clone_folder: c:\projects\regex-validator
7+
8+
environment:
9+
matrix:
10+
- dependencies: lowest
11+
php_ver_target: 5.6.30
12+
- dependencies: highest
13+
php_ver_target: 5.6.30
14+
- dependencies: lowest
15+
php_ver_target: 7.0.18
16+
- dependencies: highest
17+
php_ver_target: 7.0.18
18+
- dependencies: lowest
19+
php_ver_target: 7.1.4
20+
- dependencies: highest
21+
php_ver_target: 7.1.4
22+
23+
## Cache composer, chocolatey and php bits
24+
cache:
25+
- '%LOCALAPPDATA%\Composer\files -> composer.lock'
26+
- composer.phar
27+
# Cache chocolatey packages
28+
- C:\ProgramData\chocolatey\bin -> .appveyor.yml
29+
- C:\ProgramData\chocolatey\lib -> .appveyor.yml
30+
# Cache php install
31+
- c:\tools\php -> .appveyor.yml
32+
33+
init:
34+
- SET PATH=C:\Program Files\OpenSSL;c:\tools\php;%PATH%
35+
- SET COMPOSER_NO_INTERACTION=1
36+
- SET PHP=1 # This var is connected to PHP install cache
37+
38+
install:
39+
- IF EXIST c:\tools\php (SET PHP=0) # Checks for the PHP install being cached
40+
- ps: appveyor-retry cinst --params '""/InstallDir:C:\tools\php""' --ignore-checksums -y php --version ((choco search php --exact --all-versions -r | select-string -pattern $env:php_ver_target | sort { [version]($_ -split '\|' | select -last 1) } -Descending | Select-Object -first 1) -replace '[php|]','')
41+
- cd c:\tools\php
42+
- IF %PHP%==1 copy php.ini-production php.ini /Y
43+
- IF %PHP%==1 echo date.timezone="UTC" >> php.ini
44+
- IF %PHP%==1 echo extension_dir=ext >> php.ini
45+
- IF %PHP%==1 echo extension=php_openssl.dll >> php.ini
46+
- IF %PHP%==1 echo extension=php_mbstring.dll >> php.ini
47+
- IF %PHP%==1 echo extension=php_intl.dll >> php.ini
48+
- IF %PHP%==1 echo extension=php_fileinfo.dll >> php.ini
49+
- IF %PHP%==1 echo @php %%~dp0composer.phar %%* > composer.bat
50+
- appveyor-retry appveyor DownloadFile https://getcomposer.org/composer.phar
51+
- cd c:\projects\regex-validator
52+
- IF %dependencies%==lowest appveyor-retry composer update --prefer-lowest --no-progress --profile -n
53+
- IF %dependencies%==highest appveyor-retry composer update --no-progress --profile -n
54+
- composer show
55+
56+
## Run the actual test
57+
test_script:
58+
- cd c:\projects\regex-validator
59+
- vendor/bin/phpunit -c phpunit.xml.dist

composer.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"name": "antalaron/regex-validator",
3+
"description": "PHP library to validate regular expressions",
4+
"type": "library",
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "Antal Áron",
9+
"email": "antalaron@antalaron.hu"
10+
}
11+
],
12+
"require": {
13+
"php": "^5.6|^7.0",
14+
"symfony/validator": "^2.8|^3.0|^4.0"
15+
},
16+
"require-dev": {
17+
"phpunit/phpunit": "*"
18+
},
19+
"conflict": {
20+
"phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0"
21+
},
22+
"autoload": {
23+
"psr-4": {
24+
"Antalaron\\RegexValidator\\": "src/"
25+
}
26+
},
27+
"autoload-dev": {
28+
"psr-4": {
29+
"Antalaron\\RegexValidator\\Tests\\": "tests/Tests/"
30+
}
31+
},
32+
"extra": {
33+
"branch-alias": {
34+
"dev-master": "1.0.x-dev"
35+
}
36+
},
37+
"minimum-stability": "dev",
38+
"prefer-stable": true
39+
}

phpunit.xml.dist

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
5+
backupGlobals="false"
6+
colors="true"
7+
bootstrap="tests/bootstrap.php"
8+
>
9+
<php>
10+
<ini name="error_reporting" value="-1" />
11+
<ini name="intl.default_locale" value="en" />
12+
<ini name="intl.error_level" value="0" />
13+
<ini name="memory_limit" value="-1" />
14+
</php>
15+
16+
<testsuites>
17+
<testsuite name="RegexValidator Test Suite">
18+
<directory suffix="Test.php">./tests</directory>
19+
</testsuite>
20+
</testsuites>
21+
22+
<filter>
23+
<whitelist processUncoveredFilesFromWhitelist="true">
24+
<directory suffix=".php">./src</directory>
25+
</whitelist>
26+
</filter>
27+
</phpunit>

0 commit comments

Comments
 (0)