It is really annoying that we have to escape '<' and '>'
as '\x3E' and '\x3C', otherwise Phan will not accept them
(emitting PhanUnextractableAnnotation).
Phan will also escape them in the output, generating errors like:
Argument 2 ($op) is '=<' of type '=\x3c'
but \Wikimedia\Rdbms\IDatabase::expr() takes
'!='|'='|'LIKE'|'NOT LIKE'|'\x3c'|'\x3c='|'\x3e'|'\x3e='
I've wanted to do this for a while, but I wasn't sure if it was
worth it, because the escaping makes the type hints and the errors
hard to read. Today I noticed a bug in UserSelectQueryBuilder
that would have been caught by this, and convinced myself.
Change-Id: I7a72368446f463a99b3d0cc7a90e8f7cdca454fe
In some cases ISQLPlatform::makeList() will accept an associative
array (with string keys), but ignore the keys completely. Provide a
warning when this happens, and improve type hints so that Phan warns
about it too.
(We only warn about string keys, and not about gaps in an array
with int keys, because they arise often due to using array_diff()
or array_unique(), and that would trigger too many warnings.)
In Expression we already type-hinted it as a list (int keys with no
gaps), and we're intentionally less flexible about some other cases,
so check for gaps too and throw an exception instead of a warning.
Change-Id: I63717d16eae7cccd929b5d232944b97989113b1e
In all cases, these mistakes would have already caused an error
("Wikimedia\Rdbms\Expression could not be converted to string")
or a notice ("Array to string conversion"). But now we also get
Phan warnings to avoid them, and a better message if they happen.
Add tests describing the invalid cases.
Change-Id: Idd4ba30a8145451e85018c35d5441910af76f009
I've been having fun documenting all the terrible array shapes
accepted by the various RDBMS methods with Phan type hints,
but I'm increasingly worried that either Phan will change how
it interprets them or that someone will break them by accident.
Add a test file, similar to the one we have for testing taint
annotations for Phan SecurityCheckPlugin, to guard against that.
Start filling it with some tests for expr() / Expression.
Add two missing test cases I noticed while writing these.
Change-Id: Icb54d5a7529f7f82ff5d130dcea0a22450155c10