1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-16 15:28:48 +02:00

Drop question mark suffix from optional PHPDoc @param types

Summary:
The question mark in `@param type? $foo Desc` is a custom notation not consistently applied across the codebase and not necessarily obvious to the reader (because custom and not mentioned in https://github.com/php-fig/fig-standards/blob/master/proposed/phpdoc.md ).
Instead, explicitly state "optional" in the parameter description for clarity.

Closes T15925.

Test Plan: Run PHPStan, see no `PHPDoc @param has invalid value (type? [...]` style output anymore.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15925

Differential Revision: https://we.phorge.it/D25797
This commit is contained in:
Andre Klapper 2024-08-22 11:56:50 +02:00
parent 9e6507d37a
commit 123831b53f
36 changed files with 92 additions and 85 deletions

View file

@ -780,9 +780,9 @@ final class AphrontRequest extends Phobject {
*
* @param string $name Canonical header name, like
`"Accept-Encoding"`.
* @param wild? $default Default value to return if header is not
present.
* @param array? $data Read this instead of `$_SERVER`.
* @param wild $default (optional) Default value to return if
header is not present.
* @param array $data (optional) Read this instead of `$_SERVER`.
* @return string|wild Header value if present, or `$default` if not.
*/
public static function getHTTPHeader($name, $default = null, $data = null) {

View file

@ -29,7 +29,7 @@ abstract class AphrontHTTPSink extends Phobject {
* Write an HTTP status code to the output.
*
* @param int $code Numeric HTTP status code.
* @param string? $message
* @param string $message (optional)
* @return void
*/
final public function writeHTTPStatus($code, $message = '') {

View file

@ -107,8 +107,8 @@ final class PhabricatorCookies extends Phobject {
*
* @param AphrontRequest $request Request to write to.
* @param string $next_uri URI to write.
* @param bool? $force Write this cookie even if we have a
* fresh cookie already.
* @param bool $force (optional) Write this cookie even if we
* have a fresh cookie already.
* @return void
*
* @task next

View file

@ -45,8 +45,8 @@ abstract class PhabricatorAuthController extends PhabricatorController {
* event and do something else if they prefer.
*
* @param PhabricatorUser $user User to log the viewer in as.
* @param bool? $force_full_session True to issue a full session immediately,
* bypassing MFA.
* @param bool $force_full_session (optional) True to issue a full session
* immediately, bypassing MFA.
* @return AphrontResponse Response which continues the login process.
*/
protected function loginUser(

View file

@ -327,7 +327,7 @@ final class PhabricatorAuthSessionEngine extends Phobject {
* multifactor authentication.
*
* @param PhabricatorUser $user User whose sessions should be terminated.
* @param string|null? $except_session Optionally, one session to keep.
* @param string|null $except_session (optional) One session to keep.
* Normally, the current login session.
*
* @return void
@ -428,9 +428,9 @@ final class PhabricatorAuthSessionEngine extends Phobject {
* @param AphrontRequest $request Current request.
* @param string $cancel_uri URI to return the user to if they
* cancel.
* @param bool? $jump_into_hisec True to jump partial sessions
* directly into high security instead of just
* upgrading them to full sessions.
* @param bool $jump_into_hisec (optional) True to jump partial
* sessions directly into high security instead of
* just upgrading them to full sessions.
* @return PhabricatorAuthHighSecurityToken Security token.
* @task hisec
*/
@ -742,7 +742,7 @@ final class PhabricatorAuthSessionEngine extends Phobject {
* Issue a high security token for a session, if authorized.
*
* @param PhabricatorAuthSession $session Session to issue a token for.
* @param bool? $force Force token issue.
* @param bool $force (optional) Force token issue.
* @return PhabricatorAuthHighSecurityToken|null Token, if authorized.
* @task hisec
*/
@ -945,11 +945,11 @@ final class PhabricatorAuthSessionEngine extends Phobject {
* @param PhabricatorUser $user User to generate a URI for.
* @param PhabricatorUserEmail? $email Optionally, email to verify when
* link is used.
* @param string? $type Optional context string for the URI. This is purely
* @param string $type (optional) Context string for the URI. This is purely
* cosmetic and used only to customize workflow and error messages.
* @param bool? $force_full_session True to generate a URI which forces an
* immediate upgrade to a full session, bypassing MFA and other login
* checks.
* @param bool $force_full_session (optional) True to generate a URI which
* forces an immediate upgrade to a full session, bypassing MFA and other
* login checks.
* @return string Login URI.
* @task onetime
*/
@ -994,9 +994,10 @@ final class PhabricatorAuthSessionEngine extends Phobject {
* Load the temporary token associated with a given one-time login key.
*
* @param PhabricatorUser $user User to load the token for.
* @param PhabricatorUserEmail? $email Optionally, email to verify when
* link is used.
* @param string? $key Key user is presenting as a valid one-time login key.
* @param PhabricatorUserEmail $email (optional) Email to verify when link is
* used.
* @param string $key (optional) Key user is presenting as a valid one-time
* login key.
* @return PhabricatorAuthTemporaryToken|null Token, if one exists.
* @task onetime
*/
@ -1022,9 +1023,9 @@ final class PhabricatorAuthSessionEngine extends Phobject {
* Hash a one-time login key for storage as a temporary token.
*
* @param PhabricatorUser $user User this key is for.
* @param PhabricatorUserEmail? $email Optionally, email to verify when
* link is used.
* @param string? $key The one time login key.
* @param PhabricatorUserEmail $email (optional) Email to verify when link is
* used.
* @param string $key (optional) The one time login key.
* @return string Hash of the key.
* task onetime
*/

View file

@ -462,7 +462,8 @@ abstract class PhabricatorAuthProvider extends Phobject {
*
* @param AphrontRequest $request HTTP request.
* @param string $mode Request mode string.
* @param map? $attributes Additional parameters, see above.
* @param map $attributes (optional) Additional parameters, see
* above.
* @return wild Log in button.
*/
protected function renderStandardLoginButton(

View file

@ -331,8 +331,8 @@ abstract class PhabricatorApplication
* Build items for the main menu.
*
* @param PhabricatorUser $user The viewing user.
* @param AphrontController? $controller The current controller. May be null
* for special pages like 404, exception handlers, etc.
* @param AphrontController $controller (optional) The current controller.
* May be null for special pages like 404, exception handlers, etc.
* @return list<PHUIListItemView> List of menu items.
* @task ui
*/

View file

@ -11,7 +11,7 @@
*
* @param string $symbol Name of the celerity module to include. This is
* whatever you annotated as "@provides" in the file.
* @param string? $source_name
* @param string $source_name (optional)
* @return void
*/
function require_celerity_resource($symbol, $source_name = 'phabricator') {
@ -42,7 +42,7 @@ function celerity_generate_unique_node_id() {
* Get the versioned URI for a raw resource, like an image.
*
* @param string $resource Path to the raw image.
* @param string? $source
* @param string $source (optional) Defaults to 'phabricator'
* @return string Versioned path to the image, if one is available.
*/
function celerity_get_resource_uri($resource, $source = 'phabricator') {

View file

@ -494,7 +494,7 @@ abstract class DifferentialChangesetHTMLRenderer
* @param int $top Beginning of the line range to build links for.
* @param int $len Length of the line range to build links for.
* @param int $changeset_length Total number of lines in the changeset.
* @param bool? $is_blocks
* @param bool $is_blocks (optional)
* @return markup Rendered links.
*/
protected function renderShowContextLinks(

View file

@ -20,8 +20,8 @@ final class DiffusionGitBranch extends Phobject {
* );
*
* @param string $stdout stdout of git branch command.
* @param string? $only_this_remote Filter branches to those on a specific
* remote.
* @param string $only_this_remote (optional) Filter branches to those on a
* specific remote.
* @return map Map of 'branch' or 'remote/branch' to hash at HEAD.
*/
public static function parseRemoteBranchOutput(

View file

@ -135,7 +135,7 @@ abstract class DiffusionRequest extends Phobject {
*
* @param string $identifier Repository identifier.
* @param PhabricatorUser $viewer Viewing user.
* @param bool? $need_edit
* @param bool $need_edit (optional)
* @return DiffusionRequest New request object.
* @task new
*/

View file

@ -21,7 +21,7 @@ final class PhabricatorImageTransformer extends Phobject {
* extensions), but can save images in another format.
*
* @param resource $data GD image resource.
* @param string? $preferred_mime Optionally, preferred mime type.
* @param string $preferred_mime (optional) Preferred mime type.
* @return string Bytes of an image file.
* @task save
*/

View file

@ -807,8 +807,8 @@ final class PhabricatorFile extends PhabricatorFileDAO
/**
* Return an iterable which emits file content bytes.
*
* @param int? $begin Offset for the start of data.
* @param int? $end Offset for the end of data.
* @param int $begin (optional) Offset for the start of data.
* @param int $end (optional) Offset for the end of data.
* @return Iterable Iterable object which emits requested data.
*/
public function getFileDataIterator($begin = null, $end = null) {

View file

@ -27,7 +27,7 @@ abstract class PhabricatorApplicationConfigurationPanel
/**
* Get the URI for this application configuration panel.
*
* @param string? $path Optional path to append.
* @param string $path (optional) Path to append.
* @return string Relative URI for the panel.
*/
public function getPanelURI($path = '') {

View file

@ -456,8 +456,8 @@ final class PhabricatorMetaMTAMail
*
* @param string $thread_id Unique identifier, appropriate for use in a
* Message-ID, In-Reply-To or References headers.
* @param bool? $is_first_message If true, indicates this is the first
* message in the thread.
* @param bool $is_first_message (optional) If true, indicates this is the
* first message in the thread.
* @return this
*/
public function setThreadID($thread_id, $is_first_message = false) {

View file

@ -341,8 +341,8 @@ final class PhabricatorRepositoryPullLocalDaemon
* With the `$consume` flag, an internal cursor will also be incremented so
* that these messages are not returned by subsequent calls.
*
* @param bool? $consume Pass `true` to consume these messages, so the
* process will not see them again.
* @param bool $consume (optional) Pass `true` to consume these messages, so
* the process will not see them again.
* @return list<wild> Pending update messages.
*
* @task pull

View file

@ -236,8 +236,8 @@ final class PhabricatorRepositoryGraphCache extends Phobject {
* to force a cache update by passing the existing data to `$rebuild_data`.
*
* @param int $bucket_key Bucket key, from @{method:getBucketKey}.
* @param mixed? $rebuild_data Current data, to force a cache rebuild of
* this bucket.
* @param mixed $rebuild_data (optional) Current data, to force a cache
* rebuild of this bucket.
* @return array Data from the cache.
* @task cache
*/

View file

@ -1645,7 +1645,8 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
* 2037). We adjust the pull frequency based on when the most recent commit
* occurred.
*
* @param int? $minimum The minimum update interval to use, in seconds.
* @param int $minimum (optional) The minimum update interval to use, in
* seconds.
* @return int Repository update interval, in seconds.
*/
public function loadUpdateInterval($minimum = 15) {
@ -2113,7 +2114,8 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
* For lower-level service resolution, see @{method:getAlmanacServiceURI}.
*
* @param PhabricatorUser $viewer Viewing user.
* @param bool? $never_proxy `true` to throw if a client would be returned.
* @param bool $never_proxy (optional) `true` to throw if a client would be
* returned.
* @return ConduitClient|null Client, or `null` for local repositories.
*/
public function newConduitClient(

View file

@ -732,7 +732,7 @@ abstract class PhabricatorApplicationSearchEngine extends Phobject {
*
* @param AphrontRequest $request Request to read user PHIDs from.
* @param string $key Key to read in the request.
* @param list<const>? $allow_types Other permitted PHID types.
* @param list<const> $allow_types (optional) Other permitted PHID types.
* @return list<phid> List of user PHIDs and selector functions.
* @task read
*/
@ -807,7 +807,7 @@ abstract class PhabricatorApplicationSearchEngine extends Phobject {
*
* @param AphrontRequest $request Request to read PHIDs from.
* @param string $key Key to read in the request.
* @param list<const>? $allow_types Optional, list of permitted PHID
* @param list<const> $allow_types (optional) List of permitted PHID
* types.
* @return list<phid> List of object PHIDs.
*

View file

@ -234,7 +234,7 @@ abstract class PhabricatorSettingsPanel extends Phobject {
/**
* Get the URI for this panel.
*
* @param string? $path Optional path to append.
* @param string $path (optional) Path to append.
* @return string Relative URI for the panel.
* @task panel
*/

View file

@ -713,8 +713,8 @@ abstract class PhabricatorEditEngine
* to make Conduit a little easier to use.
*
* @param wild $identifier ID, PHID, or monogram.
* @param list<const>? $capabilities List of required capability constants,
* or omit for defaults.
* @param list<const> $capabilities (optional) List of required capability
* constants, or omit for defaults.
* @return object Corresponding editable object.
* @task load
*/
@ -793,8 +793,8 @@ abstract class PhabricatorEditEngine
* Load an object by ID.
*
* @param int $id Object ID.
* @param list<const>? $capabilities List of required capability constants,
* or omit for defaults.
* @param list<const> $capabilities (optional) List of required capability
* constants, or omit for defaults.
* @return object|null Object, or null if no such object exists.
* @task load
*/
@ -810,8 +810,8 @@ abstract class PhabricatorEditEngine
* Load an object by PHID.
*
* @param phid $phid Object PHID.
* @param list<const>? $capabilities List of required capability constants,
* or omit for defaults.
* @param list<const> $capabilities (optional) List of required capability
* constants, or omit for defaults.
* @return object|null Object, or null if no such object exists.
* @task load
*/
@ -827,8 +827,8 @@ abstract class PhabricatorEditEngine
* Load an object given a configured query.
*
* @param PhabricatorPolicyAwareQuery $query Configured query.
* @param list<const>? $capabilities List of required capability constants,
* or omit for defaults.
* @param list<const> $capabilities (optional) List of required capability
* constants, or omit for defaults.
* @return object|null Object, or null if no such object exists.
* @task load
*/

View file

@ -31,7 +31,7 @@ abstract class PhutilKeyValueCache extends Phobject {
* once.
*
* @param string $key Key to retrieve.
* @param wild? $default Optional value to return if the key is not
* @param wild $default (optional) Value to return if the key is not
* found. By default, returns null.
* @return wild Cache value (on cache hit) or default value (on cache
* miss).
@ -51,7 +51,7 @@ abstract class PhutilKeyValueCache extends Phobject {
*
* @param string $key Key to set.
* @param wild $value Value to set.
* @param int|null? $ttl Optional TTL.
* @param int|null $ttl (optional) TTL.
* @return this
* @task kvimpl
*/
@ -93,7 +93,7 @@ abstract class PhutilKeyValueCache extends Phobject {
* policy and data will persist in cache indefinitely.
*
* @param dict<string, wild> $keys Map of cache keys to values.
* @param int|null? $ttl TTL for cache keys, in seconds.
* @param int|null $ttl (optional) TTL for cache keys, in seconds.
* @return this
* @task kvimpl
*/

View file

@ -23,9 +23,9 @@ abstract class PhabricatorContentSource extends Phobject {
* Construct a new content source object.
*
* @param const $source The source type constant to build a source for.
* @param array? $params Source parameters.
* @param bool? $force True to suppress errors and force construction of a
* source even if the source type is not valid.
* @param array $params (optional) Source parameters.
* @param bool $force (optional) True to suppress errors and force
* construction of a source even if the source type is not valid.
* @return PhabricatorContentSource New source object.
*/
final public static function newForSource(

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 Event parameters.
* @param dict $params (optional) Event parameters.
* @return void
*/
private function dispatchEvent($type, array $params = array()) {

View file

@ -232,7 +232,7 @@ abstract class PhabricatorWorker extends Phobject {
*
* @param string $class Task class to queue.
* @param array $data Data for the followup task.
* @param array? $options Options for the followup task.
* @param array $options (optional) Options for the followup task.
* @return this
*/
final protected function queueTask(
@ -261,7 +261,7 @@ abstract class PhabricatorWorker extends Phobject {
* this method to force the queue to flush before failing (for example, if
* you are using queues to improve locking behavior).
*
* @param map<string, wild>? $defaults Optional default options.
* @param map<string, wild> $defaults (optional) Default options.
*/
final public function flushTaskQueue($defaults = array()) {
foreach ($this->getQueuedTasks() as $task) {

View file

@ -48,7 +48,7 @@ final class PhabricatorEdgeEditor extends Phobject {
* @param phid $src Source object PHID.
* @param const $type Edge type constant.
* @param phid $dst Destination object PHID.
* @param map? $options Options map (see documentation).
* @param map $options (optional) Options map (see documentation).
* @return this
*
* @task edit

View file

@ -256,8 +256,10 @@ final class PhabricatorEdgeQuery extends PhabricatorQuery {
* $object->attachHandles(array_select_keys($handles, $dst_phids));
* }
*
* @param list? $src_phids List of PHIDs to select, or empty to select all.
* @param list? $types List of edge types to select, or empty to select all.
* @param list $src_phids (optional) List of PHIDs to select, or empty to
* select all.
* @param list $types (optional) List of edge types to select, or empty to
* select all.
* @return list<phid> List of matching destination PHIDs.
*/
public function getDestinationPHIDs(

View file

@ -59,8 +59,8 @@ final class PhabricatorMarkupEngine extends Phobject {
* @param PhabricatorMarkupInterface $object The object to render.
* @param string $field The field to render.
* @param PhabricatorUser $viewer User viewing the markup.
* @param object? $context_object A context object for
* policy checks.
* @param object $context_object (optional) A context
* object for policy checks.
* @return string Marked up output.
* @task markup
*/
@ -196,7 +196,7 @@ final class PhabricatorMarkupEngine extends Phobject {
* @param string $field The field to retrieve.
* @param string $metadata_key The engine metadata field
* to retrieve.
* @param wild? $default Optional default value.
* @param wild $default (optional) Default value.
* @task markup
*/
public function getEngineMetadata(

View file

@ -22,8 +22,8 @@ abstract class PhutilMarkupEngine extends Phobject {
* metadata may be available in your configuration.
*
* @param string $key Key to retrieve from metadata.
* @param mixed? $default Default value to return if the key is not
* available.
* @param mixed $default (optional) Default value to return if the key is
* not available.
* @return mixed Metadata property, or default value.
*/
abstract public function getTextMetadata($key, $default = null);

View file

@ -62,7 +62,7 @@ abstract class PhutilRemarkupRule extends Phobject {
*
* @param string $name Tag name.
* @param dict<string, wild> $attrs Tag attributes.
* @param wild? $content Tag content.
* @param wild $content (optional) Tag content.
* @return PhutilSafeHTML Tag object.
*/
protected function newTag($name, array $attrs, $content = null) {

View file

@ -17,8 +17,8 @@
* parameters.
*
* @param string $tag The name of the tag, like `a` or `div`.
* @param map<string, string>? $attributes A map of tag attributes.
* @param wild? $content Content to put in the tag.
* @param map<string, string> $attributes (optional) A map of tag attributes.
* @param wild $content (optional) Content to put in the tag.
* @return PhutilSafeHTML Tag object.
*/
function phutil_tag($tag, array $attributes = array(), $content = null) {

View file

@ -264,7 +264,7 @@ abstract class LiskDAO extends Phobject
*
* @param mode $mode Connection mode.
* @param AphrontDatabaseConnection $connection Connection to cache.
* @param bool? $force_unique
* @param bool $force_unique (optional)
* @return this
* @task conn
*/
@ -802,8 +802,9 @@ abstract class LiskDAO extends Phobject
* Get or build the database connection for this object.
*
* @param string $mode 'r' for read, 'w' for read/write.
* @param bool? $force_new True to force a new connection. The connection
* will not be retrieved from or saved into the connection cache.
* @param bool $force_new (optional) True to force a new connection. The
* connection will not be retrieved from or saved into the connection
* cache.
* @return AphrontDatabaseConnection Lisk connection object.
*
* @task info

View file

@ -12,7 +12,7 @@ final class PhabricatorHash extends Phobject {
* weak. Callers should prefer @{method:digestWithNamedKey}.
*
* @param string $string Input string.
* @param string? $key
* @param string $key (optional)
* @return string 32-byte hexadecimal SHA1+HMAC hash.
*/
public static function weakDigest($string, $key = null) {

View file

@ -16,7 +16,7 @@ final class PHUICrumbsView extends AphrontView {
* a link.
*
* @param string $text Text of the crumb.
* @param string? $href Optional href for the crumb.
* @param string $href (optional) href for the crumb.
* @return this
*/
public function addTextCrumb($text, $href = null) {

View file

@ -344,10 +344,10 @@ final class PhabricatorStartup {
* Fatal the request completely, sending a plain text message to the client.
*
* @param string $message Plain text message to send to the client.
* @param string? $log_message Plain text message to send to the error log.
* If not provided, the client message is used. You can pass
* a more detailed message here (e.g., with stack traces) to
* avoid showing it to users.
* @param string $log_message (optional) Plain text message to send to the
* error log. If not provided, the client message is used.
* You can pass a more detailed message here (e.g., with
* stack traces) to avoid showing it to users.
* @return exit This method **does not return**.
*
* @task apocalypse

View file

@ -4,7 +4,7 @@
* Parse the "X_FORWARDED_FOR" HTTP header to determine the original client
* address.
*
* @param int? $layers Number of devices to trust.
* @param int $layers (optional) Number of devices to trust.
* @return void
*/
function preamble_trust_x_forwarded_for_header($layers = 1) {