Skip to content

Commit

Permalink
Merge remote-tracking branch 'vimeo/master' into disjoint_keyed_array
Browse files Browse the repository at this point in the history
  • Loading branch information
danog committed Feb 27, 2024
2 parents 447f35c + c488d40 commit 436e29f
Show file tree
Hide file tree
Showing 400 changed files with 13,614 additions and 2,646 deletions.
5 changes: 3 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ jobs:
command: bin/build-phar.sh
- run:
name: Smoke test Phar file
command: build/psalm.phar --version
# Change the root away from the project root to avoid conflicts with the Composer autoloader
command: build/psalm.phar --version --root build
- store_artifacts:
path: build/psalm.phar
- run:
Expand All @@ -63,7 +64,7 @@ jobs:
# The resource_class feature allows configuring CPU and RAM resources for each job. Different resource classes are available for different executors. https://circleci.com/docs/2.0/configuration-reference/#resourceclass
resource_class: large
test-with-real-projects:
executor: php-81
executor: php-82
steps:
- checkout # used here just for the side effect of loading the github public ssh key so we can clone other stuff
- attach_workspace:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/bcc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
composer update --no-install
- name: Cache composer cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
${{ steps.composer-cache.outputs.files_cache }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build-phar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/[email protected].0
uses: fkirc/[email protected].1
with:
concurrent_skipping: always
cancel_others: true
Expand Down Expand Up @@ -59,7 +59,7 @@ jobs:
composer update --no-install
- name: Cache composer cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
${{ steps.composer-cache.outputs.files_cache }}
Expand Down
13 changes: 10 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,14 @@ jobs:
env:
COMPOSER_ROOT_VERSION: dev-master

- name: Check all classes are autoloadable
run: |
composer dump-autoload -o --strict-psr
env:
COMPOSER_ROOT_VERSION: dev-master

- name: Cache composer cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
${{ steps.composer-cache.outputs.files_cache }}
Expand Down Expand Up @@ -77,7 +83,7 @@ jobs:
COMPOSER_ROOT_VERSION: dev-master

- name: Cache composer cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
${{ steps.composer-cache.outputs.files_cache }}
Expand Down Expand Up @@ -135,6 +141,7 @@ jobs:
CHUNK_COUNT: "${{ matrix.count }}"
CHUNK_NUMBER: "${{ matrix.chunk }}"
PARALLEL_PROCESSES: 5
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}

steps:
- name: Set up PHP
Expand Down Expand Up @@ -163,7 +170,7 @@ jobs:
COMPOSER_ROOT_VERSION: dev-master

