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

added GitHub CI for unit tests with PHP 8.2 and 8.3 #10028

Merged
merged 25 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d390133
#10026 added GitHub CI for unit tests with PHP 8.2 and 8.3
thbley Jul 19, 2023
9eb3c7e
#10026 test matrix for different php versions and operating systems
thbley Jul 19, 2023
e8586a7
#10026 test matrix for different php versions and operating systems
thbley Jul 19, 2023
d0605ee
cleanup
thbley Jul 19, 2023
ba4e40a
cleanup
thbley Jul 19, 2023
1c55437
cleanup
thbley Jul 19, 2023
fffbf75
cleanup
thbley Jul 19, 2023
0f99799
#10026 fixed AnnotationTest
thbley Jul 19, 2023
804087b
#10026 added workaround for DateTimeInterface::__unserialize() signature
thbley Jul 19, 2023
cbee1e0
#10026 adapted DateTime tests for DateMalformedStringException in PHP…
thbley Jul 19, 2023
2e0f1e2
#10026 extended callmap delta for php 8.3
thbley Jul 19, 2023
f34327e
10026 extended InternalCallMapHandlerTest ignores for php 8.3
thbley Jul 19, 2023
ee185b9
#10026 cleanup method signatures
thbley Jul 19, 2023
741d196
#10026 cleanup signature for hash_pbkdf2()
thbley Jul 19, 2023
51058eb
#10026 cleanup
thbley Jul 20, 2023
5affc12
#10026 run phpcs and phar-build with php 8.0 in circle-ci (php 7.4 is…
thbley Jul 21, 2023
4307bc4
#10026 run buuld-phar with php 8.0 in github actions (php 7.4 is out …
thbley Jul 21, 2023
fc1d3e0
#10026 added code style analysis with phpcs to github actions
thbley Jul 21, 2023
9590279
#10026 added style changes to pass phpcs check
thbley Jul 21, 2023
7f39dab
#10026 moved some more signature changes to CallMap_83_delta
thbley Jul 21, 2023
fda483a
#10026 converted version_compare() to direct comparison with PHP_VERS…
thbley Jul 21, 2023
e82114c
#10026 keep running phpcs and php lint with 7.4
thbley Jul 21, 2023
1e1ffe1
#10026 keep running phpcs and php lint with 7.4
thbley Jul 21, 2023
603dfa2
#10026 cleanup phpcs
thbley Jul 21, 2023
637dcc4
#10026 fixed case mismatches in CallMap_83_delta
thbley Jul 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Use the latest 2.1 version of CircleCI pipeline processing engine, see https://circleci.com/docs/2.0/configuration-reference/
# See https://app.circleci.com/pipelines/github/vimeo/psalm
version: 2.1
executors:
php-74:
Expand Down
54 changes: 52 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,51 @@ jobs:

