Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into phpstorm-inspections
Browse files Browse the repository at this point in the history
* upstream/master: (609 commits)
  Register so it doesn’t get removed
  Add support for compact
  Allow suppression of unused variable issues
  Fix tests
  Fix unused ref in assign op
  Issue 1926 unused variable (vimeo#1967)
  Fix ignoreExceptions tags (vimeo#1966)
  Improve DOM extension types (vimeo#1965)
  Fix infinite recursion on property types
  Analyse binary ops always
  Mark private properties unused when referenced only in constructor (vimeo#1962)
  Prefix constant
  Add slash
  Normalise plugin path
  Also convert \\ to / when scanning windows configs on macs
  Fix file path weirdness when scanning config files
  Reduce with / before converting back
  Improve behaviour of templated template assertions
  Break out templated assertion tests
  Restore gitignore for .*.swp in sub-directories (vimeo#1958)
  ...

# Conflicts:
#	src/Psalm/Config.php
#	src/Psalm/Context.php
#	src/Psalm/Internal/Analyzer/ClassAnalyzer.php
#	src/Psalm/Internal/Analyzer/CommentAnalyzer.php
#	src/Psalm/Internal/Analyzer/FileAnalyzer.php
#	src/Psalm/Internal/Analyzer/FunctionAnalyzer.php
#	src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeAnalyzer.php
#	src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php
#	src/Psalm/Internal/Analyzer/MethodAnalyzer.php
#	src/Psalm/Internal/Analyzer/Statements/Block/ForeachAnalyzer.php
#	src/Psalm/Internal/Analyzer/Statements/Block/LoopAnalyzer.php
#	src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOpAnalyzer.php
#	src/Psalm/Internal/Analyzer/Statements/Expression/Call/NewAnalyzer.php
#	src/Psalm/Internal/Analyzer/Statements/Expression/CallAnalyzer.php
#	src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ConstFetchAnalyzer.php
#	src/Psalm/Internal/Analyzer/Statements/ReturnAnalyzer.php
#	src/Psalm/Internal/Analyzer/StatementsAnalyzer.php
#	src/Psalm/Internal/Analyzer/TypeAnalyzer.php
#	src/Psalm/Internal/Codebase/Analyzer.php
#	src/Psalm/Internal/Codebase/ClassLikes.php
#	src/Psalm/Internal/Codebase/Populator.php
#	src/Psalm/Internal/Codebase/Properties.php
#	src/Psalm/Internal/Codebase/Scanner.php
#	src/Psalm/Internal/LanguageServer/LanguageServer.php
#	src/Psalm/Internal/LanguageServer/Server/TextDocument.php
#	src/Psalm/Internal/Provider/FunctionExistenceProvider.php
#	src/Psalm/Internal/Provider/FunctionParamsProvider.php
#	src/Psalm/Internal/Provider/FunctionReturnTypeProvider.php
#	src/Psalm/Internal/Provider/MethodExistenceProvider.php
#	src/Psalm/Internal/Provider/MethodParamsProvider.php
#	src/Psalm/Internal/Provider/MethodReturnTypeProvider.php
#	src/Psalm/Internal/Provider/MethodVisibilityProvider.php
#	src/Psalm/Internal/Provider/PropertyExistenceProvider.php
#	src/Psalm/Internal/Provider/PropertyTypeProvider.php
#	src/Psalm/Internal/Provider/PropertyVisibilityProvider.php
#	src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayMapReturnTypeProvider.php
#	src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayReduceReturnTypeProvider.php
#	src/Psalm/Internal/Type/ParseTree.php
#	src/Psalm/Internal/Type/TypeCombination.php
#	src/Psalm/Internal/Visitor/ReflectorVisitor.php
#	src/Psalm/Type.php
#	src/Psalm/Type/Atomic/TNamedObject.php
#	src/Psalm/Type/Reconciler.php
#	src/command_functions.php
  • Loading branch information
voku committed Jul 25, 2019
2 parents 6b17426 + 352f18b commit 09369bd
Show file tree
Hide file tree
Showing 484 changed files with 30,462 additions and 8,827 deletions.
10 changes: 5 additions & 5 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ init:
environment:
SSL_CERT_FILE: "C:\\tools\\php\\cacert.pem"
matrix:
- php_ver_target: 7.0
DEPS: 'low'
- php_ver_target: 7.0
DEPS: 'high'
- php_ver_target: 7.1
DEPS: 'low'
- php_ver_target: 7.1
Expand Down Expand Up @@ -70,5 +66,9 @@ install:
## Run the actual test
test_script:
- cd c:\projects\php-project-workspace
- vendor/bin/phpunit
- vendor/bin/phpunit --log-junit build/phpunit/phpunit.xml
- php ./psalm --shepherd

on_finish:
- ps: $wc = New-Object 'System.Net.WebClient'
- ps: $wc.UploadFile("https://ci.appveyor.com/api/testresults/junit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\build\phpunit\phpunit.xml))
125 changes: 125 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# Use the latest 2.1 version of CircleCI pipeline processing engine, see https://circleci.com/docs/2.0/configuration-reference/
version: 2.1
executors:
php-72:
docker:
- image: thecodingmachine/php:7.2-v2-cli
jobs:
install-and-self-analyse:
executor: php-72
steps:
- checkout
- run: date "+%F" > /tmp/cachekey; cat composer.json >> /tmp/cachekey
- restore_cache:
keys:
- composer-v2-{{ checksum "/tmp/cachekey" }}
# fallback to using the latest cache if no exact match is found (See https://circleci.com/docs/2.0/caching/)
- composer-v2-
- run: composer update
- save_cache:
key: composer-v2-{{ checksum "/tmp/cachekey" }}
paths:
- vendor
- run:
name: Static analysis
command: php -dextension=pcntl.so ./psalm --threads=10
- persist_to_workspace:
root: /home/docker/project/
paths:
- .
"Code Style Analysis":
executor: php-72
steps:
- attach_workspace:
at: /home/docker/project/
- run:
name: Code Style Analysis with PHPCS
command: vendor/bin/phpcs
test:
executor: php-72
steps:
- attach_workspace:
at: /home/docker/project/
- run:
name: PHPUnit test
command: php vendor/bin/phpunit --log-junit build/phpunit/phpunit.xml
- store_test_results:
path: build/
- store_artifacts:
path: build/phpunit
- persist_to_workspace:
root: /home/docker/project/
paths:
- .
coverage:
executor: php-72
steps:
- attach_workspace:
at: /home/docker/project/
- run:
name: PHPUnit test with coverage
command: php -dextension=pcov.so vendor/bin/phpunit --coverage-html build/phpunit/coverage-html
- store_artifacts:
path: build/phpunit/coverage-html
- run:
name: Display link to coverage report
command: |
echo "PHPUnit coverage report available at:"
echo https://circleci.com/api/v1.1/project/github/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/${CIRCLE_BUILD_NUM}/artifacts/0/home/docker/project/build/phpunit/coverage-html/index.html
phar-build:
executor: php-72
steps:
- attach_workspace:
at: /home/docker/project/
- run:
name: Build Phar file
command: bin/build-phar.sh
- run:
name: Smoke test Phar file
command: build/psalm.phar --version
- store_artifacts:
path: build/psalm.phar
- run:
name: Display link to phar file
command: |
echo "Phar build available at:"
echo https://circleci.com/api/v1.1/project/github/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/${CIRCLE_BUILD_NUM}/artifacts/0/home/docker/project/build/psalm.phar
- persist_to_workspace:
root: /home/docker/project/
paths:
- build/psalm.phar
test-with-real-projects:
executor: php-72
steps:
- checkout # used here just for the side effect of loading the github public ssh key so we can clone other stuff
- attach_workspace:
at: /home/docker/project/
- run:
name: Analyse PHPUnit
command: bin/test-with-real-projects.sh
- store_artifacts:
path: build/psalm.phar

# Orchestrate or schedule a set of jobs, see https://circleci.com/docs/2.0/workflows/
workflows:
Welcome:
jobs:
- install-and-self-analyse
- test:
requires:
- install-and-self-analyse
- "Code Style Analysis":
requires:
- install-and-self-analyse
- coverage:
requires:
- test
- "Code Style Analysis"
- phar-build:
requires:
- test
- "Code Style Analysis"
- test-with-real-projects:
requires:
- phar-build
10 changes: 8 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
/build/
/vendor/
/extra/
.DS_Store
/.php_cs.cache
/.php_cs
/.*.swp
/.*.swo
/.phpunit.result.cache
.*.swp
.*.swo
/composer.lock
/phpunit.xml
/vendor-bin/*/composer.lock
/vendor-bin/*/vendor/
/tests/fixtures/symlinktest/*

.idea/inspectionProfiles/Project_Default.xml
.idea/workspace.xml
64 changes: 24 additions & 40 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ stages:
- Code style analysis
- test
- Phar build
- Code coverage analysis
# - Code coverage analysis

php:
- 7.0
- 7.1
- 7.2
- 7.3
- 7.4snapshot

env:
matrix:
Expand Down Expand Up @@ -43,60 +43,44 @@ install:

script:
- vendor/bin/phpunit
- ./psalm
- ./psalm --shepherd

# Base test matrix (php/env)
matrix:
fast_finish: true
allow_failures:
- php: nightly
exclude: # covered in Code coverage stage
- php: 7.3
env: DEPS="high"
- php: 7.4snapshot

# Additional stages
jobs:
include:
- stage: Code coverage analysis
php: 7.3
# don't disable xdebug here
env: XDEBUG="true"
install:
- composer $DEFAULT_COMPOSER_FLAGS update
- composer require --dev php-coveralls/php-coveralls
- mkdir -p build
before_script:
- vendor/bin/phpunit --dump-xdebug-filter build/xdebug-filter.php
script:
- vendor/bin/phpunit --prepend build/xdebug-filter.php
- ./psalm --shepherd
after_success:
- travis_retry php vendor/bin/php-coveralls -v

- stage: Code style analysis
php: 7.3
env: DEPS="high"
script:
- vendor/bin/phpcs

# always build phar, but only deploy on tag builds
- stage: Phar build
php: 7.3
env: DEPS="high"
script:
- bin/build-phar.sh
- if [[ "$TRAVIS_PULL_REQUEST" = 'false' ]]; then bin/travis-deploy-phar.sh; fi
before_deploy:
- echo $GPG_ENCRYPTION | gpg --passphrase-fd 0 keys.asc.gpg
- gpg --batch --yes --import keys.asc
- echo $SIGNING_KEY | gpg --passphrase-fd 0 -u 8A03EA3B385DBAA1 --armor --detach-sig build/psalm.phar
- cd phar && git tag ${TRAVIS_TAG} && git push origin ${TRAVIS_TAG} && cd ..
script: bin/build-phar.sh
deploy:
skip_cleanup: true
on:
tags: true
provider: releases
api_key: $GITHUB_TOKEN
file:
- build/psalm.phar
- build/psalm.phar.asc
# deploy tagged releases to github releases page
- provider: releases
skip_cleanup: true
on:
tags: true
repo: vimeo/psalm
api_key: $GITHUB_TOKEN
file:
- build/psalm.phar
- build/psalm.phar.asc

# deploy built phar to github.com/psalm/phar repo for all branches and tags,
# but not for pull requests
- provider: script
skip_cleanup: true
on:
all_branches: true
condition: ' "$TRAVIS_PULL_REQUEST" = "false" '
script: bin/travis-deploy-phar.sh
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ Make sure to check out the [Contributing to Open Source on GitHub](https://guide
You can create an issue [here](https://github.com/vimeo/psalm/issues/new), but before you do, follow these guidelines:

* Make sure that you are using the latest version (`dev-master`).
* It’s by no means a requirement, but if it's a bug, and you provide demonstration code that can be pasted into https://getpsalm.org, it will likely get fixed faster.
* It’s by no means a requirement, but if it's a bug, and you provide demonstration code that can be pasted into https://psalm.dev, it will likely get fixed faster.

## Pull Requests

Before you send a pull request, make sure you follow these guidelines:

* Make sure to run `composer tests` and `./psalm --find-dead-code` to ensure that Travis builds will pass
* Make sure to run `composer tests` and `./psalm --find-dead-code` to ensure that Travis builds will pass
* Don’t forget to add tests!
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

Psalm is a static analysis tool for finding errors in PHP applications, built on top of [PHP Parser](https://github.com/nikic/php-parser).

It's able to find a [large number of issues](https://github.com/vimeo/psalm/blob/master/docs/issues.md), but it can also be configured to only care about a small subset of those.
It's able to find a [large number of issues](https://github.com/vimeo/psalm/blob/master/docs/running_psalm/issues.md), but it can also be configured to only care about a small subset of those.

[Try a live demo](https://psalm.dev/), or install it in your project by following the Quickstart Guide below.

Expand Down Expand Up @@ -43,7 +43,7 @@ The config created above will show you all issues in your code, but will emit `I
./vendor/bin/psalm --init [source_dir] [level]
```

You can also [learn how to suppress certain issues](https://github.com/vimeo/psalm/blob/master/docs/dealing_with_code_issues.md).
You can also [learn how to suppress certain issues](https://github.com/vimeo/psalm/blob/master/docs/running_psalm/dealing_with_code_issues.md).

## How Psalm Works

Expand Down
1 change: 1 addition & 0 deletions assets/config_levels/1.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0"?>
<psalm
totallyTyped="true"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
Expand Down
1 change: 1 addition & 0 deletions assets/config_levels/2.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0"?>
<psalm
totallyTyped="false"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
Expand Down
2 changes: 2 additions & 0 deletions assets/config_levels/3.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0"?>
<psalm
totallyTyped="false"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
Expand All @@ -21,6 +22,7 @@
<DeprecatedProperty errorLevel="info" />
<DeprecatedClass errorLevel="info" />
<DeprecatedConstant errorLevel="info" />
<DeprecatedFunction errorLevel="info" />
<DeprecatedInterface errorLevel="info" />
<DeprecatedTrait errorLevel="info" />

Expand Down
2 changes: 2 additions & 0 deletions assets/config_levels/4.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0"?>
<psalm
totallyTyped="false"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
Expand All @@ -21,6 +22,7 @@
<DeprecatedProperty errorLevel="info" />
<DeprecatedClass errorLevel="info" />
<DeprecatedConstant errorLevel="info" />
<DeprecatedFunction errorLevel="info" />
<DeprecatedInterface errorLevel="info" />
<DeprecatedTrait errorLevel="info" />

Expand Down
3 changes: 3 additions & 0 deletions assets/config_levels/5.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0"?>
<psalm
totallyTyped="false"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
Expand All @@ -21,6 +22,7 @@
<DeprecatedProperty errorLevel="info" />
<DeprecatedClass errorLevel="info" />
<DeprecatedConstant errorLevel="info" />
<DeprecatedFunction errorLevel="info" />
<DeprecatedInterface errorLevel="info" />
<DeprecatedTrait errorLevel="info" />

Expand Down Expand Up @@ -102,5 +104,6 @@
<TypeDoesNotContainNull errorLevel="info" />
<MissingDocblockType errorLevel="info" />
<ImplementedReturnTypeMismatch errorLevel="info" />
<ImplementedParamTypeMismatch errorLevel="info" />
</issueHandlers>
</psalm>
3 changes: 3 additions & 0 deletions assets/config_levels/6.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0"?>
<psalm
totallyTyped="false"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
Expand All @@ -21,6 +22,7 @@
<DeprecatedProperty errorLevel="info" />
<DeprecatedClass errorLevel="info" />
<DeprecatedConstant errorLevel="info" />
<DeprecatedFunction errorLevel="info" />
<DeprecatedInterface errorLevel="info" />
<DeprecatedTrait errorLevel="info" />

Expand Down Expand Up @@ -102,6 +104,7 @@
<TypeDoesNotContainNull errorLevel="info" />
<MissingDocblockType errorLevel="info" />
<ImplementedReturnTypeMismatch errorLevel="info" />
<ImplementedParamTypeMismatch errorLevel="info" />

<!-- level 6 issues - really bad things -->

Expand Down
Loading

0 comments on commit 09369bd

Please sign in to comment.