rdbms: Type IDatabase::buildLike param as variadic to Phan
authorTimo Tijhof <krinklemail@gmail.com>
Fri, 21 Jun 2019 20:55:53 +0000 (21:55 +0100)
committerKrinkle <krinklemail@gmail.com>
Mon, 24 Jun 2019 00:45:33 +0000 (00:45 +0000)
Follows-up 725a59f0c7.

* The real method in implementing classes is variadic.

* PHPUnit 6 on HHVM cannot create a mock for a class with a function
  that has a variadic parameter in its actual signature.
  See https://phabricator.wikimedia.org/T191668#5263929 for why.

  This is why the interface (which we use for mock creation)
  currently cannot use the variadic syntax in its signature.

* Documenting the interface as variadic while leaving the actual
  signature without it breaks stuff as well (PHPCS, Phan, ..).

* Documenting it as not variadic works for everyone, but makes
  Phan warn "PhanParamTooMany" at call sites when it is used
  as variadic (to be expected).

We can either try to disable this everywhere in repos that use
this method, but we have another option that might be cleaner.
We can document it as variadic in a way only Phan will consider
and consider only for its call-site analysis.

Hackadihack, Wickedidou, -- introducing `@phan-param`, per
<https://github.com/phan/phan/wiki/Annotating-Your-Source-Code>.

Bug: T226223
Change-Id: I33c729506c271de0f051b77d5f6aafd7a8705745

includes/libs/rdbms/database/IDatabase.php

index faed1bf..037ae99 100644 (file)
@@ -1222,6 +1222,8 @@ interface IDatabase {
         * @since 1.16
         * @param array[]|string|LikeMatch $param
         * @return string Fully built LIKE statement
+        * @phan-suppress-next-line PhanMismatchVariadicComment
+        * @phan-param array|string|LikeMatch ...$param T226223
         */
        public function buildLike( $param );