Skip to content
Merged
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
12 changes: 6 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

strategy:
matrix:
php: ['7.3', '7.4', '8.0']
php: ['8.1','8.2','8.3','8.4']

steps:
- name: "Checkout"
Expand All @@ -26,7 +26,7 @@ jobs:
extensions: "json, dom, mbstring"

- name: "Cache dependencies"
uses: "actions/cache@v1.1.2"
uses: "actions/cache@v4"
with:
path: "~/.composer/cache"
key: "php-${{ matrix.php }}-composer-cache-${{ hashFiles('**/composer.json') }}"
Expand All @@ -44,7 +44,7 @@ jobs:

strategy:
matrix:
php: ['7.3', '7.4', '8.0']
php: ['8.1','8.2','8.3','8.4']

steps:
- name: "Checkout"
Expand All @@ -57,7 +57,7 @@ jobs:
extensions: "json, dom, mbstring"

- name: "Cache dependencies"
uses: "actions/cache@v1.1.2"
uses: "actions/cache@v4"
with:
path: "~/.composer/cache"
key: "php-${{ matrix.php }}-composer-cache-${{ hashFiles('**/composer.json') }}"
Expand All @@ -75,7 +75,7 @@ jobs:

strategy:
matrix:
php: ['8.0']
php: ['8.1']

steps:
- name: "Checkout"
Expand All @@ -91,7 +91,7 @@ jobs:
run: "composer validate"

- name: "Cache dependencies"
uses: "actions/cache@v1.1.2"
uses: "actions/cache@v4"
with:
path: "~/.composer/cache"
key: "php-${{ matrix.php }}-composer-cache-${{ hashFiles('**/composer.json') }}"
Expand Down
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ test:
$(MAKE) fmt-check

phpstan:
docker run -it --rm -v ${PWD}:/app -w /app php:7.3-cli-alpine php -d error_reporting=-1 -d memory_limit=-1 bin/phpstan --ansi analyse
docker run -it --rm -v ${PWD}:/app -w /app php:8.3-cli-alpine php -d error_reporting=-1 -d memory_limit=-1 bin/phpstan --ansi analyse

phpstan-clear-cache:
docker run -it --rm -v ${PWD}:/app -w /app php:7.3-cli-alpine php -d error_reporting=-1 -d memory_limit=-1 bin/phpstan --ansi clear-result-cache
docker run -it --rm -v ${PWD}:/app -w /app php:8.3-cli-alpine php -d error_reporting=-1 -d memory_limit=-1 bin/phpstan --ansi clear-result-cache

phpunit:
docker run -it --rm -v ${PWD}:/app -w /app php:7.3-cli-alpine php -d error_reporting=-1 bin/phpunit --colors=always -c phpunit.xml
docker run -it --rm -v ${PWD}:/app -w /app php:8.3-cli-alpine php -d error_reporting=-1 bin/phpunit --colors=always -c phpunit.xml

fmt-check:
docker run -it --rm -v ${PWD}:/app -w /app php:7.3-cli-alpine php bin/phpcs --standard=./ruleset.xml --extensions=php --tab-width=4 -sp ./src ./tests
docker run -it --rm -v ${PWD}:/app -w /app php:8.3-cli-alpine php bin/phpcs --standard=./ruleset.xml --extensions=php --tab-width=4 -sp ./src ./tests