- run: |
git ls-files | grep \\\.php$ | grep -v ^dictionaries/scripts/* | ./vendor/bin/parallel-lint --stdin

code-style:
name: Code Style Analysis
runs-on: ubuntu-latest
steps:
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
tools: composer:v2
coverage: none
env:
fail-fast: true

- uses: actions/checkout@v3

- name: Get Composer Cache Directories
id: composer-cache
run: |
echo "files_cache=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
echo "vcs_cache=$(composer config cache-vcs-dir)" >> $GITHUB_OUTPUT

- name: Generate composer.lock
run: composer update --no-install
env:
COMPOSER_ROOT_VERSION: dev-master

- name: Cache composer cache
uses: actions/cache@v3
with:
path: |
${{ steps.composer-cache.outputs.files_cache }}
${{ steps.composer-cache.outputs.vcs_cache }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-

- name: Run composer install
run: composer install -o
env:
COMPOSER_ROOT_VERSION: dev-master

- name: Code Style Analysis with PHPCS
run: vendor/bin/phpcs -d memory_limit=512M

chunk-matrix:
permissions:
contents: none
Expand All @@ -70,7 +115,7 @@ jobs:
echo "chunks=$(php -r 'echo json_encode(range(1, ${{ env.CHUNK_COUNT }} ));')" >> $GITHUB_OUTPUT

tests:
name: "Unit Tests - ${{ matrix.chunk }}"
name: "Unit Tests - PHP ${{ matrix.php-version }} ${{ matrix.chunk }}/${{ matrix.count }}"

runs-on: ubuntu-latest
needs:
Expand All @@ -79,6 +124,11 @@ jobs:
strategy:
fail-fast: false
matrix:
php-version:
- "8.0"
- "8.1"
- "8.2"
- "8.3"
count: ${{ fromJson(needs.chunk-matrix.outputs.count) }}
chunk: ${{ fromJson(needs.chunk-matrix.outputs.chunks) }}

Expand All @@ -91,7 +141,7 @@ jobs:
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: "${{ matrix.php-version }}"
ini-values: zend.assertions=1, assert.exception=1, opcache.enable_cli=1, opcache.jit=function, opcache.jit_buffer_size=512M
tools: composer:v2
coverage: none
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
}
],
"require": {
"php": "^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0",
"php": "^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0",
"ext-SimpleXML": "*",
"ext-ctype": "*",
"ext-dom": "*",
Expand Down
70 changes: 23 additions & 47 deletions dictionaries/CallMap.php

Large diffs are not rendered by default.

116 changes: 116 additions & 0 deletions dictionaries/CallMap_83_delta.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,124 @@
'old' => ['array{runs:int,collected:int,threshold:int,roots:int}'],
'new' => ['array{runs:int,collected:int,threshold:int,roots:int,running:bool,protected:bool,full:bool,buffer_size:int}'],
],
'srand' => [
'old' => ['void', 'seed='=>'int', 'mode='=>'int'],
'new' => ['void', 'seed='=>'?int', 'mode='=>'int'],
],
'mt_srand' => [
'old' => ['void', 'seed='=>'int', 'mode='=>'int'],
'new' =>['void', 'seed='=>'?int', 'mode='=>'int'],
],
'posix_getrlimit' => [
'old' => ['array{"soft core": string, "hard core": string, "soft data": string, "hard data": string, "soft stack": integer, "hard stack": string, "soft totalmem": string, "hard totalmem": string, "soft rss": string, "hard rss": string, "soft maxproc": integer, "hard maxproc": integer, "soft memlock": integer, "hard memlock": integer, "soft cpu": string, "hard cpu": string, "soft filesize": string, "hard filesize": string, "soft openfiles": integer, "hard openfiles": integer}|false'],
'new' => ['array{"soft core": string, "hard core": string, "soft data": string, "hard data": string, "soft stack": integer, "hard stack": string, "soft totalmem": string, "hard totalmem": string, "soft rss": string, "hard rss": string, "soft maxproc": integer, "hard maxproc": integer, "soft memlock": integer, "hard memlock": integer, "soft cpu": string, "hard cpu": string, "soft filesize": string, "hard filesize": string, "soft openfiles": integer, "hard openfiles": integer}|false', 'resource=' => '?int'],
],
'natcasesort' => [
'old' => ['bool', '&rw_array'=>'array'],
'new' => ['true', '&rw_array'=>'array'],
],
'natsort' => [
'old' => ['bool', '&rw_array'=>'array'],
'new' => ['true', '&rw_array'=>'array'],
],
'rsort' => [
'old' => ['bool', '&rw_array'=>'array', 'flags='=>'int'],
'new' => ['true', '&rw_array'=>'array', 'flags='=>'int'],
],
'hash_pbkdf2' => [
'old' => ['non-empty-string', 'algo'=>'string', 'password'=>'string', 'salt'=>'string', 'iterations'=>'int', 'length='=>'int', 'binary='=>'bool'],
'new' => ['non-empty-string', 'algo'=>'string', 'password'=>'string', 'salt'=>'string', 'iterations'=>'int', 'length='=>'int', 'binary='=>'bool', 'options=' => 'array'],
],
'imap_setflag_full' => [
'old' => ['bool', 'imap'=>'IMAP\Connection', 'sequence'=>'string', 'flag'=>'string', 'options='=>'int'],
'new' => ['true', 'imap'=>'IMAP\Connection', 'sequence'=>'string', 'flag'=>'string', 'options='=>'int'],
],
'imap_expunge' => [
'old' => ['bool', 'imap'=>'IMAP\Connection'],
'new' => ['true', 'imap'=>'IMAP\Connection'],
],
'imap_gc' => [
'old' => ['bool', 'imap'=>'IMAP\Connection', 'flags'=>'int'],
'new' => ['true', 'imap'=>'IMAP\Connection', 'flags'=>'int'],
],
'imap_undelete' => [
'old' => ['bool', 'imap'=>'IMAP\Connection', 'message_nums'=>'string', 'flags='=>'int'],
'new' => ['true', 'imap'=>'IMAP\Connection', 'message_nums'=>'string', 'flags='=>'int'],
],
'imap_delete' => [
'old' => ['bool', 'imap'=>'IMAP\Connection', 'message_nums'=>'string', 'flags='=>'int'],
'new' => ['true', 'imap'=>'IMAP\Connection', 'message_nums'=>'string', 'flags='=>'int'],
],
'imap_clearflag_full' => [
'old' => ['bool', 'imap'=>'IMAP\Connection', 'sequence'=>'string', 'flag'=>'string', 'options='=>'int'],
'new' => ['true', 'imap'=>'IMAP\Connection', 'sequence'=>'string', 'flag'=>'string', 'options='=>'int'],
],
'imap_close' => [
'old' => ['bool', 'imap'=>'IMAP\Connection', 'flags='=>'int'],
'new' => ['true', 'imap'=>'IMAP\Connection', 'flags='=>'int'],
],
'intlcal_clear' => [
'old' => ['bool', 'calendar'=>'IntlCalendar', 'field='=>'?int'],
'new' => ['true', 'calendar'=>'IntlCalendar', 'field='=>'?int'],
],
'intlcal_set_lenient' => [
'old' => ['bool', 'calendar'=>'IntlCalendar', 'lenient'=>'bool'],
'new' => ['true', 'calendar'=>'IntlCalendar', 'lenient'=>'bool'],
],
'intlcal_set_first_day_of_week' => [
'old' => ['bool', 'calendar'=>'IntlCalendar', 'dayOfWeek'=>'int'],
'new' => ['true', 'calendar'=>'IntlCalendar', 'dayOfWeek'=>'int'],
],
'datefmt_set_timezone' => [
'old' => ['false|null', 'formatter'=>'IntlDateFormatter', 'timezone'=>'IntlTimeZone|DateTimeZone|string|null'],
'new' => ['bool', 'formatter'=>'IntlDateFormatter', 'timezone'=>'IntlTimeZone|DateTimeZone|string|null'],
],
'IntlRuleBasedBreakIterator::setText' => [
'old' => ['?bool', 'text'=>'string'],
'new' => ['bool', 'text'=>'string'],
],
'IntlCodePointBreakIterator::setText' => [
'old' => ['?bool', 'text'=>'string'],
'new' => ['bool', 'text'=>'string'],
],
'IntlDateFormatter::setTimeZone' => [
'old' => ['null|false', 'timezone'=>'IntlTimeZone|DateTimeZone|string|null'],
'new' => ['bool', 'timezone'=>'IntlTimeZone|DateTimeZone|string|null'],
],
'IntlChar::enumCharNames' => [
'old' => ['?bool', 'start'=>'string|int', 'end'=>'string|int', 'callback'=>'callable(int,int,int):void', 'type='=>'int'],
'new' => ['bool', 'start'=>'string|int', 'end'=>'string|int', 'callback'=>'callable(int,int,int):void', 'type='=>'int'],
],
'IntlBreakIterator::setText' => [
'old' => ['?bool', 'text'=>'string'],
'new' => ['bool', 'text'=>'string'],
],
],

'removed' => [
'OutOfBoundsException::__clone' => ['void'],
'ArgumentCountError::__clone' => ['void'],
'ArithmeticError::__clone' => ['void'],
'BadFunctionCallException::__clone' => ['void'],
'BadMethodCallException::__clone' => ['void'],
'ClosedGeneratorException::__clone' => ['void'],
'DomainException::__clone' => ['void'],
'ErrorException::__clone' => ['void'],
'IntlException::__clone' => ['void'],
'InvalidArgumentException::__clone' => ['void'],
'JsonException::__clone' => ['void'],
'LengthException::__clone' => ['void'],
'LogicException::__clone' => ['void'],
'OutOfRangeException::__clone' => ['void'],
'OverflowException::__clone' => ['void'],
'ParseError::__clone' => ['void'],
'RangeException::__clone' => ['void'],
'ReflectionNamedType::__clone' => ['void'],
'ReflectionObject::__clone' => ['void'],
'RuntimeException::__clone' => ['void'],
'TypeError::__clone' => ['void'],
'UnderflowException::__clone' => ['void'],
'UnexpectedValueException::__clone' => ['void'],
'IntlCodePointBreakIterator::__construct' => ['void'],
],
];
63 changes: 43 additions & 20 deletions tests/AnnotationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,28 @@ public function setUp(): void
public function testLessSpecificImplementedReturnTypeWithDocblockOnMultipleLines(): void
{
$this->expectException(CodeException::class);
$this->expectExceptionMessage('LessSpecificImplementedReturnType - somefile.php:5:');
$this->expectExceptionMessage('LessSpecificImplementedReturnType - somefile.php:16:');

$this->addFile(
'somefile.php',
'<?php

class ParentClass
{
/**
* @return $this
*/
public function execute()
{
return $this;
}
}

