• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

davidcole1340 / ext-php-rs / 14501981872

16 Apr 2025 08:30PM UTC coverage: 14.129% (+0.7%) from 13.479%
14501981872

push

github

web-flow
style(clippy): apply pedantic rules

Refs: #418

41 of 345 new or added lines in 46 files covered. (11.88%)

48 existing lines in 25 files now uncovered.

553 of 3914 relevant lines covered (14.13%)

1.3 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/internal/class.rs
1
use std::{collections::HashMap, marker::PhantomData};
2

3
use crate::{
4
    builders::FunctionBuilder,
5
    class::{ConstructorMeta, RegisteredClass},
6
    convert::{IntoZval, IntoZvalDyn},
7
    describe::DocComments,
8
    flags::MethodFlags,
9
    props::Property,
10
};
11

12
/// Collector used to collect methods for PHP classes.
13
pub struct PhpClassImplCollector<T: RegisteredClass>(PhantomData<T>);
14

15
impl<T: RegisteredClass> Default for PhpClassImplCollector<T> {
16
    #[inline]
17
    fn default() -> Self {
×
18
        Self(PhantomData)
×
19
    }
20
}
21

22
pub trait PhpClassImpl<T: RegisteredClass> {
23
    fn get_methods(self) -> Vec<(FunctionBuilder<'static>, MethodFlags)>;
24
    fn get_method_props<'a>(self) -> HashMap<&'static str, Property<'a, T>>;
25
    fn get_constructor(self) -> Option<ConstructorMeta<T>>;
26
    fn get_constants(self) -> &'static [(&'static str, &'static dyn IntoZvalDyn, DocComments)];
27
}
28

29
/// Default implementation for classes without an `impl` block. Classes that do
30
/// have an `impl` block will override this by implementing `PhpClassImpl` for
31
/// `PhpClassImplCollector<ClassName>` (note the missing reference). This is
32
/// `dtolnay` specialisation: <https://github.com/dtolnay/case-studies/blob/master/autoref-specialization/README.md>
33
impl<T: RegisteredClass> PhpClassImpl<T> for &'_ PhpClassImplCollector<T> {
34
    #[inline]
35
    fn get_methods(self) -> Vec<(FunctionBuilder<'static>, MethodFlags)> {
×
NEW
36
        Vec::default()
×
37
    }
38

39
    #[inline]
40
    fn get_method_props<'a>(self) -> HashMap<&'static str, Property<'a, T>> {
×
NEW
41
        HashMap::default()
×
42
    }
43

44
    #[inline]
45
    fn get_constructor(self) -> Option<ConstructorMeta<T>> {
×
NEW
46
        Option::default()
×
47
    }
48

49
    #[inline]
50
    fn get_constants(self) -> &'static [(&'static str, &'static dyn IntoZvalDyn, DocComments)] {
×
51
        &[]
×
52
    }
53
}
54

55
// This implementation is only used for `TYPE` and `NULLABLE`.
56
impl<T: RegisteredClass + IntoZval> IntoZval for PhpClassImplCollector<T> {
57
    const TYPE: crate::flags::DataType = T::TYPE;
58
    const NULLABLE: bool = T::NULLABLE;
59

60
    #[inline]
61
    fn set_zval(self, _: &mut crate::types::Zval, _: bool) -> crate::error::Result<()> {
62
        unreachable!();
63
    }
64
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc