Skip to content

Commit

Permalink
Initial implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
swissspidy committed May 13, 2023
1 parent 9421e08 commit df4f4e5
Show file tree
Hide file tree
Showing 34 changed files with 1,388 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
trim_trailing_whitespace = true

[*.{php,phpt}]
indent_style = tab
indent_size = 4

[*.xml]
indent_style = tab
indent_size = 4

[*.neon]
indent_style = tab
indent_size = 4

[*.{yaml,yml}]
indent_style = space
indent_size = 2

[composer.json]
indent_style = tab
indent_size = 4
11 changes: 11 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
*.php text eol=lf

.github export-ignore
tests export-ignore
tmp export-ignore
.gitattributes export-ignore
.gitignore export-ignore
Makefile export-ignore
phpcs.xml export-ignore
phpstan.neon export-ignore
phpunit.xml export-ignore
18 changes: 18 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: github-actions
directory: '/'
schedule:
interval: weekly
open-pull-requests-limit: 10

- package-ecosystem: composer
directory: '/'
schedule:
interval: weekly
open-pull-requests-limit: 10
162 changes: 162 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions

name: "Build"

on:
pull_request:
push:
branches:
- "1.1.x"

jobs:
lint:
name: "Lint"
runs-on: "ubuntu-latest"

strategy:
matrix:
php-version:
- "7.2"
- "7.3"
- "7.4"
- "8.0"
- "8.1"
- "8.2"

steps:
- name: "Checkout"
uses: actions/checkout@v3

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"

- name: "Validate Composer"
run: "composer validate"

- name: "Install dependencies"
run: "composer install --no-interaction --no-progress"

- name: "Downgrade PHPUnit"
if: matrix.php-version == '7.2' || matrix.php-version == '7.3'
run: "composer require --dev phpunit/phpunit:^7.5.20 --update-with-dependencies"

- name: "Lint"
run: "make lint"

coding-standards:
name: "Coding Standard"

runs-on: "ubuntu-latest"

steps:
- name: "Checkout"
uses: actions/checkout@v3

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "8.0"

- name: "Validate Composer"
run: "composer validate"

- name: "Install dependencies"
run: "composer install --no-interaction --no-progress"

- name: "Lint"
run: "make lint"

- name: "Coding Standard"
run: "make cs"

tests:
name: "Tests"
runs-on: "ubuntu-latest"

strategy:
fail-fast: false
matrix:
php-version:
- "7.2"
- "7.3"
- "7.4"
- "8.0"
- "8.1"
- "8.2"
dependencies:
- "lowest"
- "highest"

steps:
- name: "Checkout"
uses: actions/checkout@v3

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"

- name: "Install lowest dependencies"
if: ${{ matrix.dependencies == 'lowest' }}
run: "composer update --prefer-lowest --no-interaction --no-progress"

- name: "Install highest dependencies"
if: ${{ matrix.dependencies == 'highest' }}
run: "composer update --no-interaction --no-progress"

- name: "Downgrade PHPUnit"
if: matrix.php-version == '7.2' || matrix.php-version == '7.3'
run: "composer require --dev phpunit/phpunit:^7.5.20 --update-with-dependencies"

- name: "Tests"
run: "make tests"

static-analysis:
name: "PHPStan"
runs-on: "ubuntu-latest"

strategy:
fail-fast: false
matrix:
php-version:
- "7.2"
- "7.3"
- "7.4"
- "8.0"
- "8.1"
- "8.2"
dependencies:
- "lowest"
- "highest"

steps:
- name: "Checkout"
uses: actions/checkout@v3

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
extensions: mbstring
tools: composer:v2

- name: "Install lowest dependencies"
if: ${{ matrix.dependencies == 'lowest' }}
run: "composer update --prefer-lowest --no-interaction --no-progress"

- name: "Install highest dependencies"
if: ${{ matrix.dependencies == 'highest' }}
run: "composer update --no-interaction --no-progress"

- name: "Downgrade PHPUnit"
if: matrix.php-version == '7.2' || matrix.php-version == '7.3'
run: "composer require --dev phpunit/phpunit:^7.5.20 --update-with-dependencies"

- name: "PHPStan"
run: "make phpstan"
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/tests/tmp
/vendor
/composer.lock
.phpunit.result.cache
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Rules for detecting usage of pseudo-private functions, classes, and methods.

[![Build](https://github.com/swissspidy/phpstan-no-private/workflows/Build/badge.svg)](https://github.com/swissspidy/phpstan-no-private/actions)
[![Latest Stable Version](https://poser.pugx.org/swissspidy/phpstan-no-private/v/stable)](https://packagist.org/packages/swissspidy/phpstan-no-private)
[![License](https://poser.pugx.org/swissspidy/phpstan-no-private/license)](https://packagist.org/packages/swissspidy/phpstan-no-private)

This extension emits deprecation warnings on code which uses properties/functions/methods/classes which are annotated as `@access private`.

## Installation

To use this extension, require it in [Composer](https://getcomposer.org/):

```
composer require --dev swissspidy/phpstan-no-private
```

If you also install [phpstan/extension-installer](https://github.com/phpstan/extension-installer) then you're all set!

<details>
<summary>Manual installation</summary>

If you don't want to use `phpstan/extension-installer`, include rules.neon in your project's PHPStan config:

```
includes:
- vendor/swissspidy/phpstan-no-private/rules.neon
```
</details>

## Credits

This project is a fork of the excellent [phpstan/phpstan-deprecation-rules](https://github.com/phpstan/phpstan-deprecation-rules),
which provides rules that detect usage of deprecated classes, methods, properties, constants and traits.
55 changes: 55 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"name": "swissspidy/phpstan-no-private",
"type": "phpstan-extension",
"description": "PHPStan rules for detecting usage of pseudo-private functions, classes, and methods.",
"license": [
"MIT"
],
"require": {
"php": "^7.2 || ^8.0",
"phpstan/phpstan": "^1.10.3"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^1.0.0",
"php-parallel-lint/php-parallel-lint": "^1.2",
"phpstan/phpstan-phpunit": "^1.0",
"phpstan/phpstan-php-parser": "^1.1",
"phpunit/phpunit": "^9.5",
"slevomat/coding-standard": "^8.8.0",
"squizlabs/php_codesniffer": "^3.5.3"
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
},
"platform": {
"php": "7.4.6"
},
"sort-packages": true
},
"extra": {
"phpstan": {
"includes": [
"rules.neon"
]
}
},
"autoload": {
"psr-4": {
"Swissspidy\\PHPStan\\": "src/"
}
},
"autoload-dev": {
"classmap": [
"tests/"
]
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"lint": "vendor/bin/phpcs",
"lint:fix": "vendor/bin/phpcbf",
"phpstan": "vendor/bin/phpstan analyse -l 8 -c phpstan.neon src tests",
"test": "vendor/bin/phpunit"
}
}
Loading

0 comments on commit df4f4e5

Please sign in to comment.