Compare commits

...

2 Commits

Author SHA1 Message Date
Dries Vints b531a23117 GitHub Actions (#348)
* Add GitHub Actions workflow

* Ignore composer.lock

* Separate static analysis build

* Use ramsey/composer-install

* Add 7.2 and 7.3

* Remove coveralls
2023-01-02 18:26:14 +01:00
Alexander M. Turek 5f35e41eba Allow doctrine/lexer 2 (#345) 2022-12-30 15:09:25 +01:00
13 changed files with 120 additions and 5092 deletions
-3
View File
@@ -1,3 +0,0 @@
service_name: travis-ci
src_dir: .
coverage_clover: build/logs/clover*.xml
+35
View File
@@ -0,0 +1,35 @@
name: static analysis
on:
push:
branches:
- master
- '*.x'
pull_request:
jobs:
psalm:
runs-on: ubuntu-22.04
strategy:
fail-fast: true
name: Psalm
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
ini-values: error_reporting=E_ALL
tools: composer:v2
coverage: none
- name: Install dependencies
uses: ramsey/composer-install@v2
- name: Execute Psalm
run: vendor/bin/psalm
+48
View File
@@ -0,0 +1,48 @@
name: tests
on:
push:
branches:
- master
- '*.x'
pull_request:
schedule:
- cron: '0 0 * * *'
jobs:
tests:
runs-on: ubuntu-22.04
strategy:
fail-fast: true
matrix:
php: [7.2, 7.3, 7.4, '8.0', 8.1, 8.2]
name: PHP ${{ matrix.php }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
ini-values: error_reporting=E_ALL
tools: composer:v2
coverage: xdebug
- name: Install dependencies
uses: ramsey/composer-install@v2
- name: Setup logs directory
run: mkdir -p build/logs
- name: Execute tests
run: vendor/bin/phpunit --coverage-clover build/logs/clover.xml --exclude-group flaky
- name: Store artifacts
uses: actions/upload-artifact@v3
with:
name: logs
path: build/logs
+4 -2
View File
@@ -1,6 +1,8 @@
phpunit.result.cache
.idea
build/
report/
vendor/
composer.lock
phpunit.result.cache
.phpunit*
.idea
.vscode
-32
View File
@@ -1,32 +0,0 @@
language: php
matrix:
include:
- php: 7.4
dist: bionic
env:
- psalm=yes
- php: 8.0
env:
- psalm=yes
dist: bionic
#ppc64le support code
- php: 7.4
arch: ppc64le
env:
- psalm=yes
dist: bionic
install:
- if [ "$deps" = "low" ]; then composer update --prefer-lowest; else composer install; fi
- if [ "$psalm" = "yes" ]; then composer require --dev vimeo/psalm; fi
before_script:
- mkdir -p build/logs
script:
- vendor/bin/phpunit --coverage-clover build/logs/clover.xml --exclude-group flaky
- if [ "$psalm" = "yes" ]; then vendor/bin/psalm; fi
after_script:
- php vendor/bin/coveralls
+1 -1
View File
@@ -1,6 +1,6 @@
# EmailValidator
[![Build Status](https://app.travis-ci.com/egulias/EmailValidator.svg?branch=3.x)](https://app.travis-ci.com/github/egulias/EmailValidator)
[![Build Status](https://github.com/egulias/EmailValidator/workflows/tests/badge.svg)](https://github.com/egulias/EmailValidator/actions)
[![Code Quality](https://scrutinizer-ci.com/g/egulias/EmailValidator/badges/quality-score.png?b=3.x)](https://scrutinizer-ci.com/g/egulias/EmailValidator/?branch=3.x)
[![Test Coverage](https://scrutinizer-ci.com/g/egulias/EmailValidator/badges/coverage.png?b=3.x)](https://scrutinizer-ci.com/g/egulias/EmailValidator/?branch=3.x)
+1 -2
View File
@@ -14,11 +14,10 @@
},
"require": {
"php": ">=7.2",
"doctrine/lexer": "^1.2",
"doctrine/lexer": "^1.2|^2",
"symfony/polyfill-intl-idn": "^1.15"
},
"require-dev": {
"php-coveralls/php-coveralls": "^2.2",
"phpunit/phpunit": "^8.5.8|^9.3.3",
"vimeo/psalm": "^4"
},
Generated
-5028
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" backupGlobals="false" backupStaticAttributes="false" bootstrap="vendor/autoload.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" executionOrder="defects" processIsolation="false" stopOnFailure="false">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" backupGlobals="false" backupStaticAttributes="false" bootstrap="vendor/autoload.php" colors="true" convertDeprecationsToExceptions="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" executionOrder="defects" processIsolation="false" stopOnFailure="false">
<coverage>
<include>
<directory>./src/</directory>
+5 -16
View File
@@ -1,19 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="3.8.3@389af1bfc739bfdff3f9e3dc7bd6499aee51a831">
<file src="src/EmailLexer.php">
<DocblockTypeContradiction occurrences="1">
<code>self::$nullToken</code>
</DocblockTypeContradiction>
</file>
<file src="src/Parser/Parser.php">
<MissingReturnType occurrences="1">
<code>parse</code>
</MissingReturnType>
</file>
<file src="src/Validation/SpoofCheckValidation.php">
<UndefinedClass occurrences="2">
<code>Spoofchecker</code>
<code>Spoofchecker</code>
</UndefinedClass>
<files psalm-version="5.4.0@62db5d4f6a7ae0a20f7cc5a4952d730272fc0863">
<file src="src/Parser/DomainPart.php">
<RedundantConditionGivenDocblockType occurrences="1">
<code>null !== $this-&gt;lexer-&gt;token['type']</code>
</RedundantConditionGivenDocblockType>
</file>
</files>
+7 -1
View File
@@ -3,7 +3,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config ./vendor/vimeo/psalm/config.xsd"
errorBaseline="./psalm.baseline.xml"
errorBaseline="psalm.baseline.xml"
>
<projectFiles>
<directory name="src" />
@@ -13,5 +13,11 @@
</projectFiles>
<issueHandlers>
<DeprecatedMethod>
<errorLevel type="suppress">
<!-- This issue needs to be resolved before upgrading to Lexer 3 -->
<referencedMethod name="Doctrine\Common\Lexer\Token::offsetGet"/>
</errorLevel>
</DeprecatedMethod>
</issueHandlers>
</psalm>
+13 -5
View File
@@ -3,7 +3,11 @@
namespace Egulias\EmailValidator;
use Doctrine\Common\Lexer\AbstractLexer;
use Doctrine\Common\Lexer\Token;
/**
* @extends AbstractLexer<int, string>
*/
class EmailLexer extends AbstractLexer
{
//ASCII values
@@ -140,18 +144,20 @@ class EmailLexer extends AbstractLexer
/**
* The last matched/seen token.
*
* @var array
* @var array|Token
*
* @psalm-suppress NonInvariantDocblockPropertyType
* @psalm-var array{value:string, type:null|int, position:int}
* @psalm-suppress NonInvariantDocblockPropertyType
* @psalm-var array{value:string, type:null|int, position:int}|Token<int, string>
*/
public $token;
/**
* The next token in the input.
*
* @var array{position: int, type: int|null|string, value: int|string}|null
* @var array|Token|null
*
* @psalm-suppress NonInvariantDocblockPropertyType
* @psalm-var array{position: int, type: int|null|string, value: int|string}|Token<int, string>|null
*/
public $lookahead;
@@ -210,7 +216,9 @@ class EmailLexer extends AbstractLexer
$this->accumulator .= $this->token['value'];
}
$this->previous = $this->token;
$this->previous = $this->token instanceof Token
? ['value' => $this->token->value, 'type' => $this->token->type, 'position' => $this->token->position]
: $this->token;
if($this->lookahead === null) {
$this->lookahead = self::$nullToken;
+5 -1
View File
@@ -2,6 +2,7 @@
namespace Egulias\EmailValidator\Parser;
use Doctrine\Common\Lexer\Token;
use Egulias\EmailValidator\EmailLexer;
use Egulias\EmailValidator\Warning\TLD;
use Egulias\EmailValidator\Result\Result;
@@ -212,7 +213,10 @@ class DomainPart extends PartParser
return new ValidEmail();
}
private function checkNotAllowedChars(array $token) : Result
/**
* @psalm-param array|Token<int, string> $token
*/
private function checkNotAllowedChars($token) : Result
{
$notAllowed = [EmailLexer::S_BACKSLASH => true, EmailLexer::S_SLASH=> true];
if (isset($notAllowed[$token['type']])) {