-
-
Notifications
You must be signed in to change notification settings - Fork 78
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Description
Description
For now all constructor generate as public, and not possibility to declare as private or protected
Use Case
Some time need declare class __construct as private or protected, and instead construct use
public static function new()or to escape from error You cannot instantiate this class from PHP.
Example
#[php_class]
struct TestClassMethodVisability;
#[php_impl]
impl TestClassMethodVisability {
#[php(vis = "private")]
fn __construct() -> Self {
Self
}
#[php(vis = "private")]
fn private() -> u32 {
3
}
#[php(vis = "protected")]
fn protected() -> u32 {
3
}
}
#[php_class]
struct TestClassProtectedConstruct;
#[php_impl]
impl TestClassProtectedConstruct {
#[php(vis = "protected")]
fn __construct() -> Self {
Self
}
}#[php_class]
struct TestClassMethodVisability;
#[php_impl]
impl TestClassMethodVisability {
#[php(vis = "private")]
fn __construct() -> Self {
Self
}
#[php(vis = "private")]
fn private() -> u32 {
3
}
#[php(vis = "protected")]
fn protected() -> u32 {
3
}
}
#[php_class]
struct TestClassProtectedConstruct;
#[php_impl]
impl TestClassProtectedConstruct {
#[php(vis = "protected")]
fn __construct() -> Self {
Self
}
}Additional Context
- I can try implementing this feature myself (please assign me to this issue)
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request