Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stubs] class constants values are always null #186

Open
ju1ius opened this issue Nov 15, 2022 · 1 comment
Open

[stubs] class constants values are always null #186

ju1ius opened this issue Nov 15, 2022 · 1 comment

Comments

@ju1ius
Copy link
Contributor

ju1ius commented Nov 15, 2022

Component Version
ext_php_rs git:master
cargo-php v0.1.7

Extension code

#[php_class]
pub struct Foo;
#[php_impl]
impl Foo {
  const BAR: &'static str = "baz";
  const BAZ: i32 = 42;
}

Expected stubs:

<?php

class Foo {
  public const BAR = "baz";
  public const BAZ = 42;
}

Actual stubs:

<?php

class Foo {
  const BAR = null; 
  const BAZ = null;
}
@ju1ius
Copy link
Contributor Author

ju1ius commented Nov 17, 2022

IMO not exposing the actual value is not that much of an issue. Exposing a public constant in an api is meant to provide an abstraction over a value that may change between releases.

The issue is more about not exposing the actual type.
So it wouldn't matter if i.e. const FOO: u8 = 42 became const FOO = 0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant