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

#16 Fix deprecation warnings in PHP 8, update phpunit #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
build
composer.lock
vendor
vendor
.phpunit.result.cache
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
}
],
"require": {
"php" : ">=5.3.0"
"php" : "8.*"
},
"require-dev": {
"phpunit/phpunit" : "4.*"
"phpunit/phpunit" : "9.*"
},
"autoload": {
"psr-4": {
Expand All @@ -32,7 +32,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
"dev-master": "2.0-dev"
}
}
}
10 changes: 0 additions & 10 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,4 @@
<directory>./tests/**</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src/</directory>
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="build/coverage" charset="UTF-8" yui="true" highlight="true"/>
<log type="coverage-text" target="build/coverage.txt"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
</phpunit>
10 changes: 5 additions & 5 deletions src/RegRev/ExpressionContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function set($expression)
/**
* Rewinds the container index.
*/
public function rewind()
public function rewind(): void
{
$this->position = 0;
}
Expand All @@ -51,7 +51,7 @@ public function rewind()
*
* @return mixed
*/
public function current()
public function current(): mixed
{
return $this->expressions[$this->position];
}
Expand All @@ -61,15 +61,15 @@ public function current()
*
* @return int
*/
public function key()
public function key(): int
{
return $this->position;
}

/**
* Increases the current index.
*/
public function next()
public function next(): void
{
++$this->position;
}
Expand All @@ -79,7 +79,7 @@ public function next()
*
* @return bool
*/
public function valid()
public function valid(): bool
{
return isset($this->expressions[$this->position]);
}
Expand Down
3 changes: 2 additions & 1 deletion tests/RegRev/Test/Exception/RegExpNotValidExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@

namespace RegRev\Test\Exception;

use PHPUnit\Framework\TestCase;
use RegRev\Exception\RegExpNotValidException;

