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

Add rule to disallow casting potential null values #225

Open
wants to merge 13 commits into
base: 1.5.x
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ tmp export-ignore
.gitattributes export-ignore
.gitignore export-ignore
Makefile export-ignore
phpcs.xml export-ignore
phpstan.neon export-ignore
phpunit.xml export-ignore
5 changes: 0 additions & 5 deletions .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@
"enabled": true,
"groupName": "root-composer"
},
{
"matchPaths": ["build-cs/**"],
"enabled": true,
"groupName": "build-cs"
},
{
"matchPaths": [".github/**"],
"enabled": true,
Expand Down
14 changes: 12 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
- name: "Lint"
run: "make lint"

coding-standards:
coding-standard:
name: "Coding Standard"

runs-on: "ubuntu-latest"
Expand All @@ -55,18 +55,28 @@ jobs:
- name: "Checkout"
uses: actions/checkout@v3

- name: "Checkout build-cs"
uses: actions/checkout@v3
with:
repository: "phpstan/build-cs"
path: "build-cs"

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

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

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

- name: "Install build-cs dependencies"
working-directory: "build-cs"
run: "composer install --no-interaction --no-progress"

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

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/tests/tmp
/build-cs
/vendor
/composer.lock
.phpunit.result.cache
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,19 @@ lint:
php vendor/bin/parallel-lint --colors \
src tests

.PHONY: cs-install
cs-install:
git clone https://github.com/phpstan/build-cs.git || true
git -C build-cs fetch origin && git -C build-cs reset --hard origin/main
composer install --working-dir build-cs

.PHONY: cs
cs:
composer install --working-dir build-cs && php build-cs/vendor/bin/phpcs
php build-cs/vendor/bin/phpcs --standard=build-cs/phpcs.xml src tests

.PHONY: cs-fix
cs-fix:
php build-cs/vendor/bin/phpcbf
php build-cs/vendor/bin/phpcbf --standard=build-cs/phpcs.xml src tests

.PHONY: phpstan
phpstan:
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
* Require calling parent constructor
* Disallow usage of backtick operator (`` $ls = `ls -la` ``)
* Closure should use `$this` directly instead of using `$this` variable indirectly
* Report useless casts
* Disallow explicit casting of potential `null` values (with [https://phpstan.org/blog/what-is-bleeding-edge](bleeding edge) enabled)

Additional rules are coming in subsequent releases!

Expand Down Expand Up @@ -65,6 +67,7 @@ parameters:
disallowedLooseComparison: false
booleansInConditions: false
uselessCast: false
nullCast: false
requireParentConstructorCall: false
disallowedConstructs: false
overwriteVariablesWithLoop: false
Expand Down
1 change: 0 additions & 1 deletion build-cs/.gitignore

This file was deleted.

13 changes: 0 additions & 13 deletions build-cs/composer.json

This file was deleted.

Loading