*/
list( $partname, $ext ) = $this->splitExtensions( $this->mFilteredName );
- if ( count( $ext ) ) {
- $this->mFinalExtension = trim( $ext[count( $ext ) - 1] );
+ if ( $ext !== [] ) {
+ $this->mFinalExtension = trim( end( $ext ) );
} else {
$this->mFinalExtension = '';
$props = $this->mFileProps;
$error = null;
Hooks::run( 'UploadStashFile', [ $this, $user, $props, &$error ] );
- if ( $error ) {
- if ( !is_array( $error ) ) {
- $error = [ $error ];
- }
+ if ( $error && !is_array( $error ) ) {
+ $error = [ $error ];
}
return $error;
}
* scripts, so the blacklist needs to check them all.
*
* @param string $filename
- * @return array
+ * @return array [ string, string[] ]
*/
public static function splitExtensions( $filename ) {
$bits = explode( '.', $filename );
* Perform case-insensitive match against a list of file extensions.
* Returns an array of matching extensions.
*
- * @param array $ext
- * @param array $list
+ * @param string[] $ext
+ * @param string[] $list
* @return bool
*/
public static function checkFileExtensionList( $ext, $list ) {
$output = true; # if there's no output, return true
} elseif ( $msgPattern ) {
$groups = [];
- if ( preg_match( $msgPattern, $output, $groups ) ) {
- if ( $groups[1] ) {
- $output = $groups[1];
- }
+ if ( preg_match( $msgPattern, $output, $groups ) && $groups[1] ) {
+ $output = $groups[1];
}
}