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

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners