Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
IdentifierSuffixer.php
01 <?php
02
03 declare(strict_types=1);
04
05 namespace ProxyManager\Generator\Util;
06
07 use PackageVersions\Versions;
08
09 /**
10 * Utility class capable of generating
11 * valid class/property/method identifiers
12 * with a deterministic attached suffix,
13 * in order to prevent property name collisions
14 * and tampering from userland
15 *
16 * @author Marco Pivetta <ocramius@gmail.com>
17 * @license MIT
18 */
19 abstract class IdentifierSuffixer
20 {
21 const VALID_IDENTIFIER_FORMAT = '/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]+$/';
22 const DEFAULT_IDENTIFIER = 'g';
23
24 final private function __construct()
25 {
26 }
27
28 /**
29 * Generates a valid unique identifier from the given name,
30 * with a suffix attached to it
31 */
32 public static function getIdentifier(string $name) : string
33 {
34 static $salt;
35
36 $salt = $salt ?? $salt = self::loadBaseHashSalt();
37 $suffix = \substr(\sha1($name . $salt), 0, 5);
38
39 if (! preg_match(self::VALID_IDENTIFIER_FORMAT, $name)) {
40 return self::DEFAULT_IDENTIFIER . $suffix;
41 }
42
43 return $name . $suffix;
44 }
45
46 private static function loadBaseHashSalt() : string
47 {
48 return \sha1(\serialize(Versions::VERSIONS));
49 }
50 }
51