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

PHP 8.2 compatibility + phpstan fixes #944

Merged
merged 143 commits into from
Apr 23, 2024
Merged
Changes from all commits
Commits
Show all changes
143 commits
Select commit Hold shift + click to select a range
552f157
Update deps, CS-fixer rules, run CS-fixer
iansltx May 24, 2023
5cf0ef2
Bump PHP version in CI
iansltx May 24, 2023
84bfa2c
Install Prophecy
iansltx May 24, 2023
17cf6f4
Install Prophecy PHPUnit plugin + add trait to test that uses it
iansltx May 24, 2023
d504984
Remove unneeded-due-to-types test, fix return type on test
iansltx May 24, 2023
3d275c4
Drop Stan baseline file
iansltx May 24, 2023
5f8cff1
Get below 600 static analysis errors
iansltx May 24, 2023
c321be0
Remove redundant assignments
Synchro May 24, 2023
a88c54b
Correct branch name
Synchro May 24, 2023
a4644ee
Avoid complaint about latestVersion by providing annotation, though s…
Synchro May 24, 2023
1297675
Use property promotion, set explicit types
Synchro May 24, 2023
9f12213
Convert deprecated use of FILTER_SANITIZE_STRING to htmlspecialchars
Synchro May 24, 2023
becaa25
Require the config file so that it fails sooner and with a better err…
Synchro May 24, 2023
e8b53b4
Add types for properties, return types, and params
Synchro May 24, 2023
bc8bbe1
Avoid committing config file
Synchro May 24, 2023
f1a7dfe
CS
Synchro May 24, 2023
e8c301d
Use static string for expected
Synchro May 24, 2023
645b326
CS
Synchro May 24, 2023
acc0ce4
CS
Synchro May 24, 2023
7fd73b2
Use property promotion
Synchro May 24, 2023
66c78a9
CS
Synchro May 24, 2023
e6aef8b
More exact handling of result types, removes any ambiguity about retu…
Synchro May 24, 2023
00b9486
Use random_bytes instead of openssl, allow it to throw exceptions ins…
Synchro May 24, 2023
af0818c
Return type
Synchro May 24, 2023
6264e2f
Add param types, fix typo
Synchro May 24, 2023
548b0d8
Add types for properties, return types, and params
Synchro May 24, 2023
f788342
Update deps
Synchro May 24, 2023
610fa71
Update deprecated syntax in phpstan config
Synchro May 24, 2023
d863d08
Merge pull request #1 from Synchro/php82
iansltx May 25, 2023
263e326
Reduce phpstan errors to 550
May 25, 2023
566a278
phpunit fixes
May 25, 2023
f08d5ba
more phpstan updates to 550
May 25, 2023
dbf4e28
Merge pull request #3 from dstockto/php82
iansltx May 25, 2023
193408d
Enforce (nullable) string type for Request's clientIp and userAgent f…
Jean85 May 25, 2023
a351f17
Remove ~80 PHPStan errors
Jean85 May 24, 2023
bbf51ff
Fix PHP-CS-Fixer cache ignore
Jean85 May 25, 2023
8cf448e
Ensure evaluation order on equality after assign in conditional
iansltx May 25, 2023
cbef043
Parens-wrap another assignment inside a conditional
iansltx May 25, 2023
a69ec11
Merge pull request #2 from Jean85/phpstan-fixes
iansltx May 25, 2023
045b170
Add some return types
Synchro May 24, 2023
801b653
Because results['total'] is always set, this condition is always true
Synchro May 25, 2023
31dd50b
Tell it about the type
Synchro May 25, 2023
99380f2
Kind of ugly
Synchro May 25, 2023
368a56c
Param and return types
Synchro May 25, 2023
cc149d8
Handle null possibility
Synchro May 25, 2023
2f733c0
Add return types
Synchro May 25, 2023
6a979e9
Merge pull request #4 from Synchro/php82
iansltx May 25, 2023
cd0d95e
Introduce Request::getStringParameter to solve multiple type issues
Jean85 May 25, 2023
bc982f9
Merge pull request #5 from Jean85/more-phpstan-fixes
iansltx May 25, 2023
a4966f5
PHPStan fixes: 344
May 26, 2023
cfd1c55
Merge pull request #6 from dstockto/php82
iansltx May 26, 2023
91eabfd
Improve types in EventImagesController
herndlm May 27, 2023
349d7bc
Ass a bunch of typehints, force user IDs to ints (they basically were…
iansltx May 27, 2023
7a4b34a
Drop to 300 Stan errors
iansltx May 27, 2023
bfa7ae6
Merge pull request #7 from herndlm/event-images-controller
iansltx May 27, 2023
4991d02
PHPStan fixes: 261
May 29, 2023
a690859
Merge pull request #8 from dstockto/php82
iansltx May 29, 2023
9f33bbe
Simplify random string generation to use random_bytes() now that that…
iansltx May 29, 2023
15ef3ff
Enforce ints
Synchro May 29, 2023
16c2180
CS
Synchro May 29, 2023
9ef1bb6
Doesn't need casting as getUserId returns correct type
Synchro May 29, 2023
9712c90
Same fix as in 15ef3ffe38060867aea0de3ae864e301e2850d91
Synchro May 29, 2023
98d0bd4
Add return type
Synchro May 29, 2023
ab77682
Fix compat with parent
Synchro May 29, 2023
f8e4d45
Annotate type
Synchro May 29, 2023
d78211b
Add return types
Synchro May 29, 2023
1ce428f
Annotate uncertain types
Synchro May 29, 2023
0c6bff3
Set property types
Synchro May 29, 2023
f59d257
Merge pull request #9 from Synchro/php82
iansltx May 29, 2023
e432d43
Remove redundant null checks on controller tests
iansltx May 29, 2023
008d4d3
Clean up OAuthModel
iansltx May 30, 2023
4f9816e
Clean up EventMapper
iansltx May 30, 2023
b22fe9a
Remove unreachable code
Synchro May 30, 2023
871008b
Single quotes
Synchro May 30, 2023
cd19d88
Type param
Synchro May 30, 2023
3d33f76
Pass only ints around for pagination
herndlm May 30, 2023
e5bf6c9
Throw Exception in Request::getItemId instead of returning false
herndlm May 30, 2023
8c481ec
Consistently customize exception message in Request::getItemId
herndlm May 30, 2023
765545e
Improve Header types and remove dead code
herndlm May 30, 2023
cba1ffa
Add more precise PHPDoc to EventCommentMapper
herndlm May 30, 2023
6bb67d2
Fix incorrect PHPDoc type
herndlm May 30, 2023
0338b15
Don't fail tests that don't make assertions, undoes the breakage intr…
Synchro May 30, 2023
fcdbf45
Type properties
Synchro May 30, 2023
a900d6a
Add annotations
Synchro May 30, 2023
9627259
Param types
Synchro May 30, 2023
8ada115
Property types; these *might* need to be nullable, but tests pass
Synchro May 30, 2023
ef8a0f3
Ok, they *do* need to be nullable...
Synchro May 30, 2023
43f6f98
More return types and annotations
Synchro May 30, 2023
bb33d28
Don't assert null on void methods
Synchro May 30, 2023
217738e
Merge pull request #10 from herndlm/request-get-item-id
iansltx May 30, 2023
e3f6208
Merge pull request #11 from herndlm/pagination-int
iansltx May 30, 2023
75e429d
Merge pull request #12 from herndlm/header-types-dead-code
iansltx May 30, 2023
0a4d887
Merge pull request #13 from herndlm/event-comment-mapper
iansltx May 30, 2023
41b72e6
Merge remote-tracking branch 'origin/php82' into php82
Synchro May 30, 2023
adfdedc
Can never be null
Synchro May 30, 2023
eadd871
Allow passing null to event list start for "include first upcoming" b…
iansltx May 30, 2023
f9c5260
Merge pull request #14 from Synchro/php82
iansltx May 30, 2023
eb4cecd
Clean up talk, user mapping a bit, handle track description updates p…
iansltx May 31, 2023
8b2c2a0
Simplify syntax
Synchro May 31, 2023
5a9e72e
Check events were found before trying to use them
Synchro May 31, 2023
180bbfe
Quotes, use strict matching
Synchro May 31, 2023
7dec08c
CS
Synchro May 31, 2023
ae9e76f
Param types
Synchro May 31, 2023
545d536
Remove unused import
Synchro May 31, 2023
741734d
Simpler syntax, check value before use
Synchro May 31, 2023
4e3d9fb
Check value before use
Synchro May 31, 2023
86654f6
Types
Synchro May 31, 2023
8f0c536
Strict check
Synchro May 31, 2023
29716d2
This was only working by luck! Now relies on assoc=null implying JSON…
Synchro May 31, 2023
24317cd
This is an iffy pattern that appears in other places. Should be a bet…
Synchro May 31, 2023
07e86ca
Strict
Synchro May 31, 2023
5a78e35
Quotes
Synchro May 31, 2023
786b183
Param types
Synchro May 31, 2023
b6de41b
This pattern again...
Synchro May 31, 2023
44038d6
preg_match ensures this is all numbers, so cast it to be clear
Synchro May 31, 2023
689da36
Strict
Synchro May 31, 2023
627b295
Check before use
Synchro May 31, 2023
8fad2ce
Return type
Synchro May 31, 2023
60db289
Merge pull request #16 from Synchro/php82
iansltx May 31, 2023
f2f7b82
Specify assoc array for json_decode, as we use assoc later
iansltx May 31, 2023
3b0f965
Clean up event management a bit to drop us to 42 PHPStan errors
iansltx May 31, 2023
d88f70f
Make PHPStan aware that BaseTalkController::checkLoggedIn() narrows t…
herndlm Jun 2, 2023
8ef61f3
Merge pull request #17 from herndlm/base-talk-controller-check-logged-in
iansltx Jun 2, 2023
f86d9b9
PHPStan fixes: 27
May 31, 2023
a5427ea
Set correct response codes, remove unneeded casts
iansltx May 31, 2023
8d9a4a5
PHPStan fixes: 20
Jun 1, 2023
93b0633
Update to correct typed comparison
Jun 2, 2023
90b5c5f
Throw exception when event is not found
Jun 2, 2023
ac73a7b
Throw exception when token cannot be created
Jun 2, 2023
dcfce11
Throw 400 if twitter username is not a string
Jun 2, 2023
2614c9e
Reapply fixes from 008d4d
Jun 3, 2023
3fd374a
Merge pull request #15 from dstockto/php82
iansltx Jun 3, 2023
e06cc65
Make event not found exception more descriptive, remove duplicate exc…
iansltx Jun 3, 2023
4d11752
Skip using temp var for $event
iansltx Jun 3, 2023
4d054a3
Throw rather than returning false for comment get by ID and get info …
iansltx Jun 3, 2023
3975b7b
Clean up OAuthModel
iansltx Jun 3, 2023
1808049
Guard against false return on getUserById, narrow return type on getT…
iansltx Jun 3, 2023
bb9c465
Guard against non-string speaker names in input
iansltx Jun 3, 2023
74eff7f
Fix codestyle
iansltx Jun 3, 2023
8b4788c
Merge branch 'master' into php82
iansltx Jun 3, 2023
edcae14
Fix row handling in EventCommentMapper
herndlm Jun 7, 2023
3675b4f
Merge pull request #18 from herndlm/fix-row-handling-in-event-comment…
iansltx Jun 7, 2023
e23f643
Merge branch 'master' into php82
iansltx Apr 23, 2024
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
8 changes: 4 additions & 4 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ jobs:
strategy:
matrix:
php-version:
- 7.4
- 8.2

steps:
- name: "Checkout"
@@ -49,7 +49,7 @@ jobs:
strategy:
matrix:
php-version:
- 7.4
- 8.2

steps:
- name: "Checkout"
@@ -84,7 +84,7 @@ jobs:
strategy:
matrix:
php-version:
- 7.4
- 8.2

steps:
- name: "Checkout"
@@ -138,7 +138,7 @@ jobs:
# strategy:
# matrix:
# php-version:
# - 7.3
# - 8.2
#
# steps:
# - name: "Checkout"
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -5,10 +5,11 @@
build/
.DS_Store
.vagrant
src/config.php
src/database.php
vendor/.git
.idea
node_modules
vendor
diff.txt
.php_cs.cache
.php-cs-fixer.cache
24 changes: 10 additions & 14 deletions .php_cs → .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -9,9 +9,9 @@
'build',
'db',
])
->name('.php_cs');
->name('.php-cs-fixer');

