ext-php-rs icon indicating copy to clipboard operation
ext-php-rs copied to clipboard

[stubs] class constants values are always null

Open ju1ius opened this issue 2 years ago • 1 comments

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 avatar Nov 15 '22 02:11 ju1ius

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.

ju1ius avatar Nov 17 '22 15:11 ju1ius