@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class PhabricatorPHID extends Phobject {
4
5 public static function generateNewPHID($type, $subtype = null) {
6 if (!$type) {
7 throw new Exception(pht('Can not generate PHID with no type.'));
8 }
9
10 if ($subtype === null) {
11 $uniq_len = 20;
12 $type_str = "{$type}";
13 } else {
14 $uniq_len = 15;
15 $type_str = "{$type}-{$subtype}";
16 }
17
18 $uniq = Filesystem::readRandomCharacters($uniq_len);
19 return "PHID-{$type_str}-{$uniq}";
20 }
21
22}