Skip to content

Commit

Permalink
Merge remote-tracking branch 'hub/5.x' into non_falsy_string_literal
Browse files Browse the repository at this point in the history
  • Loading branch information
danog committed Jul 29, 2023
2 parents a86aa9a + 73ebe22 commit 63347e7
Show file tree
Hide file tree
Showing 25 changed files with 1,399 additions and 366 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'],
],
];
25 changes: 18 additions & 7 deletions docs/running_psalm/language_server.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ It currently supports diagnostics (i.e. finding errors and warnings), go-to-defi

It works well in a variety of editors (listed alphabetically):

## Emacs
## Client configuration

### Emacs

I got it working with [eglot](https://github.com/joaotavora/eglot)

Expand All @@ -27,13 +29,13 @@ This is the config I used:
)
```

## PhpStorm
### PhpStorm

### Native Support
#### Native Support

As of PhpStorm 2020.3 support for psalm is supported and on by default, you can read more about that [here](https://www.jetbrains.com/help/phpstorm/using-psalm.html)

### With LSP
#### With LSP

Alternatively, psalm works with `gtache/intellij-lsp` plugin ([Jetbrains-approved version](https://plugins.jetbrains.com/plugin/10209-lsp-support), [latest version](https://github.com/gtache/intellij-lsp/releases/tag/v1.6.0)).

Expand All @@ -51,7 +53,7 @@ In the "Server definitions" tab you should add a definition for Psalm:

In the "Timeouts" tab you can adjust the initialization timeout. This is important if you have a large project. You should set the "Init" value to the number of milliseconds you allow Psalm to scan your entire project and your project's dependencies. For opening a couple of projects that use large PHP frameworks, on a high-end business laptop, try `240000` milliseconds for Init.

## Sublime Text
### Sublime Text

I use the excellent Sublime [LSP plugin](https://github.com/tomv564/LSP) with the following config(Package Settings > LSP > Settings):
```json
Expand All @@ -64,7 +66,7 @@ I use the excellent Sublime [LSP plugin](https://github.com/tomv564/LSP) with th
}
```

## Vim & Neovim
### Vim & Neovim

**ALE**

Expand Down Expand Up @@ -105,6 +107,15 @@ Add settings to `coc-settings.json`:
}
```

## VS Code
### VS Code

[Get the Psalm plugin here](https://marketplace.visualstudio.com/items?itemName=getpsalm.psalm-vscode-plugin) (Requires VS Code 1.26+):

## Running the server in a docker container

Make sure you use `--map-folder` option. Using it without argument will map the server's CWD to the host's project root folder. You can also specify a custom mapping. For example:
```bash
docker-compose exec php /usr/share/php/psalm/psalm-language-server \
-r=/var/www/html \
--map-folder=/var/www/html:$PWD
```
Loading

0 comments on commit 63347e7

Please sign in to comment.