return PhpCsFixer\Config::create()
return (new PhpCsFixer\Config())
->setFinder($finder)
->setRules([
'@PSR2' => true,
@@ -30,7 +30,6 @@
'continue',
'declare',
'default',
'die',
'do',
'exit',
'for',
@@ -52,7 +51,8 @@
'cast_spaces' => true,
'class_attributes_separation' => [
'elements' => [
'method',
'method' => 'one',
'trait_import' => 'one'
],
],
'combine_consecutive_issets' => true,
@@ -62,10 +62,12 @@
'spacing' => 'one',
],
'declare_equal_normalize' => true,
'final_static_access' => true,
'self_static_accessor' => true,
'fully_qualified_strict_types' => true,
'function_typehint_space' => true,
'hash_to_slash_comment' => true,
'single_line_comment_style' => [
'comment_types' => ['hash']
],
'include' => true,
'increment_style' => [
'style' => 'post',
@@ -76,11 +78,9 @@
'magic_constant_casing' => true,
'magic_method_casing' => true,
'method_argument_space' => [
'ensure_fully_multiline' => true,
'keep_multiple_spaces_after_comma' => false,
],
'method_chaining_indentation' => true,
'method_separation' => false,
'multiline_whitespace_before_semicolons' => [
'strategy' => 'no_multi_line',
],
@@ -105,7 +105,6 @@
'switch',
'throw',
'use',
'use_trait',
],
],
'no_leading_import_slash' => true,
@@ -114,17 +113,14 @@
'use' => 'echo',
],
'no_multiline_whitespace_around_double_arrow' => true,
'no_multiline_whitespace_before_semicolons' => false,
'no_php4_constructor' => false,
'no_short_bool_cast' => true,
'no_short_echo_tag' => true,
'echo_tag_syntax' => ['format' => 'long'],
'no_singleline_whitespace_before_semicolons' => true,
'no_spaces_around_offset' => true,
'no_superfluous_elseif' => true,
'no_trailing_comma_in_list_call' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_trailing_comma_in_singleline' => true,
'no_unneeded_curly_braces' => true,
'no_unneeded_final_method' => true,
'no_unset_cast' => true,
'no_unused_imports' => true,
'no_useless_else' => true,
44 changes: 22 additions & 22 deletions composer.json
Original file line number Diff line number Diff line change
@@ -11,39 +11,38 @@
"homepage": "https://api.joind.in",
"license": "BSD-3-Clause",
"require": {
"php": "^7.3",
"php": "^8.2",
"ext-curl": "*",
"ext-filter": "*",
"ext-gd": "*",
"ext-intl": "*",
"ext-json": "*",
"ext-openssl": "*",
"ext-pdo": "*",
"guzzlehttp/guzzle": "^6.5",
"guzzlehttp/oauth-subscriber": "^0.3.0",
"michelf/php-markdown": "^1.8",
"guzzlehttp/guzzle": "^7.7",
"guzzlehttp/oauth-subscriber": "^0.6",
"michelf/php-markdown": "^2",
"pimple/pimple": "^3.5",
"psr/container": "^1.0.0",
"swiftmailer/swiftmailer": "^6.0",
"teapot/status-code": "^1.1.1"
"psr/container": "^2.0.2",
"swiftmailer/swiftmailer": "^6.3",
"teapot/status-code": "^2.1"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.16.0",
"infection/infection": "^0.18",
"jangregor/phpstan-prophecy": "~0.6.1",
"maglnet/composer-require-checker": "^2.0.0",
"php-mock/php-mock-phpunit": "^2.7",
"phpstan/extension-installer": "^1.0.3",
"phpstan/phpstan": "~0.12.50",
"phpstan/phpstan-phpunit": "~0.12.22",
"phpunit/phpunit": "^9.4.2",
"roave/security-advisories": "dev-master"
"friendsofphp/php-cs-fixer": "^3.17",
"infection/infection": "^0.27",
"jangregor/phpstan-prophecy": "^1",
"maglnet/composer-require-checker": "^4.6",
"php-mock/php-mock-phpunit": "^2.7.1",
"phpspec/prophecy": "^1.17",
"phpspec/prophecy-phpunit": "^2.0",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan": "^1.10.15",
"phpstan/phpstan-phpunit": "1.3.12",
"phpunit/phpunit": "^9.6.8",
"roave/security-advisories": "dev-latest"
},
"config": {
"optimize-autoloader": true,
"platform": {
"php": "7.3.11"
},
"preferred-install": "dist",
"sort-packages": true,
"allow-plugins": {
@@ -75,7 +74,7 @@
"sed -i 's/XDEBUG_PATH_WHITELIST/XDEBUG_PATH_INCLUDE/g' build/xdebug-filter.php",
"phpunit --coverage-clover=build/logs/clover.xml --coverage-text --prepend=build/xdebug-filter.php"
],
"cs": "php-cs-fixer fix --config=.php_cs --diff --diff-format=udiff --verbose",
"cs": "php-cs-fixer fix --diff --verbose",
"infection": "infection --ignore-msi-with-no-mutations --min-covered-msi=71 --min-msi=19",
"require-checker": "composer-require-checker --config-file=composer-require-checker.json",
"security": "security-checker security:check composer.lock",
@@ -90,5 +89,6 @@
"issues": "https://github.com/joindin/joindin-api/issues",
"irc": "irc://freenet/#joindin",
"source": "https://github.com/joindin/joindin-api"
}
},
"type": "project"
}
Loading