Add more typehints to arguments in PHP

Authored by mtijink on Jul 11 2017, 4:13 PM.


Add more typehints to arguments in PHP

In php 7.0 and php 7.1, new type hints were added. I would like to see those supported in KDevelop.

This patch adds support for most of the new type hints (only "self" is missing), but some types do not get a better resulting DUChain type, since I do not know how to add the types "iterable" and "callable" in the DUChain.

Since this is my first patch, I also have some questions, which I hope you can answer:

  • How should I add support for "self"? Adding it as a token gave all kinds of problems.
  • How should the "callable" type be represented? It should accept any kind of function, but I only saw support for types with known function signatures
  • This patch added some tokens, so they cannot be used as class names and constants anymore. This is a problem, I think, since PHP < 7 still allows e.g. "int" as class name. Another problem is that the newer keywords (e.g. "iterable", "int") can still be used as names for constants (but not for classes etc.), which is not allowed with this code either.

Feedback very welcome!

Reviewers: KDevelop, pprkut, mwolff

Reviewed By: KDevelop, pprkut, mwolff

Subscribers: mwolff, apol, kdevelop-devel

Tags: KDevelop

Differential Revision:


zhigalinJul 11 2017, 4:19 PM
Differential Revision
D6342: Add more typehints to arguments in PHP
R52:f4ec18d40a13: Remove finding WebKitWidgets, not used