Skip to content

Commit 7a95b58

Browse files
authored
Merge pull request #154 from PHPCSStandards/docs/move-array-specs-to-return-tags
Docs: move array return value specs to the `@return` tag
2 parents 440af70 + dc85208 commit 7a95b58

File tree

4 files changed

+51
-54
lines changed

4 files changed

+51
-54
lines changed

PHPCSUtils/Utils/ControlStructures.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -348,21 +348,21 @@ public static function getDeclareScopeOpenClose(File $phpcsFile, $stackPtr)
348348
/**
349349
* Retrieve the exception(s) being caught in a CATCH condition.
350350
*
351-
* The returned array will contain the following information for each caught exception:
352-
* ```php
353-
* 0 => array(
354-
* 'type' => string, // The type declaration for the exception being caught.
355-
* 'type_token' => integer, // The stack pointer to the start of the type declaration.
356-
* 'type_end_token' => integer, // The stack pointer to the end of the type declaration.
357-
* )
358-
* ```
359-
*
360351
* @since 1.0.0
361352
*
362353
* @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
363354
* @param int $stackPtr The position of the token we are checking.
364355
*
365-
* @return array
356+
* @return array Array with information about the caught Exception(s).
357+
* The returned array will contain the following information for
358+
* each caught exception:
359+
* ```php
360+
* 0 => array(
361+
* 'type' => string, // The type declaration for the exception being caught.
362+
* 'type_token' => integer, // The stack pointer to the start of the type declaration.
363+
* 'type_end_token' => integer, // The stack pointer to the end of the type declaration.
364+
* )
365+
* ```
366366
*
367367
* @throws \PHP_CodeSniffer\Exceptions\RuntimeException If the specified `$stackPtr` is not of
368368
* type `T_CATCH` or doesn't exist.

PHPCSUtils/Utils/FunctionDeclarations.php

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -160,24 +160,6 @@ public static function getName(File $phpcsFile, $stackPtr)
160160
/**
161161
* Retrieves the visibility and implementation properties of a method.
162162
*
163-
* The format of the return value is:
164-
* ```php
165-
* array(
166-
* 'scope' => 'public', // Public, private, or protected
167-
* 'scope_specified' => true, // TRUE if the scope keyword was found.
168-
* 'return_type' => '', // The return type of the method.
169-
* 'return_type_token' => integer, // The stack pointer to the start of the return type
170-
* // or FALSE if there is no return type.
171-
* 'return_type_end_token' => integer, // The stack pointer to the end of the return type
172-
* // or FALSE if there is no return type.
173-
* 'nullable_return_type' => false, // TRUE if the return type is nullable.
174-
* 'is_abstract' => false, // TRUE if the abstract keyword was found.
175-
* 'is_final' => false, // TRUE if the final keyword was found.
176-
* 'is_static' => false, // TRUE if the static keyword was found.
177-
* 'has_body' => false, // TRUE if the method has a body
178-
* );
179-
* ```
180-
*
181163
* Main differences with the PHPCS version:
182164
* - Bugs fixed:
183165
* - Handling of PHPCS annotations.
@@ -199,7 +181,24 @@ public static function getName(File $phpcsFile, $stackPtr)
199181
* @param int $stackPtr The position in the stack of the function token to
200182
* acquire the properties for.
201183
*
202-
* @return array
184+
* @return array Array with information about a function declaration.
185+
* The format of the return value is:
186+
* ```php
187+
* array(
188+
* 'scope' => 'public', // Public, private, or protected
189+
* 'scope_specified' => true, // TRUE if the scope keyword was found.
190+
* 'return_type' => '', // The return type of the method.
191+
* 'return_type_token' => integer, // The stack pointer to the start of the return type
192+
* // or FALSE if there is no return type.
193+
* 'return_type_end_token' => integer, // The stack pointer to the end of the return type
194+
* // or FALSE if there is no return type.
195+
* 'nullable_return_type' => false, // TRUE if the return type is nullable.
196+
* 'is_abstract' => false, // TRUE if the abstract keyword was found.
197+
* 'is_final' => false, // TRUE if the final keyword was found.
198+
* 'is_static' => false, // TRUE if the static keyword was found.
199+
* 'has_body' => false, // TRUE if the method has a body
200+
* );
201+
* ```
203202
*
204203
* @throws \PHP_CodeSniffer\Exceptions\RuntimeException If the specified position is not a T_FUNCTION
205204
* or T_CLOSURE token, nor an arrow function.

PHPCSUtils/Utils/ObjectDeclarations.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,6 @@ public static function getName(File $phpcsFile, $stackPtr)
153153
/**
154154
* Retrieves the implementation properties of a class.
155155
*
156-
* The format of the return value is:
157-
* ```php
158-
* array(
159-
* 'is_abstract' => false, // TRUE if the abstract keyword was found.
160-
* 'is_final' => false, // TRUE if the final keyword was found.
161-
* );
162-
* ```
163-
*
164156
* Main differences with the PHPCS version:
165157
* - Bugs fixed:
166158
* - Handling of PHPCS annotations.
@@ -177,7 +169,14 @@ public static function getName(File $phpcsFile, $stackPtr)
177169
* @param int $stackPtr The position in the stack of the `T_CLASS`
178170
* token to acquire the properties for.
179171
*
180-
* @return array
172+
* @return array Array with implementation properties of a class.
173+
* The format of the return value is:
174+
* ```php
175+
* array(
176+
* 'is_abstract' => false, // TRUE if the abstract keyword was found.
177+
* 'is_final' => false, // TRUE if the final keyword was found.
178+
* );
179+
* ```
181180
*
182181
* @throws \PHP_CodeSniffer\Exceptions\RuntimeException If the specified position is not a
183182
* `T_CLASS` token.

PHPCSUtils/Utils/Variables.php

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -75,21 +75,6 @@ class Variables
7575
/**
7676
* Retrieve the visibility and implementation properties of a class member variable.
7777
*
78-
* The format of the return value is:
79-
* ```php
80-
* array(
81-
* 'scope' => string, // Public, private, or protected.
82-
* 'scope_specified' => boolean, // TRUE if the scope was explicitly specified.
83-
* 'is_static' => boolean, // TRUE if the static keyword was found.
84-
* 'type' => string, // The type of the var (empty if no type specified).
85-
* 'type_token' => integer, // The stack pointer to the start of the type
86-
* // or FALSE if there is no type.
87-
* 'type_end_token' => integer, // The stack pointer to the end of the type
88-
* // or FALSE if there is no type.
89-
* 'nullable_type' => boolean, // TRUE if the type is nullable.
90-
* );
91-
* ```
92-
*
9378
* Main differences with the PHPCS version:
9479
* - Removed the parse error warning for properties in interfaces.
9580
* This will now throw the same _"$stackPtr is not a class member var"_ runtime exception as
@@ -105,7 +90,21 @@ class Variables
10590
* @param int $stackPtr The position in the stack of the `T_VARIABLE` token
10691
* to acquire the properties for.
10792
*
108-
* @return array
93+
* @return array Array with information about the class member variable.
94+
* The format of the return value is:
95+
* ```php
96+
* array(
97+
* 'scope' => string, // Public, private, or protected.
98+
* 'scope_specified' => boolean, // TRUE if the scope was explicitly specified.
99+
* 'is_static' => boolean, // TRUE if the static keyword was found.
100+
* 'type' => string, // The type of the var (empty if no type specified).
101+
* 'type_token' => integer, // The stack pointer to the start of the type
102+
* // or FALSE if there is no type.
103+
* 'type_end_token' => integer, // The stack pointer to the end of the type
104+
* // or FALSE if there is no type.
105+
* 'nullable_type' => boolean, // TRUE if the type is nullable.
106+
* );
107+
* ```
109108
*
110109
* @throws \PHP_CodeSniffer\Exceptions\RuntimeException If the specified position is not a
111110
* `T_VARIABLE` token.

0 commit comments

Comments
 (0)