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

[stubs] missing type declarations for properties

Open ju1ius opened this issue 3 years ago • 0 comments

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

Extension code:

#[php_class]
pub struct Example {
  #[prop] pub foo: String,
  #[prop] pub bar: Option<String>,
}

#[php_impl]
impl Example {
  #[getter]
  pub fn get_baz(&self) -> Vec<bool> {
    vec![true, false]
  }
}

#[php_startup]
pub fn startup_function() {}

#[php_module]
pub fn get_module(module: ModuleBuilder) -> ModuleBuilder {
    module
}

Expected stubs:

<?php

class Example {
  public string $foo;
  public string|null $bar;
  /**
   * @var array<bool>
   */
  public readonly array $baz;
}

Actual stubs:


<?php
class Example {
  public $foo;
  public $bar;
  public $baz;
  public function getBaz(): array {}
}

ju1ius avatar Nov 15 '22 02:11 ju1ius