note 126866 added to language.enumerations.static-methods

From: Date: Mon, 21 Feb 2022 16:42:07 +0000
Subject: note 126866 added to language.enumerations.static-methods
Groups: php.notes 
Request: Send a blank email to php-notes+get-217635@lists.php.net to get a copy of this message
To get all scalar equivalents values of Backed Enum as an array you could define a method in your Enum: <?php enum Suit: string { case Hearts = 'H'; case Diamonds = 'D'; case Clubs = 'C'; case Spades = 'S'; public static function values(): array { return array_column(self::cases(), 'value'); } } ?> ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.5.135 (proxied: 151.241.170.145) ---- Manual Page -- https://php.net/manual/en/language.enumerations.static-methods.php Edit -- https://main.php.net/note/edit/126866 Del: integrated -- https://main.php.net/note/delete/126866/integrated Del: useless -- https://main.php.net/note/delete/126866/useless Del: bad code -- https://main.php.net/note/delete/126866/bad+code Del: spam -- https://main.php.net/note/delete/126866/spam Del: non-english -- https://main.php.net/note/delete/126866/non-english Del: in docs -- https://main.php.net/note/delete/126866/in+docs Del: other reasons-- https://main.php.net/note/delete/126866 Reject -- https://main.php.net/note/reject/126866 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#217635) next »