diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..e469eccd --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,60 @@ +name: build + +on: [push, pull_request] + +env: + FORCE_COLOR: 3 + +jobs: + test: + if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main' + runs-on: ${{ matrix.os }} + strategy: + matrix: + include: + - xdebug: xdebug-3.1.1 # renovate:keep-up-to-date + php: '7.4' + os: ubuntu-18.04 + steps: + - uses: actions/checkout@v2 + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: '14.15.3' # renovate:keep-up-to-date + - name: Install npm dependencies + run: npm ci + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: ${{ matrix.xdebug }}, ast + tools: composer + - name: Composer Install + run: composer install + - name: phpcs + run: ./vendor/bin/phpcs -n +# - name: phan +# run: ./vendor/bin/phan + - name: phpunit + run: vendor/bin/phpunit --coverage-clover=coverage.xml --colors=always + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v2 +# release: +# runs-on: ubuntu-18.04 +# needs: test +# if: github.repository_owner == 'xdebug' && github.event_name == 'push' && github.ref == 'refs/heads/main' +# steps: +# - uses: actions/checkout@v2 +# - name: Setup Node.js +# uses: actions/setup-node@v2 +# with: +# node-version: '14.15.3' # renovate:keep-up-to-date +# - name: Install npm dependencies +# run: npm ci +# - name: Build VS Code extension +# run: npm run build +# - name: Release +# env: +# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +# VSCE_TOKEN: ${{ secrets.VSCE_TOKEN }} +# run: npm run semantic-release diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index da1f1183..00000000 --- a/.travis.yml +++ /dev/null @@ -1,60 +0,0 @@ -language: php - -php: - - '7.0' - - '7.2' - -git: - depth: 10 - submodules: false - -cache: - directories: - - $HOME/Library/Caches/Homebrew - - $HOME/.composer/cache - - $HOME/.npm - -install: - - composer install --prefer-dist --no-interaction - - pecl install ast-1.0.0 - -script: - - vendor/bin/phpcs -n - - vendor/bin/phan - - vendor/bin/phpunit --coverage-clover=coverage.xml --colors=always - - bash <(curl -s https://codecov.io/bash) - -jobs: - include: - - stage: test - os: osx - osx_image: xcode9.1 - language: generic - before_install: - # Fix ruby error https://github.com/Homebrew/brew/issues/3299 - - brew update - - brew install php@7.1 - - brew link --force --overwrite php@7.1 - - pecl install xdebug-2.6.0 - - php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" - - php composer-setup.php - - ln -s "`pwd`/composer.phar" /usr/local/bin/composer - - stage: release - php: '7.0' - services: - - docker - install: - - nvm install 8 - - nvm use 8 - - npm install - script: - - ./node_modules/.bin/semantic-release - -stages: - - test - - name: release - if: branch = master AND type = push AND fork = false - -branches: - only: - - master diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 7d0525cf..00000000 --- a/appveyor.yml +++ /dev/null @@ -1,54 +0,0 @@ -version: '{build}' - -image: Visual Studio 2017 -platform: - - x64 - -skip_tags: true -skip_branch_with_pr: true -clone_depth: 1 -max_jobs: 3 - -cache: - - '%LOCALAPPDATA%\Composer' - - '%LOCALAPPDATA%\Temp\Chocolatey' - -environment: - ANSICON: 121x90 (121x90) - matrix: - - { PHP_VERSION: '7.1.11', VC_VERSION: '14', XDEBUG_VERSION: '2.5.5' } - -install: - # Enable Windows Update service, needed to install vcredist2015 (dependency of php) - - ps: Set-Service wuauserv -StartupType Manual - - choco config set cacheLocation %LOCALAPPDATA%\Temp\Chocolatey - - choco install -y php --version %PHP_VERSION% - - choco install -y composer - - refreshenv - - composer install --no-interaction --no-progress --prefer-dist - # Install XDebug for code coverage - - ps: | - $client = New-Object System.Net.WebClient - $phpMinorVersion = $env:PHP_VERSION -replace '\.\d+$' - $xdebugUrl = "https://xdebug.org/files/php_xdebug-$env:XDEBUG_VERSION-$phpMinorVersion-vc14-nts-x86_64.dll" - $phpDir = (Get-Item (Get-Command php).Source).Directory.FullName - $xdebugPath = Join-Path $phpDir ext\xdebug.dll - $client.DownloadFile($xdebugUrl, $xdebugPath) - $phpIniPath = Join-Path $phpDir php.ini - Add-Content $phpIniPath @" - zend_extension=$xdebugPath - "@ - -build: off - -test_script: - - vendor\bin\phpunit --coverage-clover=coverage/coverage.xml - -after_test: - - ps: | - # Delete vendor because it causes problems with codecovs report search - # https://github.com/codecov/codecov-bash/issues/96 - Remove-Item -Recurse -Force vendor - $env:PATH = 'C:\msys64\usr\bin;' + $env:PATH - Invoke-WebRequest -Uri 'https://codecov.io/bash' -OutFile codecov.sh - bash codecov.sh -f 'coverage/coverage.xml' diff --git a/composer.json b/composer.json index f63bf3a1..6c41cb91 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "jetbrains/phpstorm-stubs": "dev-master", "microsoft/tolerant-php-parser": "0.0.*", "netresearch/jsonmapper": "^1.0", - "phpdocumentor/reflection-docblock": "^4.0.0", + "phpdocumentor/reflection-docblock": "^5.2.2", "psr/log": "^1.0", "sabre/event": "^5.0", "sabre/uri": "^2.0", @@ -36,9 +36,9 @@ "webmozart/path-util": "^2.3" }, "require-dev": { - "phpunit/phpunit": "^6.3", - "phan/phan": "1.1.4", - "squizlabs/php_codesniffer": "^3.1" + "phpunit/phpunit": "^6.5", + "phan/phan": "^3.2", + "squizlabs/php_codesniffer": "^3.6" }, "autoload": { "psr-4": { diff --git a/src/DefinitionResolver.php b/src/DefinitionResolver.php index adddf774..d1648d3b 100644 --- a/src/DefinitionResolver.php +++ b/src/DefinitionResolver.php @@ -1128,6 +1128,7 @@ public function getTypeFromNode($node) if ( $docBlock !== null && !empty($returnTags = $docBlock->getTagsByName('return')) + && $returnTags[0] instanceof DocBlock\Tags\Return_ && $returnTags[0]->getType() !== null ) { // Use @return tag @@ -1354,7 +1355,7 @@ private function tryGetDocBlockTagForParameter($docBlock, $variableName) } $tags = $docBlock->getTagsByName('param'); foreach ($tags as $tag) { - if ($tag->getVariableName() === \ltrim($variableName, "$")) { + if ($tag instanceof DocBlock\Tags\Param && $tag->getVariableName() === \ltrim($variableName, "$")) { return $tag; } } diff --git a/tests/Validation/cases/arrayValueShouldBeBoolean.php.expected.json b/tests/Validation/cases/arrayValueShouldBeBoolean.php.expected.json index f0cdb24d..84534a47 100644 --- a/tests/Validation/cases/arrayValueShouldBeBoolean.php.expected.json +++ b/tests/Validation/cases/arrayValueShouldBeBoolean.php.expected.json @@ -36,7 +36,7 @@ }, "containerName": "A" }, - "type__tostring": "bool[]", + "type__tostring": "array", "type": {}, "declarationLine": "protected $foo;", "documentation": null, diff --git a/tests/Validation/cases/magicConsts.php.expected.json b/tests/Validation/cases/magicConsts.php.expected.json index 27608e55..a45a72a8 100644 --- a/tests/Validation/cases/magicConsts.php.expected.json +++ b/tests/Validation/cases/magicConsts.php.expected.json @@ -40,7 +40,7 @@ }, "containerName": "A" }, - "type__tostring": "bool[]", + "type__tostring": "array<\\__CLASS__,bool>", "type": {}, "declarationLine": "private static $deprecationsTriggered;", "documentation": null,