Skip to content

Commit 2fadfed

Browse files
Tag version 0.1.0
1 parent 2537421 commit 2fadfed

11 files changed

+652
-2
lines changed

.github/workflows/all_tests.yml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: "All Tests"
2+
3+
on:
4+
pull_request:
5+
push:
6+
7+
jobs:
8+
test:
9+
name: "Run all checks for all supported PHP versions"
10+
11+
runs-on: "ubuntu-22.04"
12+
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
php-version:
17+
- "8.0"
18+
- "8.1"
19+
- "8.2"
20+
- "8.3"
21+
22+
steps:
23+
- name: "Checkout"
24+
uses: "actions/checkout@v4"
25+
26+
- name: "Install PHP"
27+
uses: "shivammathur/setup-php@v2"
28+
with:
29+
php-version: "${{ matrix.php-version }}"
30+
tools: composer
31+
32+
- name: Get composer cache directory
33+
id: composercache
34+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
35+
36+
- name: Cache dependencies
37+
uses: actions/cache@v4
38+
with:
39+
path: ${{ steps.composercache.outputs.dir }}
40+
key: "php-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }}"
41+
restore-keys: "php-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }}"
42+
43+
- name: "Install composer dependencies"
44+
run: "COMPOSER_ROOT_VERSION=dev-main composer install --no-interaction --no-progress"
45+
46+
- name: "Run tests"
47+
run: "composer tests"

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/vendor/
2+
composer.lock

.phpunit.cache/test-results

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"version":1,"defects":{"test\\PhpStaticAnalysis\\NodeVisitor\\AttributeNodeVisitorTest::testAddsReadOnlyPHPDocMaintainingExistingPHPDoc":3,"test\\PhpStaticAnalysis\\NodeVisitor\\AttributeNodeVisitorTest::testAddsMultipleTemplatePHPDocs":3,"test\\PhpStaticAnalysis\\NodeVisitor\\AttributeNodeVisitorTest::testAddsParamPHPDoc":3},"times":{"test\\PhpStaticAnalysis\\NodeVisitor\\AttributeNodeVisitorTest::testDoesNotProcessUnknownNodes":0,"test\\PhpStaticAnalysis\\NodeVisitor\\AttributeNodeVisitorTest::testDoesNotProcessNodesWithoutAttributes":0,"test\\PhpStaticAnalysis\\NodeVisitor\\AttributeNodeVisitorTest::testDoesNotProcessAttributeNotAvailableForStmt":0,"test\\PhpStaticAnalysis\\NodeVisitor\\AttributeNodeVisitorTest::testAddsReadOnlyPHPDoc":0,"test\\PhpStaticAnalysis\\NodeVisitor\\AttributeNodeVisitorTest::testAddsReadOnlyPHPDocMaintainingExistingPHPDoc":0.002,"test\\PhpStaticAnalysis\\NodeVisitor\\AttributeNodeVisitorTest::testAddsReturnPHPDoc":0,"test\\PhpStaticAnalysis\\NodeVisitor\\AttributeNodeVisitorTest::testAddsVarPHPDoc":0,"test\\PhpStaticAnalysis\\NodeVisitor\\AttributeNodeVisitorTest::testAddsTemplatePHPDoc":0,"test\\PhpStaticAnalysis\\NodeVisitor\\AttributeNodeVisitorTest::testAddsTemplateWithTypePHPDoc":0,"test\\PhpStaticAnalysis\\NodeVisitor\\AttributeNodeVisitorTest::testAddsMultipleTemplatePHPDocs":0,"test\\PhpStaticAnalysis\\NodeVisitor\\AttributeNodeVisitorTest::testAddsParamPHPDoc":0,"test\\PhpStaticAnalysis\\NodeVisitor\\AttributeNodeVisitorTest::testAddsSeveralParamPHPDocs":0,"test\\PhpStaticAnalysis\\NodeVisitor\\AttributeNodeVisitorTest::testAddsMultiplePHPDocs":0}}

