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

davidcole1340 / ext-php-rs / 15591754978

11 Jun 2025 05:37PM CUT coverage: 21.105% (+0.2%) from 20.927%
15591754978

Pull #441

github

web-flow
Merge 8ab2451e4 into 96555c4a9
Pull Request #441: Fix SapiHeader::value when value contains a : character

1 of 1 new or added line in 1 file covered. (100.0%)

829 of 3928 relevant lines covered (21.1%)

2.05 hits per line

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

0.0
/crates/macros/src/constant.rs
1
use darling::FromAttributes;
2
use proc_macro2::TokenStream;
3
use quote::{format_ident, quote};
4
use syn::ItemConst;
5

6
use crate::helpers::get_docs;
7
use crate::parsing::PhpRename;
8
use crate::prelude::*;
9

10
const INTERNAL_CONST_DOC_PREFIX: &str = "_internal_const_docs_";
11
const INTERNAL_CONST_NAME_PREFIX: &str = "_internal_const_name_";
12

13
#[derive(FromAttributes, Default, Debug)]
14
#[darling(default, attributes(php), forward_attrs(doc))]
15
pub(crate) struct PhpConstAttribute {
16
    #[darling(flatten)]
17
    pub(crate) rename: PhpRename,
18
    // TODO: Implement const Visibility
19
    // pub(crate) vis: Option<Visibility>,
20
    pub(crate) attrs: Vec<syn::Attribute>,
21
}
22

23
pub fn parser(mut item: ItemConst) -> Result<TokenStream> {
×
24
    let attr = PhpConstAttribute::from_attributes(&item.attrs)?;
×
25

26
    let name = attr.rename.rename(item.ident.to_string());
×
27
    let name_ident = format_ident!("{INTERNAL_CONST_NAME_PREFIX}{}", item.ident);
×
28

29
    let docs = get_docs(&attr.attrs)?;
×
30
    let docs_ident = format_ident!("{INTERNAL_CONST_DOC_PREFIX}{}", item.ident);
×
31
    item.attrs.retain(|attr| !attr.path().is_ident("php"));
×
32

33
    Ok(quote! {
×
34
        #item
×
35
        #[allow(non_upper_case_globals)]
×
36
        const #docs_ident: &[&str] = &[#(#docs),*];
×
37
        #[allow(non_upper_case_globals)]
×
38
        const #name_ident: &str = #name;
×
39
    })
40
}
41

42
pub fn wrap(input: &syn::Path) -> Result<TokenStream> {
×
43
    let Some(const_name) = input.get_ident().map(ToString::to_string) else {
×
44
        bail!(input => "Pass a PHP const into `wrap_constant!()`.");
×
45
    };
46
    let doc_const = format_ident!("{INTERNAL_CONST_DOC_PREFIX}{const_name}");
×
47
    let const_name = format_ident!("{INTERNAL_CONST_NAME_PREFIX}{const_name}");
×
48

49
    Ok(quote! {
×
50
        (#const_name, #input, #doc_const)
×
51
    })
52
}
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

© 2025 Coveralls, Inc