In this part of the series, we'll start working on the definition collection process for the analyser. We'll be using the https://github.com/pxp-lang/parser since it is a superset and supports all of PHP as well as extended language features for PXP.

let files = discoverer::discover(&["php"], &["."]).unwrap(); for file in files { let contents = std::fs::read(&file).unwrap(); let ast = pxp_parser::parse(&contents).unwrap(); }

impl Visitor for DefinitionCollector { fn visit(&mut self, node: &mut dyn Node) -> Result { if let Some(BracedNamespace { name: Some(SimpleIdentifier { value,... }),... }) = downcast:: (node) { let mut namespace = ByteString::from(b"\\"); namespace.extend(&value.bytes); self.current_namespace = namespace; } else if let Some(UnbracedNamespace { name: SimpleIdentifier { value,... },... }) = downcast:: (node) { let mut namespace = ByteString::from(b"\\"); namespace.extend(&value.bytes); self.current_namespace = namespace; }

#[derive(Debug)] pub struct DefinitionCollector { current_namespace: ByteString, imported_names: Vec , collection: DefinitionCollection, } impl DefinitionCollector { pub fn new() -> Self { Self { current_namespace: ByteString::default(), imported_names: Vec::new(), collection: DefinitionCollection::default(), }}
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners