diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2021-05-08 21:03:29 +0200 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2021-05-08 21:03:29 +0200 |
commit | 7d17f220e52d683f849a1854278a9bd47af17dd2 (patch) | |
tree | 3fed3ff2c6ab28c397a929a02e56d238ca40ed6d /generate-sample-gig-data.php | |
parent | ee9bef751805ac3f3c9572d1620f2221092b3094 (diff) | |
parent | 30f12e61317d9b181efb46382a4db98d73f65954 (diff) | |
download | gigologadmin-7d17f220e52d683f849a1854278a9bd47af17dd2.tar.gz gigologadmin-7d17f220e52d683f849a1854278a9bd47af17dd2.tar.bz2 gigologadmin-7d17f220e52d683f849a1854278a9bd47af17dd2.zip |
Merge branch 'psalm' into dev
This brings another tool in to help us keep the code in order - Psalm.
(I thought the name was fitting! :)
This will do fairly simple static analysis of the code, and report
problems and suggest fixes. It can help fix some issues itself, but
please double check that it does the right thing.
More info: https://psalm.dev
This merge also brings in fixes that was suggested by Paslm. Mostly this
is typa annotations for functions, but also some bugfixes discovered by
the tool.
Diffstat (limited to 'generate-sample-gig-data.php')
-rw-r--r-- | generate-sample-gig-data.php | 62 |
1 files changed, 50 insertions, 12 deletions
diff --git a/generate-sample-gig-data.php b/generate-sample-gig-data.php index 26ba0cf..11e9a0a 100644 --- a/generate-sample-gig-data.php +++ b/generate-sample-gig-data.php @@ -7,9 +7,9 @@ abstract class GeneratorBase { - abstract public function get(); + abstract public function get() : string; - function pick($arr) + function pick(array $arr) : string { return $arr[array_rand($arr)]; } @@ -17,13 +17,23 @@ abstract class GeneratorBase class BandNameGenerator extends GeneratorBase { - private $prefixes = array( + /** + * @var string[] + * + * @psalm-var array{0: string, 1: string, 2: string} + */ + private array $prefixes = array( "", "a", "the", ); - private $adverbs = array( + /** + * @var string[] + * + * @psalm-var array{0: string, 1: string, 2: string, 3: string, 4: string, 5: string, 6: string, 7: string} + */ + private array $adverbs = array( "bestial", "dead", "incongruent", @@ -34,7 +44,12 @@ class BandNameGenerator extends GeneratorBase "flamboyant", ); - private $verbs = array( + /** + * @var string[] + * + * @psalm-var array{0: string, 1: string, 2: string, 3: string, 4: string, 5: string, 6: string} + */ + private array $verbs = array( "kill", "regurgitat", "destroy", @@ -44,14 +59,19 @@ class BandNameGenerator extends GeneratorBase "mutilat", ); - private $endings = array( + /** + * @var string[] + * + * @psalm-var array{0: string, 1: string, 2: string, 3: string} + */ + private array $endings = array( "er", "ers", "ing", "ed", ); - public function get() + public function get() : string { $parts = array( $this->pick($this->prefixes), @@ -64,7 +84,12 @@ class BandNameGenerator extends GeneratorBase class VenueGenerator extends GeneratorBase { - private $prefix1 = array( + /** + * @var string[] + * + * @psalm-var array{0: string, 1: string, 2: string, 3: string, 4: string} + */ + private array $prefix1 = array( "", "royal", "shabby", @@ -72,7 +97,12 @@ class VenueGenerator extends GeneratorBase "drunken", ); - private $prefix2 = array( + /** + * @var string[] + * + * @psalm-var array{0: string, 1: string, 2: string, 3: string, 4: string, 5: string} + */ + private array $prefix2 = array( "", "music", "fiddler", @@ -81,7 +111,12 @@ class VenueGenerator extends GeneratorBase "mental", ); - private $type = array( + /** + * @var string[] + * + * @psalm-var array{0: string, 1: string, 2: string, 3: string, 4: string, 5: string, 6: string} + */ + private array $type = array( "hall", "museum", "asylum", @@ -91,7 +126,7 @@ class VenueGenerator extends GeneratorBase "lighthouse" ); - public function get() + public function get() : string { $parts = array( $this->pick($this->prefix1), @@ -104,7 +139,10 @@ class VenueGenerator extends GeneratorBase class LinkGenerator extends GeneratorBase { - public function get() + /** + * @return string + */ + public function get() : string { return 'https://example.com/' . bin2hex(random_bytes(8)); } |