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
* then resubmit their request.
*
* @return dict<string, string> Original request parameters.
* @return array<string, string> Original request parameters.
*/
public function getPassthroughRequestParameters($include_quicksand = false) {
return self::flattenData(
@ -724,7 +724,7 @@ final class AphrontRequest extends Phobject {
/**
* 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) {
$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
* (with arrays flattened).
*
* @param dict<string, wild> $data Data to flatten.
* @return dict<string, string> Flat data suitable for inclusion in an HTTP
* request.
* @param array<string, wild> $data Data to flatten.
* @return array<string, string> Flat data suitable for inclusion in an HTTP
* request.
*/
public static function flattenData(array $data) {
$result = array();

View file

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

View file

@ -21,6 +21,9 @@ final class AphrontRoutingMap extends Phobject {
return $this;
}
/**
* @return AphrontSite
*/
public function getSite() {
return $this->site;
}
@ -30,6 +33,9 @@ final class AphrontRoutingMap extends Phobject {
return $this;
}
/**
* @return PhabricatorApplication
*/
public function getApplication() {
return $this->application;
}
@ -87,7 +93,8 @@ final class AphrontRoutingMap extends Phobject {
* @param string $route Pattern from the map.
* @param string $value Value from the map.
* @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
*/
private function tryRoute($route, $value, $path) {

View file

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

View file

@ -160,7 +160,7 @@ final class PhabricatorConduitAPIController
* Authenticate the client making the request to a Phabricator user account.
*
* @param ConduitAPIRequest $api_request Request being executed.
* @param dict $metadata Request metadata.
* @param array $metadata Dictionary of request metadata.
* @param wild $method
* @return null|pair Null to indicate successful authentication, or
* 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."
* 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) {
assert_instances_of($hunks, 'DifferentialHunk');

View file

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

View file

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

View file

@ -1215,7 +1215,7 @@ final class PhabricatorFile extends PhabricatorFileDAO
* @param PhabricatorUser $user Viewing user.
* @param list<PhabricatorFilesBuiltinFile> $builtins List of builtin file
* 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) {
$builtins = mpull($builtins, null, 'getBuiltinFileKey');

View file

@ -191,7 +191,7 @@ abstract class HarbormasterBuildStepImplementation extends Phobject {
* @{function:vcsprintf}.
* @param string $pattern User-provided pattern string containing
* `${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.
*/
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.
* @return dict Parsed body.
* @param string $body Raw mail text body.
* @return array<string, array|string> Parsed body.
*/
public function parseBody($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
* @{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() {
return self::newClassMapQuery()
@ -172,7 +172,7 @@ abstract class PhabricatorPHIDType extends Phobject {
* Get all PHID types of applications installed for a given viewer.
*
* @param PhabricatorUser $viewer Viewing user.
* @return dict<string, PhabricatorPHIDType> Map of constants to installed
* @return array<string, PhabricatorPHIDType> Map of constants to installed
* types.
*/
public static function getAllInstalledTypes(PhabricatorUser $viewer) {
@ -216,7 +216,7 @@ abstract class PhabricatorPHIDType extends Phobject {
* Get all PHID types 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(
string $application) {

View file

@ -4548,7 +4548,7 @@ abstract class PhabricatorApplicationTransactionEditor
*
* 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
*/
private function getWorkerState() {
@ -4573,7 +4573,7 @@ abstract class PhabricatorApplicationTransactionEditor
/**
* 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
*/
protected function getCustomWorkerState() {
@ -4588,7 +4588,7 @@ abstract class PhabricatorApplicationTransactionEditor
* This primarily allows binary data to be passed to workers and survive
* JSON encoding.
*
* @return dict<string, string> Property encodings.
* @return array<string, string> Property encodings.
* @task workers
*/
protected function getCustomWorkerStateEncoding() {
@ -4601,7 +4601,7 @@ abstract class PhabricatorApplicationTransactionEditor
*
* 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}.
* @return $this
* @task workers
@ -4628,7 +4628,7 @@ abstract class PhabricatorApplicationTransactionEditor
* Hook; set custom properties on the editor from data emitted by
* @{method:getCustomWorkerState}.
*
* @param dict<string, wild> $state Custom state,
* @param array<string, wild> $state Custom state,
* from @{method:getCustomWorkerState}.
* @return $this
* @task workers

View file

@ -77,7 +77,7 @@ abstract class PhutilKeyValueCache extends Phobject {
* Get data from the cache.
*
* @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
* omitted, so you can detect a cache miss.
* @task kvimpl
@ -92,7 +92,7 @@ abstract class PhutilKeyValueCache extends Phobject {
* after a specified number of seconds. By default, there is no expiration
* 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.
* @return $this
* @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
* @task memcache
*/

View file

@ -329,7 +329,7 @@ final class PhutilDaemonHandle extends Phobject {
* Dispatch an event to event listeners.
*
* @param string $type Event type.
* @param dict $params (optional) Event parameters.
* @param array $params (optional) Event parameters.
* @return void
*/
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
* using them.
*
* @param string $name Tag name.
* @param dict<string, wild> $attrs Tag attributes.
* @param wild $content (optional) Tag content.
* @return PhutilSafeHTML Tag object.
* @param string $name Tag name.
* @param array<string, wild> $attrs Dictionary of tag attributes.
* @param wild $content (optional) Tag content.
* @return PhutilSafeHTML Tag object.
*/
protected function newTag($name, array $attrs, $content = null) {
foreach ($attrs as $key => $attr) {

View file

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