Skip to content

Commit c170b51

Browse files
Improve Code and add UnnecessaryNamespaceSniff
1 parent e91d1a7 commit c170b51

20 files changed

+524
-230
lines changed

.github/workflows/ci.yml

Lines changed: 60 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -33,70 +33,65 @@ jobs:
3333
- run: diff -Bw <(./bin/normalize.sh Brianvarskonst/ruleset.xml) <(./bin/normalize.sh <(xmllint --format Brianvarskonst/ruleset.xml))
3434
- run: diff -Bw phpcs.Brianvarskonst.xml <(xmllint --format phpcs.Brianvarskonst.xml)
3535
- run: diff -Bw phpcs.xml.dist <(xmllint --format phpcs.xml.dist)
36-
- run: vendor/bin/phpcs -i
3736
- name: Stylecheck against Brianvarskonst itself
3837
run: vendor/bin/phpcs
39-
run-tests:
40-
strategy:
41-
matrix:
42-
os: [ubuntu-latest]
43-
php_version:
44-
- 8.0
45-
- 8.1
46-
- 8.2
47-
- 8.3
48-
dependencies_level:
49-
- --prefer-lowest
50-
- ""
51-
include:
52-
- os: windows-latest
53-
php_version: 8.1
54-
dependencies_level: --prefer-lowest
55-
- os: windows-latest
56-
php_version: 8.1
57-
dependencies_level: ''
58-
runs-on: ${{ matrix.os }}
59-
steps:
60-
- name: Set git to use LF on windows
61-
if: ${{ matrix.os == 'windows-latest' }}
62-
run: |
63-
git config --global core.autocrlf false
64-
git config --global core.eol lf
65-
- name: Check out repository code
66-
uses: actions/checkout@v4
67-
- name: Install PHP
68-
uses: shivammathur/setup-php@v2
69-
with:
70-
coverage: 'xdebug'
71-
php-version: ${{ matrix.php_version }}
72-
extensions: ast-1.1.1
73-
- name: Cache dependencies
74-
uses: actions/cache@v3
75-
with:
76-
path: '~/.cache/composer'
77-
key: "cache-composer-${{ hashFiles('composer.json') }}"
78-
restore-keys: 'cache-composer-'
79-
- name: Run composer
80-
run: composer update ${{ matrix.dependencies_level }} --prefer-dist --no-interaction --no-progress
81-
- name: Check composer.json
82-
run: composer normalize --dry-run
83-
- name: Run tests with coverage
84-
if: ${{ matrix.os != 'windows-latest' && matrix.php_version == '8.1' && matrix.dependencies_level != '--prefer-lowest' }}
85-
run: php vendor/bin/phpunit --coverage-clover=coverage.xml
86-
- name: Run tests
87-
run: vendor/bin/phpunit
88-
- name: Run integration tests
89-
run: vendor/bin/phpcs -s --standard=Brianvarskonst integrationtests/testfile.php
90-
- name: Run PHPStan
91-
run: vendor/bin/phpstan analyse --no-progress
92-
- name: Run phan
93-
if: ${{ matrix.os != 'windows-latest' }}
94-
run: vendor/bin/phan
95-
# AST 1.1 binary for Windows seems to be missing on PECL
96-
- name: Run phan with polyfill
97-
if: ${{ matrix.os == 'windows-latest' }}
98-
run: vendor/bin/phan --allow-polyfill-parser
99-
- name: Upload coverage to Codecov
100-
uses: codecov/codecov-action@v3
101-
with:
102-
verbose: true
38+
# run-tests:
39+
# strategy:
40+
# matrix:
41+
# os: [ubuntu-latest]
42+
# php_version:
43+
# - 8.0
44+
# - 8.1
45+
# - 8.2
46+
# - 8.3
47+
# dependencies_level:
48+
# - --prefer-lowest
49+
# - ""
50+
# include:
51+
# - os: windows-latest
52+
# php_version: 8.1
53+
# dependencies_level: --prefer-lowest
54+
# - os: windows-latest
55+
# php_version: 8.1
56+
# dependencies_level: ''
57+
# runs-on: ${{ matrix.os }}
58+
# steps:
59+
# - name: Set git to use LF on windows
60+
# if: ${{ matrix.os == 'windows-latest' }}
61+
# run: |
62+
# git config --global core.autocrlf false
63+
# git config --global core.eol lf
64+
# - name: Check out repository code
65+
# uses: actions/checkout@v4
66+
# - name: Install PHP
67+
# uses: shivammathur/setup-php@v2
68+
# with:
69+
# coverage: 'xdebug'
70+
# php-version: ${{ matrix.php_version }}
71+
# extensions: ast-1.1.1
72+
# - name: Cache dependencies
73+
# uses: actions/cache@v3
74+
# with:
75+
# path: '~/.cache/composer'
76+
# key: "cache-composer-${{ hashFiles('composer.json') }}"
77+
# restore-keys: 'cache-composer-'
78+
# - name: Run composer
79+
# run: composer update ${{ matrix.dependencies_level }} --prefer-dist --no-interaction --no-progress
80+
# - name: Check composer.json
81+
# run: composer normalize --dry-run
82+
# - name: Run tests with coverage
83+
# if: ${{ matrix.os != 'windows-latest' && matrix.php_version == '8.1' && matrix.dependencies_level != '--prefer-lowest' }}
84+
# run: php vendor/bin/phpunit --coverage-clover=coverage.xml
85+
# - name: Run tests
86+
# run: vendor/bin/phpunit
87+
# - name: Run integration tests
88+
# run: vendor/bin/phpcs -s --standard=Brianvarskonst integrationtests/testfile.php
89+
# - name: Run PHPStan
90+
# run: vendor/bin/phpstan analyse --no-progress
91+
# - name: Run phan
92+
# if: ${{ matrix.os != 'windows-latest' }}
93+
# run: vendor/bin/phan
94+
# # AST 1.1 binary for Windows seems to be missing on PECL
95+
# - name: Run phan with polyfill
96+
# if: ${{ matrix.os == 'windows-latest' }}
97+
# run: vendor/bin/phan --allow-polyfill-parser