- name: Cache composer cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
${{ steps.composer-cache.outputs.files_cache }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-labels.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Pull Request Labels
name: Pull Request Labels (to be added by maintainers)
on:
pull_request:
types: [opened, reopened, labeled, unlabeled, synchronize]
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/windows-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,12 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
ini-values: zend.assertions=1, assert.exception=1, opcache.enable_cli=1, opcache.jit=function, opcache.jit_buffer_size=512M
#ini-values: zend.assertions=1, assert.exception=1, opcache.enable_cli=1, opcache.jit=function, opcache.jit_buffer_size=512M
ini-values: zend.assertions=1, assert.exception=1
tools: composer:v2
coverage: none
extensions: none, curl, dom, filter, intl, json, libxml, mbstring, openssl, opcache, pcre, phar, reflection, simplexml, spl, tokenizer, xml, xmlwriter
#extensions: none, curl, dom, filter, intl, json, libxml, mbstring, openssl, opcache, pcre, phar, reflection, simplexml, spl, tokenizer, xml, xmlwriter
extensions: none, curl, dom, filter, intl, json, libxml, mbstring, openssl, pcre, phar, reflection, simplexml, spl, tokenizer, xml, xmlwriter
env:
fail-fast: true

Expand All @@ -83,7 +85,7 @@ jobs:
COMPOSER_ROOT_VERSION: dev-master

- name: Cache composer cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
${{ steps.composer-cache.outputs.files_cache }}
Expand Down
5 changes: 4 additions & 1 deletion UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@
- [BC] The only optional boolean parameter of `TKeyedArray::getGenericArrayType` was removed, and was replaced with a string parameter with a different meaning.

- [BC] The `TDependentListKey` type was removed and replaced with an optional property of the `TIntRange` type.
-
- [BC] `TCallableArray` and `TCallableList` removed and replaced with `TCallableKeyedArray`.

- [BC] Value of constant `Psalm\Type\TaintKindGroup::ALL_INPUT` changed to reflect new `TaintKind::INPUT_SLEEP` and `TaintKind::INPUT_XPATH` have been added. Accordingly, default values for `$taint` parameters of `Psalm\Codebase::addTaintSource()` and `Psalm\Codebase::addTaintSink()` have been changed as well.
- [BC] Class `Psalm\Issue\MixedInferredReturnType` was removed

- [BC] Value of constant `Psalm\Type\TaintKindGroup::ALL_INPUT` changed to reflect new `TaintKind::INPUT_EXTRACT`, `TaintKind::INPUT_SLEEP` and `TaintKind::INPUT_XPATH` have been added. Accordingly, default values for `$taint` parameters of `Psalm\Codebase::addTaintSource()` and `Psalm\Codebase::addTaintSink()` have been changed as well.

- [BC] Property `Config::$shepherd_host` was replaced with `Config::$shepherd_endpoint`

Expand Down
12 changes: 9 additions & 3 deletions bin/test-with-real-projects.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ collections)
git clone --depth=1 [email protected]:psalm/endtoend-test-collections.git
cd endtoend-test-collections
composer install
rm vendor/amphp/amp/lib/functions.php; touch vendor/amphp/amp/lib/functions.php;
rm vendor/amphp/amp/lib/Internal/functions.php; touch vendor/amphp/amp/lib/Internal/functions.php
rm vendor/amphp/byte-stream/lib/functions.php; touch vendor/amphp/byte-stream/lib/functions.php
"$PSALM" --monochrome --show-info=false
;;

Expand All @@ -36,10 +39,13 @@ psl)

git clone [email protected]:psalm/endtoend-test-psl.git
cd endtoend-test-psl
git checkout 2.3.x
git checkout 2.3.x_master
composer install
"$PSALM" --monochrome -c config/psalm.xml
"$PSALM" --monochrome -c config/psalm.xml tests/static-analysis
# Avoid conflicts with old psalm when running phar tests
rm -rf vendor/vimeo/psalm
sed 's/ErrorOutputBehavior::Packed, ErrorOutputBehavior::Discard/ErrorOutputBehavior::Discard/g' -i src/Psl/Shell/execute.php
"$PSALM_PHAR" --monochrome -c config/psalm.xml
"$PSALM_PHAR" --monochrome -c config/psalm.xml tests/static-analysis
;;

laravel)
Expand Down
27 changes: 23 additions & 4 deletions bin/tests-github-actions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
set -eu

function get_seeded_random() {
openssl enc -aes-256-ctr -pass pass:"vimeo/psalm" -nosalt </dev/zero 2>/dev/null
local -r branch_name="$1"
openssl enc -aes-256-ctr -pass pass:"$branch_name" -nosalt </dev/zero 2>/dev/null
}

