Skip to content

Commit

Permalink
feat: change min phpcs version to 3.10 + update dev dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
gskema committed May 23, 2024
1 parent 03033a8 commit a062ea8
Show file tree
Hide file tree
Showing 13 changed files with 56 additions and 102 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
/.vagrant/
/composer.lock
/build/
.phpunit.result.cache
/var/
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to `phpcs-type-sniff` will be documented in this file.

Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) principles.

## Unreleased
### Changed
- Min `phpcs` version to 3.10

## 81.5.2 - 2024-04-05
### Changed
- Min phpcs version to 3.9
Expand Down
12 changes: 8 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
],
"require": {
"php": ">=8.1",
"squizlabs/php_codesniffer": "^3.9"
"squizlabs/php_codesniffer": "^3.10"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"scrutinizer/ocular": "^1.8.1"
"phpunit/phpunit": "^10.5",
"scrutinizer/ocular": "^1.6"
},
"autoload": {
"psr-4": {
Expand Down Expand Up @@ -52,6 +52,10 @@
"test-coverage": "vendor/bin/phpunit --coverage-clover=clover.xml",
"test-coverage-local": "php -d xdebug.mode=coverage ./vendor/bin/phpunit --coverage-html=build/coverage",
"upload-coverage": "vendor/bin/ocular code-coverage:upload --format=php-clover coverage.xml;",
"phpcs": "vendor/bin/phpcs -p"
"phpcs": "vendor/bin/phpcs -p",
"build": [
"@test",
"@phpcs"
]
}
}
12 changes: 5 additions & 7 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,22 @@
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="tests/bootstrap.php"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
cacheDirectory="./var/.phpunit.cache"
backupStaticProperties="false"
>
<testsuites>
<testsuite name="Tests">
<directory>./tests</directory>
</testsuite>
</testsuites>
<coverage>
<source>
<include>
<directory suffix=".php">src/</directory>
</include>
</coverage>
</source>
</phpunit>
21 changes: 8 additions & 13 deletions tests/Core/CodeElement/CodeElementDetectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,15 @@
use PHP_CodeSniffer\Config;
use PHP_CodeSniffer\Files\LocalFile;
use PHP_CodeSniffer\Ruleset;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

