Skip to content

Commit 90cbbc0

Browse files
authored
Specify classes as fully-qualified names in stubs (#156)
* Specify classes as fully-qualified names in stubs When stubs are generated, the type annotations don't use a loading `\`, which means they are interpreted as relative to the current namespace. That's wrong, as all types are relative to the root namespace. * rustfmt
1 parent 73902ef commit 90cbbc0

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/describe/stub.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ impl ToStub for Parameter {
153153

154154
impl ToStub for DataType {
155155
fn fmt_stub(&self, buf: &mut String) -> FmtResult {
156+
let mut fqdn = "\\".to_owned();
156157
write!(
157158
buf,
158159
"{}",
@@ -162,7 +163,10 @@ impl ToStub for DataType {
162163
DataType::Double => "float",
163164
DataType::String => "string",
164165
DataType::Array => "array",
165-
DataType::Object(Some(ty)) => ty,
166+
DataType::Object(Some(ty)) => {
167+
fqdn.push_str(ty);
168+
fqdn.as_str()
169+
}
166170
DataType::Object(None) => "object",
167171
DataType::Resource => "resource",
168172
DataType::Reference => "reference",

0 commit comments

Comments
 (0)