function run {
local -r chunk_count="$1"
local -r chunk_number="$2"
local -r parallel_processes="$3"
local -r branch_name="$4"

local -r phpunit_cmd='
echo "::group::{}";
Expand All @@ -23,13 +25,30 @@ exit "$exit_code"'

mkdir -p build/parallel/ build/phpunit/logs/

find tests -name '*Test.php' | shuf --random-source=<(get_seeded_random) > build/tests_all
split --number="l/$chunk_number/$chunk_count" build/tests_all > build/tests_split
find tests -name '*Test.php' | shuf --random-source=<(get_seeded_random "$branch_name") > build/tests_all
# split incorrectly splits the lines by byte size, which means that the number of tests per file are as evenly distributed as possible
#split --number="l/$chunk_number/$chunk_count" build/tests_all > build/tests_split
local -r lines=$(wc -l <build/tests_all)
local -r chunk_lines=$(( $lines / $chunk_count ))
local -r rest=$(( $lines % $chunk_count ))
local start_line
local end_line
if [[ $chunk_number -le $rest ]]
then
start_line=$(( ($chunk_number - 1) * $chunk_lines + $chunk_number ))
end_line=$(( $chunk_number * $chunk_lines + $chunk_number ))
else
start_line=$(( ($chunk_number - 1) * $chunk_lines + $rest + 1 ))
end_line=$(( $chunk_number * $chunk_lines + $rest ))
fi
awk "NR==$start_line,NR==$end_line" <build/tests_all > build/tests_split

parallel --group -j"$parallel_processes" --rpl {_}\ s/\\//_/g --joblog build/parallel/jobs.log "$phpunit_cmd" < build/tests_split
}

if [ -z "${CHUNK_COUNT:-}" ]; then echo "Did not find env var CHUNK_COUNT."; exit 1; fi
if [ -z "${CHUNK_NUMBER:-}" ]; then echo "Did not find env var CHUNK_NUMBER."; exit 1; fi
if [ -z "${PARALLEL_PROCESSES:-}" ]; then echo "Did not find env var PARALLEL_PROCESSES."; exit 1; fi
if [ -z "${BRANCH_NAME:-}" ]; then echo "Did not find env var BRANCH_NAME."; exit 1; fi

