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

PSR-12 and PHPCS #2420

Merged
merged 90 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
d5bbd89
updated composer; added shortcut commands
niden Nov 27, 2023
f686a01
switching to psr-12
niden Nov 27, 2023
580ea0f
a lot of phpcs fixes
niden Nov 27, 2023
d066605
fixing the fixer
niden Nov 27, 2023
86e4908
correcting var for symbol table
niden Nov 27, 2023
448dfda
adding public to prototype constants
niden Nov 27, 2023
c6c89d0
fixing imports
niden Nov 27, 2023
8cddbbd
fixing imports phpcs
niden Nov 27, 2023
46cece9
disabling phpfixer
niden Nov 27, 2023
5f75f38
fixing typo
niden Nov 27, 2023
08b83b7
refactoring require/require_once operators - duplicate code
niden Nov 28, 2023
62362b7
refactoring likely/unlikely
niden Nov 28, 2023
631c868
refactoring and reusing code
niden Nov 28, 2023
332d48c
refactoring and removing duplicate code
niden Nov 28, 2023
4f10143
removed more duplicate code
niden Nov 28, 2023
3fe2426
removing duplications; reverting operand checks
niden Nov 28, 2023
55f35ff
phpcs
niden Nov 28, 2023
85fce61
reverting back to get the tests to run
niden Nov 28, 2023
b863c42
removing duplicate code from require and inc/decr
niden Nov 28, 2023
d8aa93c
added variables trait; refactored code for return value exception check
niden Nov 28, 2023
f90689b
refactored checks for local, read only and initialized vars
niden Nov 29, 2023
e30313a
correcting call_user_func* optimizers
niden Nov 29, 2023
a6e8de5
phpcs
niden Nov 29, 2023
405c49b
additional refactoring for checking expression elements
niden Nov 29, 2023
35fa921
removing duplicate code; refactoring
niden Nov 29, 2023
c95ba81
correcting import
niden Nov 29, 2023
af7fc4c
a lot of code smells and optimizations
niden Nov 29, 2023
34614d2
Revert "a lot of code smells and optimizations"
niden Nov 29, 2023
14850b8
refactored some exceptions and remove duplicate code
niden Nov 29, 2023
2f15332
removed duplicate code from and/or operators
niden Nov 29, 2023
680780a
adding qodana setup
niden Nov 30, 2023
130981a
correcting qodana action
niden Nov 30, 2023
b5bcdab
adding baseline file
niden Nov 30, 2023
116b5ef
removed duplicate code
niden Nov 30, 2023
a69f5e4
excluding various folders
niden Nov 30, 2023
0968d2d
removing unreachable statements
niden Nov 30, 2023
fe2a712
minor correction
niden Nov 30, 2023
a50fb0f
correcting typo
niden Nov 30, 2023
add6ae6
phpcs
niden Nov 30, 2023
7f46f5e
more phpcs
niden Nov 30, 2023
68a9b2b
removing psr2 reference
niden Nov 30, 2023
cf3ab03
fixing phpcs
niden Nov 30, 2023
0a5d378
correcting workflow; removing duplication
niden Nov 30, 2023
b9a5bde
reverting
niden Nov 30, 2023
0c0a4d6
updating baseline file
niden Nov 30, 2023
dabafe1
trying a different config for qodana
niden Nov 30, 2023
1ccda61
trying a different workflow for qodana
niden Nov 30, 2023
b5a2e00
correcting yml file
niden Nov 30, 2023
7d05477
minor change
niden Dec 1, 2023
e76ef08
trying to fix qodana
niden Dec 1, 2023
ab6fa2e
changing qodana to php 8.1
niden Dec 1, 2023
558458e
different ci structure
niden Dec 1, 2023
1ea0cc9
trying to get the coverage working
niden Dec 1, 2023
3937a65
removed duplicates; corrected docblocks
niden Dec 1, 2023
4d9ddf8
phpcs
niden Dec 1, 2023
446f47b
adding a scan step
niden Dec 1, 2023
b828019
removed duplications
niden Dec 1, 2023
063de9a
correcting symbol call
niden Dec 1, 2023
abd0cdb
removed more duplications
niden Dec 1, 2023
428731c
Revert "removed more duplications"
niden Dec 1, 2023
062952b
Revert "correcting symbol call"
niden Dec 1, 2023
06ff544
Revert "removed duplications"
niden Dec 1, 2023
c664883
removing duplications
niden Dec 1, 2023
c447b11
removing more duplications
niden Dec 1, 2023
db5c742
removing duplications from compiler files
niden Dec 1, 2023
1ab880c
Revert "removing duplications from compiler files"
niden Dec 1, 2023
72c3c8b
Revert "removing more duplications"
niden Dec 1, 2023
888a428
removing more duplications
niden Dec 1, 2023
8ac5c54
Revert "removing more duplications"
niden Dec 1, 2023
1bb179f
remove duplications from compiler
niden Dec 1, 2023
ddf5a04
removing duplications from string optimizers
niden Dec 1, 2023
d4bc89a
array, getclass - removing duplications
niden Dec 1, 2023
3913922
trim, camelize and crc32 optimizers - removing duplicates
niden Dec 2, 2023
7f91722
Revert "trim, camelize and crc32 optimizers - removing duplicates"
niden Dec 2, 2023
177db8f
Revert "array, getclass - removing duplications"
niden Dec 2, 2023
2b06db7
camelize/trim/crc32 duplication
niden Dec 2, 2023
af59b78
removing dupes from inarray
niden Dec 2, 2023
470adf7
more optimizations; removing duplicate code
niden Dec 2, 2023
54f9cb0
duplicates from array* optimizers
niden Dec 2, 2023
c02f094
static property - let - duplicate code
niden Dec 2, 2023
8a35d4a
removed duplicate block
niden Dec 2, 2023
e5d88ea
reformatting on exception
niden Dec 3, 2023
df3d9e9
phpcs
niden Dec 3, 2023
94e9506
removing duplicates json/functions
niden Dec 3, 2023
6a81b9c
Revert "removing duplicates json/functions"
niden Dec 3, 2023
8c2ed6e
Revert "phpcs"
niden Dec 3, 2023
d82d33e
phpcs again
niden Dec 3, 2023
7e91f3b
removing more duplicated code
niden Dec 4, 2023
8e6d330
more duplications
niden Dec 4, 2023
5b8de90
Merge branch 'development' into phpcs-changes
Jeckerson Dec 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions .docker/8.0/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ RUN apt update -y && apt install -y \
libicu-dev \
libgmp-dev \
libzip-dev && \
pecl install psr zephir_parser
pecl install psr xdebug zephir_parser

