Skip to content

Commit 39435bc

Browse files
committed
Adapt
1 parent 660f652 commit 39435bc

File tree

5 files changed

+23
-11
lines changed

5 files changed

+23
-11
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phper-doc/Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,11 @@ phper = { workspace = true }
2525
[dev-dependencies]
2626
thiserror = "2.0.11"
2727
reqwest = { version = "0.12.12", features = ["blocking", "cookies"] }
28+
29+
[build-dependencies]
30+
phper-build = { workspace = true }
31+
32+
[lints.rust]
33+
unexpected_cfgs = { level = "warn", check-cfg = [
34+
'cfg(phper_enum_supported)',
35+
] }

phper-doc/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ pub mod _06_module {
7070
#[doc = include_str!("../doc/_06_module/_07_register_interface/index.md")]
7171
pub mod _07_register_interface {}
7272

73+
#[cfg(phper_enum_supported)]
7374
#[doc = include_str!("../doc/_06_module/_08_register_enum/index.md")]
7475
pub mod _08_register_enum {}
7576
}

phper/src/modules.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use crate::{
1414
classes::{ClassEntity, Interface, InterfaceEntity, StateClass},
1515
constants::Constant,
16-
enums::EnumEntity,
1716
errors::Throwable,
1817
functions::{Function, FunctionEntity, FunctionEntry, HandlerMap},
1918
ini,
@@ -62,6 +61,7 @@ unsafe extern "C" fn module_startup(_type: c_int, module_number: c_int) -> c_int
6261
module.handler_map.extend(class_entity.handler_map());
6362
}
6463

64+
#[cfg(phper_enum_supported)]
6565
for enum_entity in &module.enum_entities {
6666
enum_entity.init();
6767
module.handler_map.extend(enum_entity.handler_map());
@@ -146,7 +146,8 @@ pub struct Module {
146146
function_entities: Vec<FunctionEntity>,
147147
class_entities: Vec<ClassEntity<()>>,
148148
interface_entities: Vec<InterfaceEntity>,
149-
enum_entities: Vec<EnumEntity<()>>,
149+
#[cfg(phper_enum_supported)]
150+
enum_entities: Vec<crates::enums::EnumEntity<()>>,
150151
constants: Vec<Constant>,
151152
ini_entities: Vec<ini::IniEntity>,
152153
infos: HashMap<CString, CString>,
@@ -170,6 +171,7 @@ impl Module {
170171
function_entities: vec![],
171172
class_entities: Default::default(),
172173
interface_entities: Default::default(),
174+
#[cfg(phper_enum_supported)]
173175
enum_entities: Default::default(),
174176
constants: Default::default(),
175177
ini_entities: Default::default(),

tests/integration/tests/php/enums.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,21 @@
2929
assert_eq(IntegrationTest\PureEnum::getDescription(), 'Pure enum implementation', 'PureEnum::getDescription() should return proper value');
3030

3131
// Test direct access to enum members
32-
assert_eq(IntegrationTest\PureEnum::ONE->name, 'ONE');
33-
assert_eq(IntegrationTest\PureEnum::TWO->name, 'TWO');
34-
assert_eq(IntegrationTest\PureEnum::THREE->name, 'THREE');
32+
assert_eq((IntegrationTest\PureEnum::ONE)->name, 'ONE');
33+
assert_eq((IntegrationTest\PureEnum::TWO)->name, 'TWO');
34+
assert_eq((IntegrationTest\PureEnum::THREE)->name, 'THREE');
3535

3636
// Test int-backed enum
3737
assert_true(enum_exists('IntegrationTest\IntEnum'), 'IntEnum should exist');
38-
assert_eq(IntegrationTest\IntEnum::LOW->value, 1, 'IntEnum::LOW value should be 1');
39-
assert_eq(IntegrationTest\IntEnum::MEDIUM->value, 5, 'IntEnum::MEDIUM value should be 5');
40-
assert_eq(IntegrationTest\IntEnum::HIGH->value, 10, 'IntEnum::HIGH value should be 10');
38+
assert_eq((IntegrationTest\IntEnum::LOW)->value, 1, 'IntEnum::LOW value should be 1');
39+
assert_eq((IntegrationTest\IntEnum::MEDIUM)->value, 5, 'IntEnum::MEDIUM value should be 5');
40+
assert_eq((IntegrationTest\IntEnum::HIGH)->value, 10, 'IntEnum::HIGH value should be 10');
4141

4242
// Test string-backed enum
4343
assert_true(enum_exists('IntegrationTest\StringEnum'), 'StringEnum should exist');
44-
assert_eq(IntegrationTest\StringEnum::RED->value, 'FF0000', 'StringEnum::RED value should be FF0000');
45-
assert_eq(IntegrationTest\StringEnum::GREEN->value, '00FF00', 'StringEnum::GREEN value should be 00FF00');
46-
assert_eq(IntegrationTest\StringEnum::BLUE->value, '0000FF', 'StringEnum::BLUE value should be 0000FF');
44+
assert_eq((IntegrationTest\StringEnum::RED)->value, 'FF0000', 'StringEnum::RED value should be FF0000');
45+
assert_eq((IntegrationTest\StringEnum::GREEN)->value, '00FF00', 'StringEnum::GREEN value should be 00FF00');
46+
assert_eq((IntegrationTest\StringEnum::BLUE)->value, '0000FF', 'StringEnum::BLUE value should be 0000FF');
4747

4848
// Test reflection API
4949
$reflection = new ReflectionEnum(IntegrationTest\StringEnum::class);

0 commit comments

Comments
 (0)