README.md

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,13 @@
1-
# node-visitor
2-
PHP parser node visitor that converts Attributes into PHPDoc annotations
1+
# PHP Static Analysis Node Visitor
2+
[![Continuous Integration](https://github.com/php-static-analysis/node-visitor/workflows/All%20Tests/badge.svg)](https://github.com/php-static-analysis/node-visitor/actions)
3+
[![Latest Stable Version](https://poser.pugx.org/php-static-analysis/node-visitor/v/stable)](https://packagist.org/packages/php-static-analysis/node-visitor)
4+
[![PHP Version Require](http://poser.pugx.org/php-static-analysis/node-visitor/require/php)](https://packagist.org/packages/php-static-analysis/node-visitor)
5+
[![License](https://poser.pugx.org/php-static-analysis/node-visitor/license)](https://github.com/php-static-analysis/node-visitor/blob/main/LICENSE)
6+
[![Total Downloads](https://poser.pugx.org/php-static-analysis/node-visitor/downloads)](https://packagist.org/packages/php-static-analysis/node-visitor/stats)
7+
8+
PHP class that provides a PHP parser node visitor that converts Attributes into PHPDoc annotations
9+
10+
This class is used by the [PHPStan extension](https://github.com/php-static-analysis/phpstan-extension) and the [Psalm plugin](https://github.com/php-static-analysis/psalm-plugin) for the [PHP static analysis attributes](https://github.com/php-static-analysis/attributes)
11+
12+
13+

composer.json

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"name": "php-static-analysis/node-visitor",
3+
"description": "PHP parser node visitor that converts Attributes into PHPDoc annotations",
4+
"type": "library",
5+
"keywords": ["dev", "static analysis"],
6+
"license": "MIT",
7+
"autoload": {
8+
"psr-4": {
9+
"PhpStaticAnalysis\\NodeVisitor\\": "src/"
10+
}
11+
},
12+
"autoload-dev": {
13+
"psr-4": {
14+
"test\\PhpStaticAnalysis\\NodeVisitor\\": "tests/"
15+
}
16+
},
17+
"authors": [
18+
{
19+
"name": "Carlos Granados",
20+
"email": "[email protected]"
21+
}
22+
],
23+
"minimum-stability": "dev",
24+
"prefer-stable": true,
25+
"require": {
26+
"php": ">=8.0",
27+
"nikic/php-parser": "^4 || ^5",
28+
"php-static-analysis/attributes": "^0.1 || dev-main"
29+
},
30+
"require-dev": {
31+
"php-static-analysis/phpstan-extension": "dev-main",
32+
"php-static-analysis/psalm-plugin": "dev-main",
33+
"phpstan/extension-installer": "^1.3",
34+
"phpstan/phpstan": "^1.8",
35+
"phpunit/phpunit": "^9.0",
36+
"psalm/plugin-phpunit": "^0.18.4",
37+
"symplify/easy-coding-standard": "^12.1",
38+
"vimeo/psalm": "^5"
39+
},
40+
"scripts": {
41+
"phpstan": "phpstan analyse",
42+
"ecs": "ecs",
43+
"ecs-fix": "ecs --fix",
44+
"phpunit": "phpunit",
45+
"psalm": "psalm",
46+
"tests": [
47+
"@ecs",
48+
"@phpstan",
49+
"@phpunit",
50+
"@psalm"
51+
]
52+
},
53+
"config": {
54+
"allow-plugins": {
55+
"phpstan/extension-installer": true
56+
},
57+
"sort-packages": true
58+
}
59+
}

ecs.php

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use PhpCsFixer\Fixer\Import\NoUnusedImportsFixer;
6+
use Symplify\EasyCodingStandard\Config\ECSConfig;
7+
8+
return ECSConfig::configure()
9+
->withPaths([
10+
__DIR__ . '/src',
11+
__DIR__ . '/tests',
12+
])
13+
->withPreparedSets(
14+
psr12: true,
15+
);

phpstan.neon

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
parameters:
2+
level: max
3+
paths:
4+
- src
5+
- tests

phpunit.xml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
4+
bootstrap="vendor/autoload.php"
5+
cacheResultFile=".phpunit.cache/test-results"
6+
executionOrder="depends,defects"
7+
beStrictAboutCoversAnnotation="true"
8+
beStrictAboutOutputDuringTests="true"
9+
beStrictAboutTodoAnnotatedTests="true"
10+
convertDeprecationsToExceptions="true"
11+
failOnRisky="true"
12+
failOnWarning="true"
13+
verbose="true">
14+
<testsuites>
15+
<testsuite name="default">
16+
<directory>tests</directory>
17+
</testsuite>
18+
</testsuites>
19+
</phpunit>

psalm.xml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" ?>
2+
<psalm
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns="https://getpsalm.org/schema/config"
5+
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
6+
7+
errorLevel="1"
8+
findUnusedBaselineEntry="true"
9+
findUnusedCode="false"
10+
>
11+
<projectFiles>
12+
<directory name="src"/>
13+
<directory name="tests"/>
14+
<ignoreFiles>
15+
<directory name="vendor"/>
16+
</ignoreFiles>
17+
</projectFiles>
18+
19+
<plugins>
20+
<pluginClass class="PhpStaticAnalysis\PsalmPlugin\Plugin"/>
21+
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/></plugins>
22+
</psalm>

0 commit comments

Comments
 (0)