RUN docker-php-ext-install zip gmp intl mysqli && \
docker-php-ext-enable psr zephir_parser
docker-php-ext-enable psr zephir_parser xdebug

COPY --from=composer /usr/bin/composer /usr/local/bin/composer
# Bash script with helper aliases
Expand Down
4 changes: 2 additions & 2 deletions .docker/8.1/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ RUN apt update -y && apt install -y \
libicu-dev \
libgmp-dev \
libzip-dev && \
pecl install psr zephir_parser
pecl install psr xdebug zephir_parser

RUN docker-php-ext-install zip gmp intl mysqli && \
docker-php-ext-enable psr zephir_parser
docker-php-ext-enable psr zephir_parser xdebug

COPY --from=composer /usr/bin/composer /usr/local/bin/composer
# Bash script with helper aliases
Expand Down
4 changes: 2 additions & 2 deletions .docker/8.2/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ RUN apt update -y && apt install -y \
libicu-dev \
libgmp-dev \
libzip-dev && \
pecl install psr zephir_parser
pecl install psr xdebug zephir_parser

RUN docker-php-ext-install zip gmp intl mysqli && \
docker-php-ext-enable psr zephir_parser
docker-php-ext-enable psr zephir_parser xdebug

COPY --from=composer /usr/bin/composer /usr/local/bin/composer
# Bash script with helper aliases
Expand Down
2 changes: 2 additions & 0 deletions .docker/8.3/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ RUN apt update -y && apt install -y \
libgmp-dev \
libzip-dev && \
pecl install psr zephir_parser
# pecl install psr zephir_parser xdebug

RUN docker-php-ext-install zip gmp intl mysqli && \
docker-php-ext-enable psr zephir_parser
# docker-php-ext-enable psr zephir_parser xdebug

COPY --from=composer /usr/bin/composer /usr/local/bin/composer
# Bash script with helper aliases
Expand Down
71 changes: 62 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ jobs:
phpcs --version
phpcs --runtime-set ignore_warnings_on_exit true

- name: Run PHP CS Fixer
if: always()
run: |
php-cs-fixer fix --diff --dry-run -v --using-cache=no
# Disabling for now until I figure out the rules
# - name: Run PHP CS Fixer
# if: always()
# run: |
# php-cs-fixer fix --diff --dry-run -v --using-cache=no

- name: Run Shell Check
if: always()
Expand Down Expand Up @@ -175,28 +176,80 @@ jobs:
shell: pwsh
run: |
php vendor/bin/phpunit -c phpunit.ext.xml
env:
XDEBUG_MODE: coverage

