Commit Graph

460 Commits

Author SHA1 Message Date
01fe497c49 phpstan: use PHP 8.0 as primary version
I'm using 8.0 for local development now, so having the phpstan configs targeted at 7.4 by default makes things inconvenient.
2021-07-26 14:34:47 +01:00
4abf4aecad MainLogger: fixed potential deadlock during syncFlushBuffer()
the notify() to flush the buffer might arrive in between the writeLogStream() and synchronized() calls in the thread body, resulting in a deadlock if the logger thread managed to call wait() before the main thread did.
2021-03-28 18:10:23 +01:00
2aef83e7d7 MainLogger: fix type ambiguity 2021-02-12 15:05:24 +00:00
7e3e63f342 Fixed race condition in MainLogger shutdown
this resulted in a deadlock in https://github.com/pmmp/PocketMine-MP/runs/1831812620?check_suite_focus=true because the notify() arrived while writeLogStream() was executing.
This ensures that either:
- the notification will occur before the sleep, and therefore no sleeping will occur (this->shutdown = true before the wait)
- the notification will arrive during the sleep.
2021-02-04 16:40:10 +00:00
8ef1e54e20 MainLogger: fixing CPU waste on logger thread
this doesn't need to keep spinning every 25ms; it can just wake up when there's actually log messages to write into the buffer.
2021-02-04 15:07:40 +00:00
eaf3a86981 MainLogger: fixed UB in writeLogStream()
notify() has to be used inside a synchronized block.
2021-02-04 15:03:14 +00:00
16fa958416 phpstan: better hack for any-callable parameters
variadics are a bad fit for this because what we really need is to accept callable with any number of arguments. LSP requires that the provided number of arguments must be >= than the required number of arguments.
2021-01-27 19:25:28 +00:00
34c1d455a7 phpstan: enable checkMissingCallableSignature 2021-01-24 20:27:53 +00:00
97c124edf9 thanks git, this just sneaked in without any questions ................ 2021-01-12 21:43:34 +00:00
0d8858f948 composer.json: sort packages automatically 2021-01-09 17:38:22 +00:00
0604dfc9e5 phpstan 0.12.63 2020-12-18 00:32:55 +00:00
68887105b2 Utils::cleanPath(): drop the square braces
this looks ugly, as well as breaking plugin crash detection (which tbh is too fragile, but it is what it is ...)
2020-12-09 20:26:08 +00:00
104e90b794 CrashDump: more robust core crash detection 2020-12-08 23:27:03 +00:00
8273f789ee Backport SingletonTrait to PM3 2020-11-20 21:00:47 +00:00
9a53de0903 Utils: explode() never returns an empty array 2020-10-24 11:19:37 +01:00
873535f719 Timezone: explicitly check result of getURL()
phpstan-strict-rules should report this, but it doesn't ...
2020-10-09 17:23:22 +01:00
730ee74a65 Use objects for internal structures created in TextFormat::toJSON() (#3747) 2020-08-15 18:30:26 +01:00
df2c3136c9 VersionString: added missing start anchor to regex 2020-08-02 21:10:47 +01:00
75e0844ff5 MainLogger: log stack traces with CRITICAL level
maybe this will get people to send the whole thing instead of just the error message? ...
2020-07-08 10:45:15 +01:00
a34f3261cb event: harden APIs that accept arrays
plugin devs can't be relied on to pass the proper types to these APIs, and when the wrong types get passed it makes type errors appear from inside the internals.
2020-07-04 21:55:23 +01:00
a4e250a3e6 TextFormat: improved exception messages for PCRE failures 2020-06-15 23:43:01 +01:00
23b97d8e2d TextFormat: wrap all preg_replace() usages in a type-safe exception-throwing version
fixes 3 phpstan level 8 errors
2020-06-15 23:31:46 +01:00
d8d994351b phpstan 0.12.29 2020-06-14 16:25:55 +01:00
df13e967fd imports cleanup 2020-06-14 10:27:15 +01:00
76f1add3b3 Timezone: return false if date_parse() fails
I hate this, but I don't want to change it to throw right now because it'll create a bunch of extra work.
2020-06-10 10:34:34 +01:00
ecbf21acea Utils: added OS constants, remove hardcoded OS strings everywhere 2020-05-23 11:05:58 +01:00
73d1f84072 Merge branch 'stable' into next-minor 2020-05-20 19:36:20 +01:00
ff3af492f8 Random: remove multiline formatting in nextSignedInt()
I'm sick to death of formatting tools messing with this...
2020-05-20 14:34:29 +01:00
80b804f7aa automated imports cleanup 2020-05-20 14:31:31 +01:00
dc9351b024 Merge remote-tracking branch 'origin/stable' into next-minor 2020-05-19 11:26:25 +01:00
786f416f2e Improved support for paths with backslashes on Unix filesystems (#3501)
Fixes #3497
2020-05-19 10:34:51 +01:00
9ebd6d6b0f Timezone: remove rogue newline 2020-05-17 14:03:22 +01:00
717b866605 Merge branch 'stable' into next-minor 2020-05-06 20:25:11 +01:00
ef97c8f99e Utils: fix parsing of single-line doc comments, closes #3388 (#3469)
* Utils: fix parsing of single-line doc comments, closes #3388

* correctly handle the empty doc-comment case, add another test case

* ignore an extra phpstan bug
2020-05-06 14:17:08 +01:00
bc985198a0 Config: do not expect string keys on parseProperties(), because of key casting (PHP sucks) 2020-04-15 12:20:23 +01:00
27b2710c56 Config: make phpstan happy for load()
currently this will never be reached if the regular exception handler has been set, but it might not be set if the class is used on its own.
2020-04-15 12:18:22 +01:00
1755b25808 Utils: make explicit assumption about result of scandir() in recursiveUnlink()
TODO: this assumption might be flawed in the case of threading...
2020-04-15 12:13:26 +01:00
a78133d0e3 Utils: provide phpstan type information for testValidInstance() 2020-04-15 12:12:18 +01:00
a51a16a55c Utils: silence PHPStan warning about array_combine() result
phpstan doesn't account for having 2 arrays of the same size, and even if it did, the size cannot be inferred easily here.
2020-04-15 12:11:13 +01:00
099562d582 Utils: assume explicitly that ob_get_contents() will not return false in getReferenceCount() based on context 2020-04-15 12:10:21 +01:00
ae76e8f08f Utils: fix some implicit casts to boolean on result of preg_match_all() 2020-04-15 12:09:10 +01:00
42a08e7e4a Utils: don't assume that callable is only array|string implicitly
this should really support closures too, but since it's not used anywhere, I feel OK with this change.
2020-04-15 12:08:33 +01:00
b193d9f919 Process: shut up PHPStan about possible float returns on getMemoryUsage and friends
this can never actually happen because the given data sources will never have such large numbers, but PHPStan doesn't know this.
2020-04-15 12:07:24 +01:00
24d64eedab Process: make some assumptions about I/O explicit for type safety 2020-04-15 12:05:13 +01:00
0c9d16f1ef Internet: explicitly assume return of curl_exec() is string after error checking
this is documented as string|bool, but it's actually string|false if CURLOPT_RETURNTRANSFER is set, and bool if not.
2020-04-15 12:02:38 +01:00
d246933e3e TextFormat: account for failure to encode JSON in toJSON() 2020-04-15 11:29:50 +01:00
41d7b8c0e4 TextFormat: properly handle pcre errors in some cases
these would previously just hit type errors.
2020-04-15 11:29:04 +01:00
2622c34542 Terminal: explicitly assume that fopen(stdin) will not fail 2020-04-15 11:12:03 +01:00
5c9419b55c Timezone: use false checks instead of file existing for static analysis 2020-04-15 10:59:36 +01:00
83c40f4502 Timezone: properly account for failure to read timezone file 2020-04-15 10:23:07 +01:00