Brianvarskonst/Helper/Boundaries.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace Brianvarskonst\CodingStandard\Helper;
66

77
use PHPCSUtils\Tokens\Collections;
8-
use PHPCSUtils\Utils\Arrays;
98
use PHP_CodeSniffer\Files\File;
109
use PHP_CodeSniffer\Util\Tokens;
1110

@@ -42,21 +41,6 @@ public static function objectBoundaries(File $file, int $position): array
4241
return self::startEnd($file, $position);
4342
}
4443

45-
/** @return list{int, int} */
46-
public static function arrayBoundaries(File $file, int $position): array
47-
{
48-
$openClose = Arrays::getOpenClose($file, $position);
49-
50-
if (!\is_array($openClose)
51-
|| !\is_int($openClose['opener'] ?? null)
52-
|| !\is_int($openClose['closer'] ?? null)
53-
) {
54-
return [-1, -1];
55-
}
56-
57-
return [(int) $openClose['opener'], (int) $openClose['closer']];
58-
}
59-
6044
/** @return list{int, int} */
6145
private static function startEnd(File $file, int $position): array
6246
{

Brianvarskonst/Helper/Misc.php

Lines changed: 0 additions & 88 deletions
This file was deleted.

Brianvarskonst/Sniffs/Array/ArrayDoubleArrowAlignmentSniff.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ class ArrayDoubleArrowAlignmentSniff implements Sniff
1717
{
1818
/**
1919
* Define all types of arrays.
20+
*
21+
* @var array<int, int|string> $arrayTokens
2022
*/
2123
protected array $arrayTokens = [
2224
// @phan-suppress-next-line PhanUndeclaredConstant
@@ -27,7 +29,7 @@ class ArrayDoubleArrowAlignmentSniff implements Sniff
2729
/**
2830
* Registers the tokens that this sniff wants to listen for.
2931
*
30-
* @return array<int, int>
32+
* @return array<int, int|string>
3133
*/
3234
public function register(): array
3335
{

Brianvarskonst/Sniffs/Array/MultiLineArraySniff.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,18 @@
1010
/** Multi Line Array sniff */
1111
class MultiLineArraySniff implements Sniff
1212
{
13-
/** Define all types of arrays */
14-
protected array $arrayTokens = [
15-
// @phan-suppress-next-line PhanUndeclaredConstant
16-
T_OPEN_SHORT_ARRAY,
17-
T_ARRAY,
18-
];
19-
2013
/**
2114
* Registers the tokens that this sniff wants to listen for.
2215
*
23-
* @return array<int, int>
16+
* @return array<int, int|string>
2417
*/
2518
public function register(): array
2619
{
27-
return $this->arrayTokens;
20+
return [
21+
// @phan-suppress-next-line PhanUndeclaredConstant
22+
T_OPEN_SHORT_ARRAY,
23+
T_ARRAY,
24+
];
2825
}
2926

3027
/**

Brianvarskonst/Sniffs/Formatting/AlphabeticalUseStatementsSniff.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace Brianvarskonst\Sniffs\Formatting;
5+
namespace Formatting;
66

77
use PHP_CodeSniffer\Files\File;
88
use PHP_CodeSniffer\Standards\PSR2\Sniffs\Namespaces\UseDeclarationSniff;
@@ -125,7 +125,11 @@ public function process(File $phpcsFile, $stackPtr): void
125125
$this->lastLine = $line;
126126
}
127127

128-
/** Get the import class name for use statement pointed by $stackPtr. */
128+
/**
129+
* Get the import class name for use statement pointed by $stackPtr.
130+
*
131+
* @return false|array{startPtr: int, content: string}
132+
*/
129133
private function getUseImport(File $phpcsFile, int $stackPtr): false|array
130134
{
131135
$importTokens = [

0 commit comments

Comments
 (0)