Skip to content

Commit c206e08

Browse files
authored
Add generic type to the Str utility methods (#62)
Generic will allow the method to infer the type returned based on the argument type. For example: ```php /** @var array<string,string> $arr */ $arr = ['foo' => '']; $val = Str::toSnakeCase($arr); // Type: string. /** @var array<string,non-empty-string> $arr */ $arr = ['foo' => 'bar_123']; $val = Str::toSnakeCase($arr); // Type: non-empty-string. ```
1 parent 8c28930 commit c206e08

File tree

5 files changed

+235
-177
lines changed

5 files changed

+235
-177
lines changed

.devcontainer/devcontainer.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,13 @@
1818
"extensions": [
1919
"bmewburn.vscode-intelephense-client",
2020
"christian-kohler.path-intellisense",
21-
"editorConfig.editorConfig",
21+
"editorconfig.editorconfig",
22+
"kasik96.latte",
23+
"mikestead.dotenv",
2224
"neilbrayfield.php-docblocker",
23-
"SanderRonde.phpstan-vscode",
24-
"wongjn.php-sniffer"
25+
"sanderronde.phpstan-vscode",
26+
"wmaurer.change-case",
27+
"dotjoshjohnson.xml"
2528
]
2629
}
2730
}

.github/workflows/ci.yml

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,29 +26,12 @@ on:
2626
- "phpunit.xml.dist"
2727

2828
jobs:
29-
lint:
30-
runs-on: ubuntu-latest
31-
steps:
32-
- name: Checkout code
33-
uses: actions/checkout@v4
34-
35-
- name: Setup PHP
36-
uses: shivammathur/setup-php@v2
37-
with:
38-
php-version: 7.4
39-
40-
- name: Install dependencies
41-
run: composer install --prefer-dist --no-ansi --no-interaction --no-progress
42-
43-
- name: Run linter
44-
run: composer phpcs
45-
4629
test:
4730
runs-on: ubuntu-latest
4831
strategy:
4932
fail-fast: true
5033
matrix:
51-
version: [7.4, 8.0, 8.1, 8.2, 8.3, 8.4]
34+
version: ["7.4", "8.0", "8.1", "8.2", "8.3", "8.4"]
5235
steps:
5336
- name: Checkout code
5437
uses: actions/checkout@v4
@@ -73,10 +56,15 @@ jobs:
7356
- name: Install dependencies
7457
run: composer update --prefer-dist --no-ansi --no-interaction --no-progress
7558

59+
- name: Run linter
60+
if: ${{ matrix.version == '7.4' }}
61+
run: composer phpcs
62+
63+
- name: Run static analysis
64+
run: composer phpstan
65+
7666
- name: Run test
77-
run: |
78-
composer phpstan
79-
vendor/bin/phpunit --testdox --coverage-clover coverage.xml
67+
run: vendor/bin/phpunit --coverage-clover coverage.xml
8068

8169
- name: Upload coverage to Codecov
8270
uses: codecov/codecov-action@v4

0 commit comments

Comments
 (0)