fmt:
docker run -it --rm -v ${PWD}:/app -w /app php:7.3-cli-alpine php bin/phpcbf --standard=./ruleset.xml --extensions=php --tab-width=4 -sp ./src ./tests
docker run -it --rm -v ${PWD}:/app -w /app php:8.3-cli-alpine php bin/phpcbf --standard=./ruleset.xml --extensions=php --tab-width=4 -sp ./src ./tests
9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"version": "0.5.0",
"name": "bonami/phpstan-collections",
"type": "phpstan-extension",
"description": "Phpstan extension for bonami/collections library",
Expand All @@ -10,16 +11,16 @@
}
],
"require": {
"php": ">=7.3|^8.0",
"phpstan/phpstan": "^1.0"
"php": "^8.1",
"phpstan/phpstan": "^2.0"
},
"require-dev": {
"roave/security-advisories": "dev-latest",
"ergebnis/composer-normalize": "^2.0.2",
"phpunit/phpunit": "^9.4.2",
"slevomat/coding-standard": "^6.4.1",
"squizlabs/php_codesniffer": "^3.5.0",
"bonami/collections": "^0.4.5"
"bonami/collections": "0.6.0"
},
"config": {
"bin-dir": "bin",
Expand All @@ -30,7 +31,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "0.4.x-dev"
"dev-master": "0.5.x-dev"
},
"phpstan": {
"includes": [
Expand Down
2 changes: 2 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ includes:
- extension.neon
- vendor/phpstan/phpstan/conf/bleedingEdge.neon
parameters:
ignoreErrors:
- '~Doing instanceof PHPStan\\Type\\Generic\\GenericObjectType is error-prone and deprecated~'
reportUnmatchedIgnoredErrors: true
level: 9
paths:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use PhpParser\Node\Expr\MethodCall;
use PHPStan\Analyser\Scope;
use PHPStan\Reflection\MethodReflection;
use PHPStan\Type\CallableType;
use PHPStan\Type\ClosureType;
use PHPStan\Type\DynamicMethodReturnTypeExtension;
use PHPStan\Type\Generic\GenericObjectType;
Expand All @@ -18,9 +17,10 @@

class GroupByMethodReturnTypeExtension implements DynamicMethodReturnTypeExtension
{
/** @var string */
private $class;
/** @var class-string */
private string $class;

/** @param class-string $class */
public function __construct(string $class)
{
$this->class = $class;
Expand All @@ -43,8 +43,9 @@ public function getTypeFromMethodCall(
): Type {
$arg = $methodCall->args[0];
assert($arg instanceof Arg);

$closure = $scope->getType($arg->value);
assert($closure instanceof ClosureType || $closure instanceof CallableType);
assert($closure instanceof ClosureType);

$listType = $scope->getType($methodCall->var);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@

class LateStaticBindingMethodReturnTypeExtension implements DynamicMethodReturnTypeExtension
{
/** @var string */
private $class;
/** @var class-string */
private string $class;

/** @var array<string, int> */
private $methods;
private array $methods;

/**
* @param string $class
* @param class-string $class
* @param array<string> $methods
*/
private function __construct(string $class, array $methods)
Expand All @@ -29,7 +29,7 @@ private function __construct(string $class, array $methods)
}

/**
* @param string $class
* @param class-string $class
* @param array<string> $methods
*/
public static function forMethods(string $class, array $methods): self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@

class LateStaticBindingStaticMethodReturnTypeExtension implements DynamicStaticMethodReturnTypeExtension
{
/** @var string */
private $class;
/** @var class-string */
private string $class;

/** @var array<string, int> */
private $methods;
private array $methods;

/**
* @param string $class
* @param class-string $class
* @param array<string> $methods
*/
private function __construct(string $class, array $methods)
Expand All @@ -34,7 +34,7 @@ private function __construct(string $class, array $methods)
}

/**
* @param string $class
* @param class-string $class
* @param array<string> $methods
*/
public static function forMethods(string $class, array $methods): self
Expand All @@ -60,8 +60,8 @@ public function getTypeFromStaticMethodCall(
$calledClassExpr = $methodCall->class;
if ($calledClassExpr instanceof PropertyFetch) {
$type = $scope->getType($calledClassExpr);
if ($type instanceof GenericClassStringType) {
return $type->getGenericType();
if ($type->isClassString()->yes()) {
return $type->getClassStringObjectType();
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Bonami/Collection/Phpstan/MapTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public function testSortValuesReturnType(): void
self::assertInstanceOf(FooMap::class, $concreteList);
}

/** @phpstan-param Map<int, Foo> $list */
/** @phpstan-param Map<covariant int, Foo> $list */
public function requireMapOfFoo(Map $list): void
{
}
Expand Down
Loading