|
1 | 1 | # PHP-Parser
|
2 | 2 |
|
3 |
| -A handwritten fault-tolerant, recursive-descent parser for PHP written in Rust. |
4 |
| - |
5 |
| -[](https://justforfunnoreally.dev) |
6 |
| - |
7 |
| -> **Warning** - this is still alpha software and the public API is still subject to change. Please use at your own risk. |
8 |
| -
|
9 |
| ---- |
10 |
| - |
11 |
| -## Usage |
12 |
| - |
13 |
| -Add `php-parser-rs` in your `Cargo.toml`'s `dependencies` section |
14 |
| - |
15 |
| -```toml |
16 |
| -[dependencies] |
17 |
| -php-parser-rs = { git = "https://github.com/php-rust-tools/parser" } |
18 |
| -``` |
19 |
| - |
20 |
| -or use `cargo add` |
21 |
| - |
22 |
| -```sh |
23 |
| -cargo add php-parser-rs --git https://github.com/php-rust-tools/parser |
24 |
| -``` |
25 |
| - |
26 |
| -### Example |
27 |
| - |
28 |
| -```rust |
29 |
| -use std::io::Result; |
30 |
| - |
31 |
| -use php_parser_rs::parser; |
32 |
| - |
33 |
| -const CODE: &str = r#"<?php |
34 |
| -
|
35 |
| -final class User { |
36 |
| - public function __construct( |
37 |
| - public readonly string $name, |
38 |
| - public readonly string $email, |
39 |
| - public readonly string $password, |
40 |
| - ) { |
41 |
| - } |
42 |
| -} |
43 |
| -"#; |
44 |
| - |
45 |
| -fn main() -> Result<()> { |
46 |
| - match parser::parse(CODE) { |
47 |
| - Ok(ast) => { |
48 |
| - println!("{:#?}", ast); |
49 |
| - } |
50 |
| - Err(err) => { |
51 |
| - println!("{}", err.report(CODE, None, true, false)?); |
52 |
| - |
53 |
| - println!("parsed so far: {:#?}", err.partial); |
54 |
| - } |
55 |
| - } |
56 |
| - |
57 |
| - Ok(()) |
58 |
| -} |
59 |
| -``` |
60 |
| - |
61 |
| -## License |
62 |
| - |
63 |
| -Licensed under either of |
64 |
| - |
65 |
| - * Apache License, Version 2.0 |
66 |
| - ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) |
67 |
| - * MIT license |
68 |
| - ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) |
69 |
| - |
70 |
| -at your option. |
71 |
| - |
72 |
| -## Contribution |
73 |
| - |
74 |
| -Unless you explicitly state otherwise, any contribution intentionally submitted |
75 |
| -for inclusion in the work by you, as defined in the Apache-2.0 license, shall be |
76 |
| -dual licensed as above, without any additional terms or conditions. |
77 |
| - |
78 |
| -## Credits |
79 |
| - |
80 |
| -* [Ryan Chandler](https://github.com/ryangjchandler) |
81 |
| -* [All contributors](https://github.com/ryangjchandler/php-parser-rs/graphs/contributors) |
| 3 | +> [!WARNING] |
| 4 | +> This package has been archived and is **no longer maintained**. If you rely on this package for a project, please migrate the the PHP parser provided by the [PXP](https://github.com/pxp-lang/pxp) project. |
0 commit comments