class RegExpNotValidExceptionTest extends \PHPUnit_Framework_TestCase
class RegExpNotValidExceptionTest extends TestCase
{
public function testException()
{
Expand Down
5 changes: 3 additions & 2 deletions tests/RegRev/Test/Metacharacter/CharType/CharTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,17 @@

namespace RegRev\Test\Metacharacter\CharType;

use PHPUnit\Framework\TestCase;
use RegRev\Metacharacter\CharType\CharType;

/**
* Class Number
*
* @package RevReg\Char
*/
class CharTypeTest extends \PHPUnit_Framework_TestCase
class CharTypeTest extends TestCase
{
public function setup()
protected function setUp(): void
{
$this->digit = new CharType();
$this->digit->setChars('01');
Expand Down
5 changes: 3 additions & 2 deletions tests/RegRev/Test/Metacharacter/CharType/GenericTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,17 @@

namespace RegRev\Test\Metacharacter\CharType;

use PHPUnit\Framework\TestCase;
use RegRev\Metacharacter\CharType\Generic;

/**
* Class Number
*
* @package RevReg\Char
*/
class GenericTest extends \PHPUnit_Framework_TestCase
class GenericTest extends TestCase
{
public function setup()
protected function setUp(): void
{
$this->blank = new Generic();
$this->blank->setReturnValue(' ');
Expand Down
5 changes: 3 additions & 2 deletions tests/RegRev/Test/Metacharacter/CharType/UnknownTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,17 @@

namespace RegRev\Test\Metacharacter\CharType;

use PHPUnit\Framework\TestCase;
use RegRev\Metacharacter\CharType\Unknown;

/**
* Class Number
*
* @package RevReg\Char
*/
class UnknownTest extends \PHPUnit_Framework_TestCase
class UnknownTest extends TestCase
{
public function setup()
protected function setUp(): void
{
$this->unknown = new Unknown();
}
Expand Down
13 changes: 6 additions & 7 deletions tests/RegRev/Test/Metacharacter/CharacterHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,22 @@

namespace RegRev\Test\Metacharacter;

use PHPUnit\Framework\TestCase;
use RegRev\Metacharacter\CharacterHandler;

class TestCharacterHandler extends CharacterHandler
{
public function generate(){ return;}
}

/**
* Class Number
*
* @package RevReg\Char
*/
class CharacterHandlerTest extends \PHPUnit_Framework_TestCase
class CharacterHandlerTest extends TestCase
{
public function testisValid()
{
$charTypeTest = new TestCharacterHandler();
$charTypeTest = new class extends CharacterHandler
{
public function generate(){ return;}
};
$charTypeTest->setPattern('\d');

$this->assertTrue($charTypeTest->isValid('\d'));
Expand Down
5 changes: 3 additions & 2 deletions tests/RegRev/Test/Metacharacter/GroupType/SubpatternTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,17 @@

namespace RegRev\Test\Metacharacter\GroupType;

use PHPUnit\Framework\TestCase;
use RegRev\Metacharacter\GroupType\Subpattern;

/**
* Class Number
*
* @package RevReg\Char
*/
class SubpatternTest extends \PHPUnit_Framework_TestCase
class SubpatternTest extends TestCase
{
public function setup()
protected function setUp(): void
{
$this->subpattern = new Subpattern();
$this->subpattern->setPattern('/\(.*\)/');
Expand Down
5 changes: 3 additions & 2 deletions tests/RegRev/Test/Metacharacter/Quantifier/NTimesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace RegRev\Test\Metacharacter\CharType;

use PHPUnit\Framework\TestCase;
use RegRev\Metacharacter\CharType\Generic;
use RegRev\Metacharacter\Quantifier\NTimes;

Expand All @@ -18,9 +19,9 @@
*
* @package RevReg\Char
*/
class NTimesTest extends \PHPUnit_Framework_TestCase
class NTimesTest extends TestCase
{
public function setup()
protected function setUp(): void
{
$this->regEx = new NTimes();
$this->regEx->setPattern('/\{(\d*),?(\d*)?\}/');
Expand Down
5 changes: 3 additions & 2 deletions tests/RegRev/Test/Metacharacter/Quantifier/OneOrMoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace RegRev\Test\Metacharacter\CharType;

use PHPUnit\Framework\TestCase;
use RegRev\Metacharacter\CharType\Generic;
use RegRev\Metacharacter\Quantifier\OneOrMore;

Expand All @@ -18,9 +19,9 @@
*
* @package RevReg\Char
*/
class OneOrMoreTest extends \PHPUnit_Framework_TestCase
class OneOrMoreTest extends TestCase
{
public function setup()
protected function setUp(): void
{
$this->regEx = new OneOrMore();
$this->regEx->setPattern('+');
Expand Down
5 changes: 3 additions & 2 deletions tests/RegRev/Test/Metacharacter/Quantifier/ZeroOrMoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace RegRev\Test\Metacharacter\CharType;

use PHPUnit\Framework\TestCase;
use RegRev\Metacharacter\CharType\Generic;
use RegRev\Metacharacter\Quantifier\ZeroOrMore;

Expand All @@ -18,9 +19,9 @@
*
* @package RevReg\Char
*/
class ZeroOrMoreTest extends \PHPUnit_Framework_TestCase
class ZeroOrMoreTest extends TestCase
{
public function setup()
protected function setUp(): void
{
$this->regEx = new ZeroOrMore();
$this->regEx->setPattern('*');
Expand Down
5 changes: 3 additions & 2 deletions tests/RegRev/Test/Metacharacter/Quantifier/ZeroOrOneTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace RegRev\Test\Metacharacter\CharType;

use PHPUnit\Framework\TestCase;
use RegRev\Metacharacter\CharType\Generic;
use RegRev\Metacharacter\Quantifier\ZeroOrOne;

Expand All @@ -18,9 +19,9 @@
*
* @package RevReg\Char
*/
class ZeroOrOneTest extends \PHPUnit_Framework_TestCase
class ZeroOrOneTest extends TestCase
{
public function setup()
protected function setUp(): void
{
$this->regEx = new ZeroOrOne();
$this->regEx->setPattern('?');
Expand Down
5 changes: 3 additions & 2 deletions tests/RegRev/Test/Metacharacter/Range/RangeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,17 @@

namespace RegRev\Test\Metacharacter\GroupType;

use PHPUnit\Framework\TestCase;
use RegRev\Metacharacter\Range\Range;

/**
* Class Number
*
* @package RevReg\Char
*/
class RangeTest extends \PHPUnit_Framework_TestCase
class RangeTest extends TestCase
{
public function setup()
protected function setUp(): void
{
$this->subpattern = new Range();
$this->subpattern->setPattern('/^\[[^\]]*\]/');
Expand Down
10 changes: 5 additions & 5 deletions tests/RegRev/Test/RegRevTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@

namespace RegRev\Test;

use PHPUnit\Framework\TestCase;
use RegRev\Configuration;
use RegRev\Debug;
use RegRev\Exception\RegExpNotValidException;
use RegRev\RegRev;

class RegRevTest extends \PHPUnit_Framework_TestCase
class RegRevTest extends TestCase
{
public function testCustomConfiguration()
{
Expand Down Expand Up @@ -44,11 +46,9 @@ public function testSupportedRegex()
$this->assertTrue(is_numeric($result));
}

/**
* @expectedException RegRev\Exception\RegExpNotValidException
*/
public function testNotValidRegex()
{
$this->expectException(RegExpNotValidException::class);
$string = '/\d/';
RegRev::generate($string);
}
Expand All @@ -68,7 +68,7 @@ public function testDebug()
RegRev::generate($string);
$debug = RegRev::debug();

$this->assertContains('Unknown', $debug[0]);
$this->assertStringContainsString('Unknown', $debug[0]);
}

/**
Expand Down