- name: Unit Tests (Zephir)
if: always()
run: php vendor/bin/phpunit --testsuite Zephir
run: php vendor/bin/phpunit --testsuite Zephir --coverage-php ./tests/output/clover.xml
env:
XDEBUG_MODE: coverage

- name: "Upload coverage file artifact"
uses: "actions/upload-artifact@v3"
with:
name: "unit-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.name }}.coverage"
path: "tests/output/clover.xml"

- name: Black-box Testing
if: always() && runner.os != 'Windows'
shell: bash
working-directory: tests/sharness
run: |
make -j$(getconf _NPROCESSORS_ONLN)

- name: Upload Code Coverage Report
uses: codecov/codecov-action@v3
upload-coverage:
permissions:
contents: read

name: "Upload coverage"
runs-on: "ubuntu-22.04"
needs:
- "build-and-test"

steps:
- name: "Checkout"
uses: "actions/checkout@v3"
with:
fetch-depth: 2

- name: 'Qodana Scan'
uses: JetBrains/qodana-action@v2023.2
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
with:
args: --baseline,qodana.sarif.json

- name: "Create download folder"
run: |
mkdir -p reports

- name: "Download coverage files"
uses: "actions/download-artifact@v3"
with:
path: "reports"

- name: "Display structure of downloaded files"
run: ls -R
working-directory: reports

- name: "Upload to Codecov"
uses: "codecov/codecov-action@v3"
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./tests/output/clover.xml
flags: unittests,${{ runner.os }},php-${{ matrix.php }}
directory: reports
fail_ci_if_error: true
verbose: true
name: codecov-umbrella

- name: "Upload to Qodana"
run: |
docker run \
-v $(pwd):/data/project/ \
-v ./reports/:/data/coverage \
-e QODANA_TOKEN="${{ secrets.QODANA_TOKEN }}" \
jetbrains/qodana-php

- name: Upload build artifacts after Failure
if: failure()
uses: actions/upload-artifact@v2
Expand Down
2 changes: 1 addition & 1 deletion .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
'@Symfony' => true,
'@Symfony:risky' => true,
'@PHPUnit48Migration:risky' => true,
'@PSR2' => true,
'@PSR12' => true,
'php_unit_no_expectation_annotation' => false,
'array_syntax' => ['syntax' => 'short'],
'fopen_flags' => false,
Expand Down
19 changes: 17 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
"ext-pdo_sqlite": "*",
"ext-zip": "*",
"phpunit/phpunit": "9.5.28",
"psr/log": "1.1.*"
"psr/log": "1.1.*",
"squizlabs/php_codesniffer": "^3.7"
},
"config": {
"optimize-autoloader": true,
Expand Down Expand Up @@ -71,5 +72,19 @@
"source": "https://github.com/zephir-lang/zephir",
"irc": "irc://irc.freenode.net/zephir",
"docs": "https://docs.zephir-lang.com"
}
},
"scripts": {
"cs": "./vendor/bin/phpcs --standard=phpcs.xml.dist",
"cs-fix": "./vendor/bin/phpcbf --standard=phpcs.xml.dist",
"test": "./vendor/bin/phpunit --testsuite Zephir",
"test-coverage": "./vendor/bin/phpunit --testsuite Zephir --coverage-php ./tests/output/coverage/coverage.xml",
"test-coverage-html": "./vendor/bin/phpunit --testsuite Zephir --coverage-html ./tests/output/coverage"
},
"scripts-descriptions": {
"cs": "Run PHPCS",
"cs-fix": "Run PHPCBF",
"test": "Run all tests",
"test-coverage": "Run all tests with coverage (clover)",
"test-coverage-html": "Run all tests with coverage (HTML)"
}
}
7 changes: 4 additions & 3 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,19 @@
<!-- Show sniff codes in all reports -->
<arg value="s"/>

<!-- Use PSR-2 as a base -->
<rule ref="PSR2"/>
<!-- Use PSR-12 as a base -->
<rule ref="PSR12"/>

<!-- Uncomment to use colors in progress or report -->
<arg name="colors" />

<!-- Show progress of the run -->
<arg value="p"/>

<rule ref="PSR2">
<rule ref="PSR12">
<exclude name="Generic.Files.LineLength.TooLong"/>
<exclude name="PSR2.Methods.MethodDeclaration.Underscore"/>
<exclude name="PSR2.Classes.PropertyDeclaration.SpacingAfterType"/>
</rule>

<!--
Expand Down
Loading
Loading