PhpDoc: Replace non-standard dict type with array

Summary:
Make static code analysis more correct (which does not also mean less noisy) by replacing "dict" and "dictionary" types in PhpDoc with what they actually are: an array.
The "dictionary" type is not mentioned in `arcanist/src/parser/PhutilTypeSpec.php` either, thus no side effects.

See also related discussions in https://we.phorge.it/D26037 and https://we.phorge.it/D26039#27821

Test Plan: Grep and read the code, use static code analysis.

Reviewers: O1 Blessed Committers, valerio.bozzolan, amybones

Reviewed By: O1 Blessed Committers, valerio.bozzolan, amybones

Subscribers: amybones, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Differential Revision: https://we.phorge.it/D26059
This commit is contained in:
Andre Klapper 2025-06-03 20:08:07 +02:00
parent aed58a3444
commit 697d08f581
18 changed files with 67 additions and 46 deletions

View file

@ -714,7 +714,7 @@ final class AphrontRequest extends Phobject {
* This is primarily useful if you want to ask the user for more input and * This is primarily useful if you want to ask the user for more input and
* then resubmit their request. * then resubmit their request.
* *
* @return dict<string, string> Original request parameters. * @return array<string, string> Original request parameters.
*/ */
public function getPassthroughRequestParameters($include_quicksand = false) { public function getPassthroughRequestParameters($include_quicksand = false) {
return self::flattenData( return self::flattenData(
@ -724,7 +724,7 @@ final class AphrontRequest extends Phobject {
/** /**
* Get request data other than "magic" parameters. * Get request data other than "magic" parameters.
* *
* @return dict<string, wild> Request data, with magic filtered out. * @return array<string, wild> Request data, with magic filtered out.
*/ */
public function getPassthroughRequestData($include_quicksand = false) { public function getPassthroughRequestData($include_quicksand = false) {
$data = $this->getRequestData(); $data = $this->getRequestData();
@ -748,9 +748,9 @@ final class AphrontRequest extends Phobject {
* into a list of key-value pairs suitable for submitting via HTTP request * into a list of key-value pairs suitable for submitting via HTTP request
* (with arrays flattened). * (with arrays flattened).
* *
* @param dict<string, wild> $data Data to flatten. * @param array<string, wild> $data Data to flatten.
* @return dict<string, string> Flat data suitable for inclusion in an HTTP * @return array<string, string> Flat data suitable for inclusion in an HTTP
* request. * request.
*/ */
public static function flattenData(array $data) { public static function flattenData(array $data) {
$result = array(); $result = array();

View file

@ -387,8 +387,8 @@ final class AphrontApplicationConfiguration
/** /**
* Build a controller to respond to the request. * Build a controller to respond to the request.
* *
* @return pair<AphrontController,dict> Controller and dictionary of request * @return pair<AphrontController,array> Controller and dictionary of request
* parameters. * parameters.
* @task routing * @task routing
*/ */
private function buildController() { private function buildController() {
@ -512,8 +512,9 @@ final class AphrontApplicationConfiguration
* *
* @param list<AphrontRoutingMap> $maps List of routing maps. * @param list<AphrontRoutingMap> $maps List of routing maps.
* @param string $path Path to route. * @param string $path Path to route.
* @return pair<AphrontController,dict>|null Controller and dictionary of * @return array<AphrontController,array<string,string>>|null Controller
* request parameters, or null if no paths to route were found. * subclass and dictionary of request parameters, or null if no paths to
* route were found.
* @task routing * @task routing
*/ */
private function routePath(array $maps, $path) { private function routePath(array $maps, $path) {

View file

@ -21,6 +21,9 @@ final class AphrontRoutingMap extends Phobject {
return $this; return $this;
} }
/**
* @return AphrontSite
*/
public function getSite() { public function getSite() {
return $this->site; return $this->site;
} }
@ -30,6 +33,9 @@ final class AphrontRoutingMap extends Phobject {
return $this; return $this;
} }
/**
* @return PhabricatorApplication
*/
public function getApplication() { public function getApplication() {
return $this->application; return $this->application;
} }
@ -87,7 +93,8 @@ final class AphrontRoutingMap extends Phobject {
* @param string $route Pattern from the map. * @param string $route Pattern from the map.
* @param string $value Value from the map. * @param string $value Value from the map.
* @param string $path Path to route. * @param string $path Path to route.
* @return dict<string, wild>|null Match details, if path matches sub-map. * @return array<string, array<string>|string>|null Match details, if path
* matches sub-map.
* @task routing * @task routing
*/ */
private function tryRoute($route, $value, $path) { private function tryRoute($route, $value, $path) {

View file

@ -21,6 +21,9 @@ final class AphrontRoutingResult extends Phobject {
return $this; return $this;
} }
/**
* @return AphrontSite
*/
public function getSite() { public function getSite() {
return $this->site; return $this->site;
} }
@ -30,6 +33,9 @@ final class AphrontRoutingResult extends Phobject {
return $this; return $this;
} }
/**
* @return PhabricatorApplication
*/
public function getApplication() { public function getApplication() {
return $this->application; return $this->application;
} }
@ -39,6 +45,9 @@ final class AphrontRoutingResult extends Phobject {
return $this; return $this;
} }
/**
* @return AphrontController
*/
public function getController() { public function getController() {
return $this->controller; return $this->controller;
} }
@ -48,6 +57,9 @@ final class AphrontRoutingResult extends Phobject {
return $this; return $this;
} }
/**
* @return array<string,string>
*/
public function getURIData() { public function getURIData() {
return $this->uriData; return $this->uriData;
} }

View file

@ -160,7 +160,7 @@ final class PhabricatorConduitAPIController
* Authenticate the client making the request to a Phabricator user account. * Authenticate the client making the request to a Phabricator user account.
* *
* @param ConduitAPIRequest $api_request Request being executed. * @param ConduitAPIRequest $api_request Request being executed.
* @param dict $metadata Request metadata. * @param array $metadata Dictionary of request metadata.
* @param wild $method * @param wild $method
* @return null|pair Null to indicate successful authentication, or * @return null|pair Null to indicate successful authentication, or
* an error code and error message pair. * an error code and error message pair.

View file

@ -14,7 +14,8 @@ final class DifferentialHunkParser extends Phobject {
* datastructure is used to determine when to render "Context not available." * datastructure is used to determine when to render "Context not available."
* in diffs with multiple hunks. * in diffs with multiple hunks.
* *
* @return dict<int, bool> Map of lines where hunks start, other than line 1. * @return array<int|string, bool> Map of lines where hunks start, other than
* line 1.
*/ */
public function getHunkStartLines(array $hunks) { public function getHunkStartLines(array $hunks) {
assert_instances_of($hunks, 'DifferentialHunk'); assert_instances_of($hunks, 'DifferentialHunk');

View file

@ -32,8 +32,8 @@ abstract class PhabricatorFeedStory
* construct appropriate @{class:PhabricatorFeedStory} wrappers for each * construct appropriate @{class:PhabricatorFeedStory} wrappers for each
* data row. * data row.
* *
* @param list<dict> $rows List of @{class:PhabricatorFeedStoryData} rows * @param array<int,array<string,string>> $rows List of
* from the database. * @{class:PhabricatorFeedStoryData} rows from the database.
* @param PhabricatorUser $viewer * @param PhabricatorUser $viewer
* @return list<PhabricatorFeedStory> List of @{class:PhabricatorFeedStory} * @return list<PhabricatorFeedStory> List of @{class:PhabricatorFeedStory}
* objects. * objects.

View file

@ -96,8 +96,8 @@ final class PhabricatorFileQuery
* `PHID-FILE-aaaa` and all transformations of the file with PHID * `PHID-FILE-aaaa` and all transformations of the file with PHID
* `PHID-FILE-bbbb`. * `PHID-FILE-bbbb`.
* *
* @param list<dict> $specs List of transform specifications, described * @param array<int, array<string, mixed>> $specs List of transform
* above. * specifications, described above.
* @return $this * @return $this
*/ */
public function withTransforms(array $specs) { public function withTransforms(array $specs) {

View file

@ -1215,7 +1215,7 @@ final class PhabricatorFile extends PhabricatorFileDAO
* @param PhabricatorUser $user Viewing user. * @param PhabricatorUser $user Viewing user.
* @param list<PhabricatorFilesBuiltinFile> $builtins List of builtin file * @param list<PhabricatorFilesBuiltinFile> $builtins List of builtin file
* specs. * specs.
* @return dict<string, PhabricatorFile> Dictionary of named builtins. * @return array<string, PhabricatorFile> Dictionary of named builtins.
*/ */
public static function loadBuiltins(PhabricatorUser $user, array $builtins) { public static function loadBuiltins(PhabricatorUser $user, array $builtins) {
$builtins = mpull($builtins, null, 'getBuiltinFileKey'); $builtins = mpull($builtins, null, 'getBuiltinFileKey');

View file

@ -191,7 +191,7 @@ abstract class HarbormasterBuildStepImplementation extends Phobject {
* @{function:vcsprintf}. * @{function:vcsprintf}.
* @param string $pattern User-provided pattern string containing * @param string $pattern User-provided pattern string containing
* `${variables}`. * `${variables}`.
* @param dict $variables List of available replacement variables. * @param array $variables List of available replacement variables.
* @return string String with variables replaced safely into it. * @return string String with variables replaced safely into it.
*/ */
protected function mergeVariables($function, $pattern, array $variables) { protected function mergeVariables($function, $pattern, array $variables) {

View file

@ -26,8 +26,8 @@ final class PhabricatorMetaMTAEmailBodyParser extends Phobject {
* ), * ),
* ) * )
* *
* @param string $body Raw mail text body. * @param string $body Raw mail text body.
* @return dict Parsed body. * @return array<string, array|string> Parsed body.
*/ */
public function parseBody($body) { public function parseBody($body) {
$body = $this->stripTextBody($body); $body = $this->stripTextBody($body);

View file

@ -147,7 +147,7 @@ abstract class PhabricatorPHIDType extends Phobject {
* To get PHID types a given user has access to, see * To get PHID types a given user has access to, see
* @{method:getAllInstalledTypes}. * @{method:getAllInstalledTypes}.
* *
* @return dict<string, PhabricatorPHIDType> Map of type constants to types. * @return array<string, PhabricatorPHIDType> Map of type constants to types.
*/ */
final public static function getAllTypes() { final public static function getAllTypes() {
return self::newClassMapQuery() return self::newClassMapQuery()
@ -172,7 +172,7 @@ abstract class PhabricatorPHIDType extends Phobject {
* Get all PHID types of applications installed for a given viewer. * Get all PHID types of applications installed for a given viewer.
* *
* @param PhabricatorUser $viewer Viewing user. * @param PhabricatorUser $viewer Viewing user.
* @return dict<string, PhabricatorPHIDType> Map of constants to installed * @return array<string, PhabricatorPHIDType> Map of constants to installed
* types. * types.
*/ */
public static function getAllInstalledTypes(PhabricatorUser $viewer) { public static function getAllInstalledTypes(PhabricatorUser $viewer) {
@ -216,7 +216,7 @@ abstract class PhabricatorPHIDType extends Phobject {
* Get all PHID types of an application. * Get all PHID types of an application.
* *
* @param string $application Class name of an application * @param string $application Class name of an application
* @return dict<string, PhabricatorPHIDType> Map of constants of application * @return array<string, PhabricatorPHIDType> Map of constants of application
*/ */
public static function getAllTypesForApplication( public static function getAllTypesForApplication(
string $application) { string $application) {

View file

@ -4548,7 +4548,7 @@ abstract class PhabricatorApplicationTransactionEditor
* *
* This data will be loaded with @{method:loadWorkerState} in the worker. * This data will be loaded with @{method:loadWorkerState} in the worker.
* *
* @return dict<string, wild> Serializable editor state. * @return array<string, wild> Serializable editor state.
* @task workers * @task workers
*/ */
private function getWorkerState() { private function getWorkerState() {
@ -4573,7 +4573,7 @@ abstract class PhabricatorApplicationTransactionEditor
/** /**
* Hook; return custom properties which need to be passed to workers. * Hook; return custom properties which need to be passed to workers.
* *
* @return dict<string, wild> Custom properties. * @return array<string, wild> Custom properties.
* @task workers * @task workers
*/ */
protected function getCustomWorkerState() { protected function getCustomWorkerState() {
@ -4588,7 +4588,7 @@ abstract class PhabricatorApplicationTransactionEditor
* This primarily allows binary data to be passed to workers and survive * This primarily allows binary data to be passed to workers and survive
* JSON encoding. * JSON encoding.
* *
* @return dict<string, string> Property encodings. * @return array<string, string> Property encodings.
* @task workers * @task workers
*/ */
protected function getCustomWorkerStateEncoding() { protected function getCustomWorkerStateEncoding() {
@ -4601,7 +4601,7 @@ abstract class PhabricatorApplicationTransactionEditor
* *
* This method is used to load state when running worker operations. * This method is used to load state when running worker operations.
* *
* @param dict<string, wild> $state Editor state, from * @param array<string, wild> $state Editor state, from
@{method:getWorkerState}. @{method:getWorkerState}.
* @return $this * @return $this
* @task workers * @task workers
@ -4628,7 +4628,7 @@ abstract class PhabricatorApplicationTransactionEditor
* Hook; set custom properties on the editor from data emitted by * Hook; set custom properties on the editor from data emitted by
* @{method:getCustomWorkerState}. * @{method:getCustomWorkerState}.
* *
* @param dict<string, wild> $state Custom state, * @param array<string, wild> $state Custom state,
* from @{method:getCustomWorkerState}. * from @{method:getCustomWorkerState}.
* @return $this * @return $this
* @task workers * @task workers

View file

@ -77,7 +77,7 @@ abstract class PhutilKeyValueCache extends Phobject {
* Get data from the cache. * Get data from the cache.
* *
* @param list<string> $keys List of cache keys to retrieve. * @param list<string> $keys List of cache keys to retrieve.
* @return dict<string, wild> Dictionary of keys that were found in the * @return array<string, wild> Dictionary of keys that were found in the
* cache. Keys not present in the cache are * cache. Keys not present in the cache are
* omitted, so you can detect a cache miss. * omitted, so you can detect a cache miss.
* @task kvimpl * @task kvimpl
@ -92,7 +92,7 @@ abstract class PhutilKeyValueCache extends Phobject {
* after a specified number of seconds. By default, there is no expiration * after a specified number of seconds. By default, there is no expiration
* policy and data will persist in cache indefinitely. * policy and data will persist in cache indefinitely.
* *
* @param dict<string, wild> $keys Map of cache keys to values. * @param array<string, wild> $keys Map of cache keys to values.
* @param int|null $ttl (optional) TTL for cache keys, in seconds. * @param int|null $ttl (optional) TTL for cache keys, in seconds.
* @return $this * @return $this
* @task kvimpl * @task kvimpl

View file

@ -100,7 +100,7 @@ final class PhutilMemcacheKeyValueCache extends PhutilKeyValueCache {
* ), * ),
* )); * ));
* *
* @param list<dict> $servers List of server specifications. * @param array $servers List of server specifications.
* @return $this * @return $this
* @task memcache * @task memcache
*/ */

View file

@ -329,7 +329,7 @@ final class PhutilDaemonHandle extends Phobject {
* Dispatch an event to event listeners. * Dispatch an event to event listeners.
* *
* @param string $type Event type. * @param string $type Event type.
* @param dict $params (optional) Event parameters. * @param array $params (optional) Event parameters.
* @return void * @return void
*/ */
private function dispatchEvent($type, array $params = array()) { private function dispatchEvent($type, array $params = array()) {

View file

@ -60,10 +60,10 @@ abstract class PhutilRemarkupRule extends Phobject {
* This method acts as @{function:phutil_tag}, but checks attributes before * This method acts as @{function:phutil_tag}, but checks attributes before
* using them. * using them.
* *
* @param string $name Tag name. * @param string $name Tag name.
* @param dict<string, wild> $attrs Tag attributes. * @param array<string, wild> $attrs Dictionary of tag attributes.
* @param wild $content (optional) Tag content. * @param wild $content (optional) Tag content.
* @return PhutilSafeHTML Tag object. * @return PhutilSafeHTML Tag object.
*/ */
protected function newTag($name, array $attrs, $content = null) { protected function newTag($name, array $attrs, $content = null) {
foreach ($attrs as $key => $attr) { foreach ($attrs as $key => $attr) {

View file

@ -450,8 +450,8 @@ abstract class LiskDAO extends Phobject
/** /**
* Loads all of the objects, unconditionally. * Loads all of the objects, unconditionally.
* *
* @return dict Dictionary of all persisted objects of this type, keyed * @return array<int,object> Dictionary of all persisted objects of this
* on object ID. * type, keyed on object ID.
* *
* @task load * @task load
*/ */
@ -470,7 +470,7 @@ abstract class LiskDAO extends Phobject
* *
* @param string $pattern queryfx()-style SQL WHERE clause. * @param string $pattern queryfx()-style SQL WHERE clause.
* @param mixed $args,... Zero or more conversions. * @param mixed $args,... Zero or more conversions.
* @return dict Dictionary of matching objects, keyed on ID. * @return array<int,object> Dictionary of matching objects, keyed on ID.
* *
* @task load * @task load
*/ */
@ -574,9 +574,9 @@ abstract class LiskDAO extends Phobject
* convenient to pull data from elsewhere directly (e.g., a complicated * convenient to pull data from elsewhere directly (e.g., a complicated
* join via @{method:queryData}) and then load from an array representation. * join via @{method:queryData}) and then load from an array representation.
* *
* @param dict $row Dictionary of properties, which should be equivalent * @param array<string,string|null> $row Dictionary of properties, which
* to selecting a row from the table or calling * should be equivalent to selecting a row from the table or calling
* @{method:getProperties}. * @{method:getProperties}.
* @return $this * @return $this
* *
* @task load * @task load
@ -650,7 +650,7 @@ abstract class LiskDAO extends Phobject
* This is a lot messier than @{method:loadAllWhere}, but more flexible. * This is a lot messier than @{method:loadAllWhere}, but more flexible.
* *
* @param list $rows List of property dictionaries. * @param list $rows List of property dictionaries.
* @return dict List of constructed objects, keyed on ID. * @return array<int,object> List of constructed objects, keyed on ID.
* *
* @task load * @task load
*/ */
@ -739,8 +739,8 @@ abstract class LiskDAO extends Phobject
* database. * database.
* Properties that should not be persisted must be declared as private. * Properties that should not be persisted must be declared as private.
* *
* @return dict Dictionary of normalized (lowercase) to canonical (original * @return array<string,string> Dictionary of normalized (lowercase) to
* case) property names. * canonical (original case) property names.
* *
* @task info * @task info
*/ */
@ -874,7 +874,7 @@ abstract class LiskDAO extends Phobject
* using legacy features with CONFIG_CONVERT_CAMELCASE, but in that case you * using legacy features with CONFIG_CONVERT_CAMELCASE, but in that case you
* should just go ahead and die in a fire). * should just go ahead and die in a fire).
* *
* @return dict Dictionary of object properties. * @return array<string,wild|null> Dictionary of object properties.
* *
* @task info * @task info
*/ */