Skip to content

Commit

Permalink
Merge pull request #10028 from thbley/master
Browse files Browse the repository at this point in the history
added GitHub CI for unit tests with PHP 8.2 and 8.3
  • Loading branch information
orklah authored Jul 26, 2023
2 parents be82c3a + 637dcc4 commit be875f5
Show file tree
Hide file tree
Showing 9 changed files with 365 additions and 154 deletions.
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
Loading

0 comments on commit be875f5

Please sign in to comment.