/**
* @method int test()
* @method \DateTime modify($modify)
* @method self execute()
*/
class WTF extends \DateTime { }',
class BreakingThings extends ParentClass { }',
);

$this->analyzeFile('somefile.php', new Context());
Expand All @@ -50,23 +61,23 @@ public function testLessSpecificImplementedReturnTypeWithDocblockOnMultipleLines
'somefile.php',
'<?php

class ParentClass
{
class ParentClass
{
/**
* @return $this
*/
public function execute()
{
return $this;
}
}

/**
* @return $this
* @method self execute()
*/
public function execute()
class BreakingThings extends ParentClass
{
return $this;
}
}

/**
* @method self execute()
*/
class BreakingThings extends ParentClass
{
}',
}',
);

$this->analyzeFile('somefile.php', new Context());
Expand All @@ -75,19 +86,31 @@ class BreakingThings extends ParentClass
public function testLessSpecificImplementedReturnTypeWithDescription(): void
{
$this->expectException(CodeException::class);
$this->expectExceptionMessage('LessSpecificImplementedReturnType - somefile.php:7:');
$this->expectExceptionMessage('LessSpecificImplementedReturnType - somefile.php:19:');

$this->addFile(
'somefile.php',
'<?php

class ParentClass
{
/**
* @return $this
*/
public function execute()
{
return $this;
}
}

/**
* test test test
* test rambling text
* test test text
*
* @method \DateTime modify($modify)
* @method self execute()
*/
class WTF extends \DateTime { }',
class BreakingThings extends ParentClass { }',
);

$this->analyzeFile('somefile.php', new Context());
Expand Down