class CodeElementDetectorTest extends TestCase
{
/**
* @return mixed[][]
*/
public function dataDetectFromTokens(): array
public static function dataDetectFromTokens(): array
{
$dataSets = [];

Expand Down Expand Up @@ -1320,21 +1321,15 @@ public function dataDetectFromTokens(): array
return $dataSets;
}

/**
* @dataProvider dataDetectFromTokens
*
* @param bool $givenUseReflection
* @param string $givenPath
* @param FileElement $expected
*/
public function testDetectFromTokens(bool $givenUseReflection, string $givenPath, FileElement $expected): void
#[DataProvider('dataDetectFromTokens')]
public function testDetectFromTokens(bool $givenUseReflection, string $givenFile, FileElement $expected): void
{
static::assertFileExists($givenPath);
static::assertFileExists($givenFile);

$givenFile = new LocalFile($givenPath, new Ruleset(new Config()), new Config());
$givenFile->parse();
$givenFileObj = new LocalFile($givenFile, new Ruleset(new Config()), new Config());
$givenFileObj->parse();

$actual = CodeElementDetector::detectFromTokens($givenFile, $givenUseReflection);
$actual = CodeElementDetector::detectFromTokens($givenFileObj, $givenUseReflection);

self::assertEquals($expected, $actual);
}
Expand Down
21 changes: 5 additions & 16 deletions tests/Core/DocBlock/DocBlockParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
use PHP_CodeSniffer\Exceptions\RuntimeException;
use PHP_CodeSniffer\Files\LocalFile;
use PHP_CodeSniffer\Ruleset;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

class DocBlockParserTest extends TestCase
{
/**
* @return mixed[][]
*/
public function dataDetectFromTokens(): array
public static function dataDetectFromTokens(): array
{
$dataSets = [];

Expand Down Expand Up @@ -113,15 +114,10 @@ public function dataDetectFromTokens(): array
}

/**
* @dataProvider dataDetectFromTokens
*
* @param string $givenPath
* @param int[] $givenPointers
* @param DocBlock|null $expectedDocBlock
* @param string|null $expectedException
*
* @throws RuntimeException
*/
#[DataProvider('dataDetectFromTokens')]
public function testDetectFromTokens(
string $givenPath,
array $givenPointers,
Expand All @@ -143,7 +139,7 @@ public function testDetectFromTokens(
/**
* @return mixed[][]
*/
public function dataFromRaw(): array
public static function dataFromRaw(): array
{
$dataSets = [];

Expand Down Expand Up @@ -249,14 +245,7 @@ public function dataFromRaw(): array
return $dataSets;
}

/**
* @dataProvider dataFromRaw
*
* @param string $givenRawDocBlock
* @param int $givenStartLine
* @param DocBlock|null $expectedDocBlock
* @param string|null $expectedException
*/
#[DataProvider('dataFromRaw')]
public function testFromRaw(
string $givenRawDocBlock,
int $givenStartLine,
Expand Down
11 changes: 3 additions & 8 deletions tests/Core/Func/FunctionSignatureParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@
use PHP_CodeSniffer\Exceptions\RuntimeException;
use PHP_CodeSniffer\Files\LocalFile;
use PHP_CodeSniffer\Ruleset;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

class FunctionSignatureParserTest extends TestCase
{
/**
* @return mixed[][]
*/
public function dataFromTokens(): array
public static function dataFromTokens(): array
{
$dataSets = [];

Expand Down Expand Up @@ -150,15 +151,9 @@ public function dataFromTokens(): array
}

/**
* @dataProvider dataFromTokens
*
* @param string $givenPath
* @param int $givenFnPtr
* @param FunctionSignature|null $expectedFun
* @param string|null $expectedException
*
* @throws RuntimeException
*/
#[DataProvider('dataFromTokens')]
public function testFromTokens(
string $givenPath,
int $givenFnPtr,
Expand Down
13 changes: 3 additions & 10 deletions tests/Core/Type/TypeComparatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

namespace Gskema\TypeSniff\Core\Type;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

class TypeComparatorTest extends TestCase
{
/**
* @return string[][]
*/
public function dataCompare(): array
public static function dataCompare(): array
{
// doc_type, fn_type, val_type, wrong_doc, missing_doc
return [
Expand Down Expand Up @@ -94,15 +95,7 @@ public function dataCompare(): array
];
}

/**
* @dataProvider dataCompare
*
* @param string $givenRawDocType
* @param string $givenRawFnType
* @param string|null $givenRawValueType
* @param string $expectedWrongRawDocTypes
* @param string $expectedMissingRawDocTypes
*/
#[DataProvider('dataCompare')]
public function testCompare(
string $givenRawDocType,
string $givenRawFnType,
Expand Down
20 changes: 5 additions & 15 deletions tests/Core/Type/TypeConverterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@
use Gskema\TypeSniff\Core\Type\DocBlock\ThisType;
use Gskema\TypeSniff\Core\Type\DocBlock\TrueType;
use Gskema\TypeSniff\Core\Type\DocBlock\TypedArrayType;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

class TypeConverterTest extends TestCase
{
/**
* @return TypeInterface[][]
*/
public function dataToExampleDocType(): array
public static function dataToExampleDocType(): array
{
return [
[new ArrayType(), new TypedArrayType(new FqcnType('SomeClass'), 1)],
Expand Down Expand Up @@ -69,12 +70,7 @@ public function dataToExampleDocType(): array
];
}

/**
* @dataProvider dataToExampleDocType
*
* @param TypeInterface $givenFnType
* @param TypeInterface|null $expectedExampleDocType
*/
#[DataProvider('dataToExampleDocType')]
public function testToExampleDocType(
TypeInterface $givenFnType,
?TypeInterface $expectedExampleDocType,
Expand All @@ -87,7 +83,7 @@ public function testToExampleDocType(
/**
* @return TypeInterface[][]
*/
public function dataToExampleFnType(): array
public static function dataToExampleFnType(): array
{
return [
0 => [
Expand Down Expand Up @@ -196,13 +192,7 @@ public function dataToExampleFnType(): array
];
}

/**
* @dataProvider dataToExampleFnType
*
* @param TypeInterface $givenDocType
* @param TypeInterface|null $expectedFnType
* @param bool $givenIsProp
*/
#[DataProvider('dataToExampleFnType')]
public function testToExampleFnType(
TypeInterface $givenDocType,
?TypeInterface $expectedFnType,
Expand Down
15 changes: 5 additions & 10 deletions tests/Core/Type/TypeFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@
use Gskema\TypeSniff\Core\Type\DocBlock\ThisType;
use Gskema\TypeSniff\Core\Type\DocBlock\TrueType;
use Gskema\TypeSniff\Core\Type\DocBlock\TypedArrayType;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

class TypeFactoryTest extends TestCase
{
/**
* @return mixed[][]
*/
public function dataSplit(): array
public static function dataSplit(): array
{
$dataSets = [
['int $param1', [['int'], '$param1']],
Expand Down Expand Up @@ -88,11 +89,9 @@ public function dataSplit(): array
}

/**
* @dataProvider dataSplit
*
* @param string $givenTagBody
* @param mixed[] $expectedSplit
*/
#[DataProvider('dataSplit')]
public function testSplit(
string $givenTagBody,
array $expectedSplit,
Expand All @@ -111,7 +110,7 @@ public static function doSplit(string $tagBody): array
/**
* @return mixed[][]
*/
public function dataFromRawType(): array
public static function dataFromRawType(): array
{
$dataSets = [
['array' , new ArrayType()],
Expand Down Expand Up @@ -284,11 +283,7 @@ public function dataFromRawType(): array
return $dataSets;
}

/**
* @dataProvider dataFromRawType
* @param string $givenRawType
* @param TypeInterface $expectedType
*/
#[DataProvider('dataFromRawType')]
public function testFromRawType(string $givenRawType, TypeInterface $expectedType): void
{
self::assertEquals($expectedType, TypeFactory::fromRawType($givenRawType));
Expand Down
10 changes: 3 additions & 7 deletions tests/Core/Type/TypeHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
use Gskema\TypeSniff\Core\Type\Common\ArrayType;
use Gskema\TypeSniff\Core\Type\Common\IntType;
use Gskema\TypeSniff\Core\Type\DocBlock\TypedArrayType;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

class TypeHelperTest extends TestCase
{
/**
* @return mixed[][]
*/
public function dataGetFakeTypedArrayType(): array
public static function dataGetFakeTypedArrayType(): array
{
return [
[null, null],
Expand All @@ -22,12 +23,7 @@ public function dataGetFakeTypedArrayType(): array
];
}

/**
* @dataProvider dataGetFakeTypedArrayType
*
* @param TypeInterface|null $givenType
* @param TypeInterface|null $expectedFakeType
*/
#[DataProvider('dataGetFakeTypedArrayType')]
public function testGetFakeTypedArrayType(?TypeInterface $givenType, ?TypeInterface $expectedFakeType): void
{
$actualFakeType = TypeHelper::getFakeTypedArrayType($givenType);
Expand Down
Loading

0 comments on commit a062ea8

Please sign in to comment.