Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement phpstan doc parsing #51

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/lint-and-analyse.yml
Original file line number Diff line number Diff line change
@@ -12,10 +12,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use php 7.2
- name: Use php 7.4
uses: shivammathur/setup-php@v2
with:
php-version: 7.2
php-version: 7.4
tools: composer:v2
- name: Validate composer.json and composer.lock
run: composer validate
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ jobs:
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
php-version: ["7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3"]
php-version: ["7.4", "8.0", "8.1", "8.2", "8.3"]
os: [ubuntu-latest]
experimental: [false]
composer-options: ['']
@@ -51,7 +51,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-version: ["7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3"]
php-version: ["7.4", "8.0", "8.1", "8.2", "8.3"]
os: [ubuntu-latest]
experimental: [false]
composer-options: ['']
@@ -83,7 +83,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-version: ["7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3"]
php-version: ["7.4", "8.0", "8.1", "8.2", "8.3"]
os: [ubuntu-latest]
experimental: [false]
composer-options: ['']
@@ -117,7 +117,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-version: ["7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3"]
php-version: ["7.4", "8.0", "8.1", "8.2", "8.3"]
os: [ubuntu-latest]
experimental: [false]
composer-options: ['']
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased] - yyyy-mm-dd

- Require PHP `7.4.26`

## [5.5.4] - 2023-12-16

- Fix PHP 8.2 dynamic properties for configurations with the `language` key
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ Installation

.. caution::

Doctum requires **PHP 7.2.20** or later.
Doctum requires **PHP 7.4.26** or later.

Get Doctum as a `phar file`_:

8 changes: 6 additions & 2 deletions bin/doctum-binary.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<?php

if (PHP_VERSION_ID < 70220) {// 70 2 20
echo 'You need to use PHP 7.2.20 or above to run Doctum.' . PHP_EOL;
if (PHP_VERSION_ID < 70426) {// 70 4 26
echo 'You need to use PHP 7.4.26 or above to run Doctum.' . PHP_EOL;
if (PHP_MAJOR_VERSION === 7 && PHP_MINOR_VERSION === 4 && PHP_RELEASE_VERSION < 26) {
echo 'We decided not having an updated PHP 7.4 was not healthy and has security issues.' . PHP_EOL;
echo 'You can discuss about that with us on: https://github.com/code-lts/doctum/discussions.' . PHP_EOL;
}
echo 'Current detected version: (' . PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . ') (' . PHP_VERSION_ID . ').' . PHP_EOL;
exit(1);
}
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -35,16 +35,15 @@
}
],
"require": {
"php": "^7.2.20 || ^8.0",
"php": "^7.4.26 || ^8.0",
"twig/twig": "^3.0",
"nikic/php-parser": "^4.10",
"symfony/console": "~3.4|~4.3|^5|^6",
"symfony/finder": "~3.4|~4.3|^5|^6",
"symfony/filesystem": "~3.4|~4.3|^5|^6",
"symfony/yaml": "~3.4|~4.3|^5|^6",
"symfony/process": "~3.4|~4.3|^5|^6",
"phpdocumentor/reflection-docblock": "~5.3",
"phpdocumentor/type-resolver": "1.6.*",
"phpdocumentor/reflection-docblock": "5.x-dev#f359e4f",
"wdes/php-i18n-l10n": "^4.0",
"code-lts/cli-tools": "^1.4.0",
"erusev/parsedown": "^1.7"
@@ -72,6 +71,7 @@
}
},
"prefer-stable": true,
"minimum-stability": "dev",
"bin": [
"bin/doctum.php"
],
5 changes: 0 additions & 5 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1985,11 +1985,6 @@ parameters:
count: 1
path: tests/Parser/DocBlockParserTest.php

-
message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\) with array\\{'The hint on \"prop1\"…'\\} and array\\{\\} will always evaluate to false\\.$#"
count: 1
path: tests/Parser/NodeVisitorTest.php

-
message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\) with array\\{'Too much @return…'\\} and array\\{\\} will always evaluate to false\\.$#"
count: 1
22 changes: 16 additions & 6 deletions tests/Parser/DocBlockParserTest.php
Original file line number Diff line number Diff line change
@@ -298,7 +298,7 @@ public function getParseTests(): array
],
],
],
[
'Test that @throws with a dot at the end works' => [
'
/**
* @throws \InvalidArgumentException.
@@ -311,8 +311,14 @@ public function getParseTests(): array
'longDesc' => '',
'tags' => [
'throws' => [
'\InvalidArgumentException.',
'\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException.',
[
'\InvalidArgumentException',
'',
],
[
'\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException',
'',
],
],
],
],
@@ -594,7 +600,7 @@ public function getParseTests(): array
],
]],
],
[
'Test that invalid @return format also works' => [
'/**
* Prepares queries for adding users and
* also create database and return query and message
@@ -630,8 +636,12 @@ public function getParseTests(): array
'SQL query for add a user',
],
],
'return' => [
'array, $message',

'return' => [ // Array from found tags.
[ // First found tag.
[['array', false]], // Array from data types.
', $message', // The description
],
],
],
]],
1 change: 0 additions & 1 deletion tests/Parser/NodeVisitorTest.php
Original file line number Diff line number Diff line change
@@ -553,7 +553,6 @@ public function testAddTagFromCommentToMethodInvalidHint(): void
);
$this->assertSame(
[
'The hint on "prop1" at @var is invalid: "\Illuminate\Support\Carbon;"',
],
$errors
);
1 change: 1 addition & 0 deletions tests/composer-package-auto-test.sh
Original file line number Diff line number Diff line change
@@ -27,6 +27,7 @@ recreateSetup() {
}
}
],
"minimum-stability": "dev",
"require": {
"code-lts/doctum": "5.x-dev"
}