For example, if I add the following patch to CoreGenericClasses.phpstub, it doesn't give me any indication that the same class was already declared in src/Psalm/Internal/Stubs/CoreImmutableClasses.phpstub.
Ideally, it would warn, and/or combine any annotations that affect analysis. I haven't checked what would happen if a plugin registered a stub.
Obviously, in this use case, I should be adding the annotation to CoreImmutableClasses instead if I wanted to treat that as potentially unsafe, or use a plugin to modify the method after the stubs get registered.
--- a/src/Psalm/Internal/Stubs/CoreGenericClasses.phpstub
+++ b/src/Psalm/Internal/Stubs/CoreGenericClasses.phpstub
@@ -256,6 +256,19 @@ class Generator implements Traversable {
public function throw(Throwable $exception) {}
}
+class Exception implements \Throwable {
+ /**
+ * @psalm-taint-source input
+ * @return string
+ */
+ final public function getTraceAsString() {}
+ /**
+ * @psalm-taint-source input
+ * @return string
+ */
+ public function __toString() {}
+}
+
For example, if I add the following patch to CoreGenericClasses.phpstub, it doesn't give me any indication that the same class was already declared in src/Psalm/Internal/Stubs/CoreImmutableClasses.phpstub.
Ideally, it would warn, and/or combine any annotations that affect analysis. I haven't checked what would happen if a plugin registered a stub.
Obviously, in this use case, I should be adding the annotation to CoreImmutableClasses instead if I wanted to treat that as potentially unsafe, or use a plugin to modify the method after the stubs get registered.