Commit Graph

316 Commits

Author SHA1 Message Date
Dylan K. Taylor
aa9f8781ff Merge branch 'next-minor' into next-major 2022-06-07 19:56:26 +01:00
Dylan K. Taylor
083a35f970 Modernize property type declarations 2022-06-04 18:16:32 +01:00
Dylan K. Taylor
38d6284671 Use PHP-CS-Fixer to enforce file header presence 2022-06-04 17:34:49 +01:00
Dylan K. Taylor
df3a69dcb7 Modernize private property declarations in Threaded classes
I previously avoided this due to being unsure of the effects; however, it's clear that we already use typed properties on Threaded things in other places anyway, and the only known issues are with uninit properties, and arrays.
2022-05-17 22:42:18 +01:00
Dylan K. Taylor
d4b7f66e15 Promote some constructors 2022-05-17 22:34:58 +01:00
Dylan K. Taylor
9ff1bf6deb Merge remote-tracking branch 'origin/stable' into next-minor 2022-05-11 13:12:45 +01:00
Dylan K. Taylor
a913736235 fix CS 2022-05-10 14:13:01 +01:00
Dylan K. Taylor
124edeacaf fix build 2022-05-10 14:11:46 +01:00
Dylan K. Taylor
a216f4d089 Utils: improve representation of int, float and null in stack trace parameters 2022-05-10 14:07:07 +01:00
Dylan K. Taylor
17b0e0be84 Utils: use match to clean up stringifyValueForTrace() 2022-05-10 14:04:52 +01:00
Dylan K. Taylor
81d8aed2e2 Utils: account for named variadic arguments in printableTrace() 2022-05-10 13:59:42 +01:00
Dylan K. Taylor
6d7bf1c5d8 Utils: fixed missing property initializer 2022-04-28 14:52:21 +01:00
Dylan K. Taylor
0e7e776862 Modernize property declarations in src/utils 2022-04-28 13:12:12 +01:00
Dylan K. Taylor
8cc7fb9dd9 fix CS 2022-03-28 17:16:35 +01:00
Dylan K. Taylor
194cb1fb84 phpstan 1.5.1 2022-03-28 17:12:00 +01:00
Dylan K. Taylor
4a94cb85a2 fix CS 2022-03-22 15:44:11 +00:00
Dylan K. Taylor
b7e6854189 RegistryTrait: enforce name validation rules on everything, not just enums
fixes #4916
2022-03-22 15:41:17 +00:00
PJZ9n
f4f5c3128f EnumTrait: fixed regex not accepting member names with 1 character
this also fixes EnumTrait accepting invalid non-numeric characters for the first character, such as @.
2022-03-19 16:47:36 +00:00
Dylan K. Taylor
f97ce6afef Harden APIs which accept Vector3/Position/Location in event namespace 2022-03-09 22:22:37 +00:00
EndermanbugZJFC
f181c60209 Fixed typo (occured => occurred) (#4873)
[ci skip]
2022-03-02 16:28:02 +00:00
Dylan K. Taylor
282b430b1f Replace disallowed operators in src/utils/ 2022-01-20 19:02:26 +00:00
Dylan K. Taylor
ee6548aa50 Merge branch 'stable' into next-minor 2022-01-14 00:45:49 +00:00
Dylan K. Taylor
a5c0958adf Filesystem::safeFilePutContents() now consistently throws RuntimeException in all expected failure cases
unexpected cases may still throw ErrorException (such as undefined variables) but we don't want to capture those.
2022-01-09 16:33:31 +00:00
Dylan K. Taylor
fd880d8465 Filesystem: Use ErrorToExceptionHandler to improve error output 2022-01-09 16:26:42 +00:00
Dylan K. Taylor
0a5b146189 substr() returns an empty string instead of false in 8.0
an empty string will pass through preg_match_all() without any harmful effects, so we don't need to check for it.
2022-01-07 22:38:00 +00:00
Dylan K. Taylor
661848c5e7 fix more EOF newlines 2022-01-07 20:39:43 +00:00
Dylan K. Taylor
75fc7a2d1f Merge branch 'stable' into next-minor 2022-01-07 20:16:35 +00:00
Dylan K. Taylor
6d249026cc Merge branch 'legacy/pm3' into stable 2022-01-07 20:15:15 +00:00
Dylan K. Taylor
4f8a0bad25 RegistryTrait: avoid overwriting parameter variables 2022-01-06 23:54:54 +00:00
Dylan K. Taylor
e04dfe96af Merge branch 'stable' into next-minor 2022-01-01 17:55:17 +00:00
xxAROX
193a1b3f4e TextFormat: Added MINECOIN_GOLD (§g) color code support (#4670) 2021-12-30 23:53:05 +00:00
Dylan K. Taylor
38b6b39cb3 Filesystem: workaround a stupid Windows issue in safeFilePutContents()
occasionally Windows will randomly decide to deny us access to rename the file for no reason whatsoever. If this happens, we attempt an old-style copy and delete.
If the rename failed for a legit reason, the copy and delete should also fail and generate an error message. If it was Windows being a spaz, it should work normally without errors.
2021-12-29 15:26:34 +00:00
Dylan K. Taylor
65dabefa3b Config: improve config loading and parsing error handling
closes #4654
closes #3454
2021-12-19 16:53:29 +00:00
Dylan K. Taylor
482bc462d3 VersionString: Use multiplication instead of bitshift for version IDs
this makes them more recognizable, and also fixes #4630.

This is technically a BC break (behavioural change), but since nothing appears to use this functionality anyway except PM itself, I don't think it matters.
2021-12-15 14:32:50 +00:00
Dylan K. Taylor
60938c8c9d Random: fixed nextSignedInt() not actually returning signed ints
closes #4646
closes #4645

Impact assessment by core usage search and poggit suggests that the impact of this change will be close to zero.
However, since it changes behaviour which plugins might be unknowingly relying on, it's going into 4.1 rather than a patch release.
2021-12-15 00:59:10 +00:00
Dylan K. Taylor
dbad5dd611 Merge branch 'stable' into next-minor 2021-12-14 23:16:01 +00:00
Dylan K. Taylor
ea1fceece2 Merge branch 'legacy/pm3' into stable 2021-12-14 23:15:53 +00:00
Dylan K. Taylor
889d048ca3 Make use of Utils::assumeNotFalse() in a bunch of places
I've stuck to only doing this in the places where I'm sure we should never get false back. Other places I'm less sure of (and I found more bugs along the way).
2021-12-08 19:39:04 +00:00
Dylan K. Taylor
c6466a6da9 Utils: added crutch assumeNotFalse()
this can be used to get PHPStan to shut up about stuff that will never return false in normal contexts.
It's more fine-grained than @phpstan-ignore-line and less hassle than ignoreErrors (and works in PhpStorm too).
In addition, it's easy to search for references.
2021-12-08 18:58:39 +00:00
Dylan K. Taylor
8e37f86480 Avoid file_put_contents() when overwriting files
this fixes many cases of corruption during disk-full situations - file_put_contents() would write an empty file, destroying the original data.
fixes #3152
2021-12-05 00:26:48 +00:00
Dylan K. Taylor
8e8cee45b8 Config: use JSON_THROW_ON_ERROR for encoding 2021-12-04 21:44:12 +00:00
Dylan K. Taylor
b784a04e08 Utils: fixed parseDocComment() ignoring tags containing hyphens 2021-11-24 16:38:37 +00:00
Dylan K. Taylor
269231c228 Ban foreach(arrayWithStringKeys as k => v)
this is not as good as phpstan/phpstan-src#769 (e.g. array_key_first()/array_key_last() aren't covered by this, nor is array_rand()) but it does eliminate the most infuriating cases where this usually crops up.
2021-11-15 22:52:05 +00:00
Dylan K. Taylor
18f5fb66bb Abstract the base functionality of StringToItemParser 2021-11-08 18:37:05 +00:00
Dylan K. Taylor
d184838ba0 Move Promise classes to their own namespace 2021-11-02 17:10:07 +00:00
Dylan K. Taylor
e34364412b Replace InvalidStateException usages with InvalidArgument or LogicException 2021-11-02 16:05:54 +00:00
Dylan K. Taylor
4eef458d29 Config: throw AssumptionFailedError if config type is invalid or DETECT during save()
this should never happen ... it was already checked in load()
2021-11-02 16:03:43 +00:00
Dylan K. Taylor
f2912fcdd8 Updated pocketmine/log and pocketmine/log-pthreads (BC breaks included)
AttachableLogger deals with Closures now instead of LoggerAttachment objects
ThreadedLoggerAttachment no longer implements LoggerAttachment
2021-11-01 22:22:22 +00:00
Dylan K. Taylor
f827a555d5 Merge branch 'stable' 2021-11-01 18:13:24 +00:00
Dylan K. Taylor
08636d079d Promise: expose isResolved() 2021-10-31 22:48:52 +00:00