run "$CHUNK_COUNT" "$CHUNK_NUMBER" "$PARALLEL_PROCESSES"
run "$CHUNK_COUNT" "$CHUNK_NUMBER" "$PARALLEL_PROCESSES" "$BRANCH_NAME"
37 changes: 14 additions & 23 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,13 @@
"dnoegel/php-xdg-base-dir": "^0.1.1",
"felixfbecker/advanced-json-rpc": "^3.1",
"felixfbecker/language-server-protocol": "^1.5.2",
"fidry/cpu-core-counter": "^0.4.1 || ^0.5.1",
"fidry/cpu-core-counter": "^0.4.1 || ^0.5.1 || ^1.0.0",
"netresearch/jsonmapper": "^1.0 || ^2.0 || ^3.0 || ^4.0",
"nikic/php-parser": "^4.16",
"sebastian/diff": "^4.0 || ^5.0",
"nikic/php-parser": "^5.0.0",
"sebastian/diff": "^4.0 || ^5.0 || ^6.0",
"spatie/array-to-xml": "^2.17.0 || ^3.0",
"symfony/console": "^4.1.6 || ^5.0 || ^6.0",
"symfony/filesystem": "^5.4 || ^6.0"
},
"conflict": {
"nikic/php-parser": "4.17.0"
"symfony/console": "^4.1.6 || ^5.0 || ^6.0 || ^7.0",
"symfony/filesystem": "^5.4 || ^6.0 || ^7.0"
},
"provide": {
"psalm/psalm": "self.version"
Expand All @@ -60,7 +57,7 @@
"psalm/plugin-phpunit": "^0.18",
"slevomat/coding-standard": "^8.4",
"squizlabs/php_codesniffer": "^3.6",
"symfony/process": "^4.4 || ^5.0 || ^6.0"
"symfony/process": "^4.4 || ^5.0 || ^6.0 || ^7.0"
},
"suggest": {
"ext-igbinary": "^2.0.5 is required, used to serialize caching data",
Expand Down Expand Up @@ -96,12 +93,6 @@
"Psalm\\Tests\\": "tests/"
}
},
"repositories": [
{
"type": "path",
"url": "examples/plugins/composer-based/echo-checker"
}
],
"minimum-stability": "dev",
"prefer-stable": true,
"bin": [
Expand All @@ -112,20 +103,20 @@
"psalter"
],
"scripts": {
"cs": "phpcs -ps",
"cs-fix": "phpcbf -ps",
"lint": "parallel-lint ./src ./tests",
"cs": "@php phpcs -ps",
"cs-fix": "@php phpcbf -ps",
"lint": "@php parallel-lint ./src ./tests",
"phpunit": [
"Composer\\Config::disableProcessTimeout",
"paratest -f --runner=WrapperRunner"
],
"phpunit-std": [
"Composer\\Config::disableProcessTimeout",
"phpunit"
"@php phpunit"
],
"verify-callmap": "@php phpunit tests/Internal/Codebase/InternalCallMapHandlerTest.php",
"psalm": "@php ./psalm",
"psalm-set-baseline": "@php ./psalm --set-baseline=psalm-baseline.xml",
"psalm-set-baseline": "@php ./psalm --set-baseline",
"tests": [
"@lint",
"@cs",
Expand All @@ -143,8 +134,8 @@
"tests": "Runs all available tests."
},
"support": {
"docs": "https://psalm.dev/docs",
"issues": "https://github.com/vimeo/psalm/issues",
"source": "https://github.com/vimeo/psalm"
"docs": "https://psalm.dev/docs",
"issues": "https://github.com/vimeo/psalm/issues",
"source": "https://github.com/vimeo/psalm"
}
}
9 changes: 8 additions & 1 deletion config.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@
<xs:attribute name="checkForThrowsInGlobalScope" type="xs:boolean" default="false" />
<xs:attribute name="ensureArrayIntOffsetsExist" type="xs:boolean" default="false" />
<xs:attribute name="ensureArrayStringOffsetsExist" type="xs:boolean" default="false" />
<xs:attribute name="ensureOverrideAttribute" type="xs:boolean" default="false" />
<xs:attribute name="findUnusedCode" type="xs:boolean" default="false" />
<xs:attribute name="findUnusedVariablesAndParams" type="xs:boolean" default="false" />
<xs:attribute name="findUnusedPsalmSuppress" type="xs:boolean" default="false" />
<!-- TODO: Update default to true in Psalm 6 -->
<xs:attribute name="findUnusedBaselineEntry" type="xs:boolean" default="false" />
<xs:attribute name="findUnusedIssueHandlerSuppression" type="xs:boolean" default="true" />
<xs:attribute name="hideExternalErrors" type="xs:boolean" default="false" />
<xs:attribute name="hoistConstants" type="xs:boolean" default="false" />
<xs:attribute name="ignoreInternalFunctionFalseReturn" type="xs:boolean" default="false" />
Expand Down Expand Up @@ -284,6 +286,7 @@
<xs:element name="InvalidNamedArgument" type="ArgumentIssueHandlerType" minOccurs="0" />
<xs:element name="InvalidNullableReturnType" type="IssueHandlerType" minOccurs="0" />
<xs:element name="InvalidOperand" type="IssueHandlerType" minOccurs="0" />
<xs:element name="InvalidOverride" type="IssueHandlerType" minOccurs="0" />
<xs:element name="InvalidParamDefault" type="IssueHandlerType" minOccurs="0" />
<xs:element name="InvalidParent" type="IssueHandlerType" minOccurs="0" />
<xs:element name="InvalidPassByReference" type="IssueHandlerType" minOccurs="0" />
Expand Down Expand Up @@ -319,6 +322,7 @@
<xs:element name="MissingDocblockType" type="IssueHandlerType" minOccurs="0" />
<xs:element name="MissingFile" type="IssueHandlerType" minOccurs="0" />
<xs:element name="MissingImmutableAnnotation" type="IssueHandlerType" minOccurs="0" />
<xs:element name="MissingOverrideAttribute" type="IssueHandlerType" minOccurs="0" />
<xs:element name="MissingParamType" type="IssueHandlerType" minOccurs="0" />
<xs:element name="MissingPropertyType" type="PropertyIssueHandlerType" minOccurs="0" />
<xs:element name="MissingReturnType" type="IssueHandlerType" minOccurs="0" />
Expand All @@ -333,7 +337,6 @@
<xs:element name="MixedAssignment" type="IssueHandlerType" minOccurs="0" />
<xs:element name="MixedClone" type="ArgumentIssueHandlerType" minOccurs="0" />
<xs:element name="MixedFunctionCall" type="IssueHandlerType" minOccurs="0" />
<xs:element name="MixedInferredReturnType" type="IssueHandlerType" minOccurs="0" />
<xs:element name="MixedMethodCall" type="IssueHandlerType" minOccurs="0" />
<xs:element name="MixedOperand" type="IssueHandlerType" minOccurs="0" />
<xs:element name="MixedPropertyAssignment" type="IssueHandlerType" minOccurs="0" />
Expand Down Expand Up @@ -420,6 +423,7 @@
<xs:element name="RedundantCastGivenDocblockType" type="IssueHandlerType" minOccurs="0" />
<xs:element name="RedundantCondition" type="IssueHandlerType" minOccurs="0" />
<xs:element name="RedundantConditionGivenDocblockType" type="IssueHandlerType" minOccurs="0" />
<xs:element name="RedundantFlag" type="IssueHandlerType" minOccurs="0" />
<xs:element name="RedundantFunctionCall" type="IssueHandlerType" minOccurs="0" />
<xs:element name="RedundantFunctionCallGivenDocblockType" type="IssueHandlerType" minOccurs="0" />
<xs:element name="RedundantIdentityWithTrue" type="IssueHandlerType" minOccurs="0" />
Expand All @@ -428,11 +432,13 @@
<xs:element name="ReferenceReusedFromConfusingScope" type="IssueHandlerType" minOccurs="0" />
<xs:element name="ReservedWord" type="IssueHandlerType" minOccurs="0" />
<xs:element name="RiskyCast" type="IssueHandlerType" minOccurs="0" />
<xs:element name="RiskyTruthyFalsyComparison" type="IssueHandlerType" minOccurs="0" />
<xs:element name="StringIncrement" type="IssueHandlerType" minOccurs="0" />
<xs:element name="TaintedCallable" type="IssueHandlerType" minOccurs="0" />
<xs:element name="TaintedCookie" type="IssueHandlerType" minOccurs="0" />
<xs:element name="TaintedCustom" type="IssueHandlerType" minOccurs="0" />
<xs:element name="TaintedEval" type="IssueHandlerType" minOccurs="0" />
<xs:element name="TaintedExtract" type="IssueHandlerType" minOccurs="0" />
<xs:element name="TaintedFile" type="IssueHandlerType" minOccurs="0" />
<xs:element name="TaintedHeader" type="IssueHandlerType" minOccurs="0" />
<xs:element name="TaintedHtml" type="IssueHandlerType" minOccurs="0" />
Expand Down Expand Up @@ -494,6 +500,7 @@
<xs:element name="UnusedClosureParam" type="IssueHandlerType" minOccurs="0" />
<xs:element name="UnusedConstructor" type="MethodIssueHandlerType" minOccurs="0" />
<xs:element name="UnusedDocblockParam" type="IssueHandlerType" minOccurs="0" />
<xs:element name="UnusedIssueHandlerSuppression" type="IssueHandlerType" minOccurs="0" />
<xs:element name="UnusedForeachValue" type="IssueHandlerType" minOccurs="0" />
<xs:element name="UnusedFunctionCall" type="FunctionIssueHandlerType" minOccurs="0" />
<xs:element name="UnusedMethod" type="MethodIssueHandlerType" minOccurs="0" />
Expand Down
Loading

0 comments on commit 436e29f

Please sign in to comment.