aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-php-src/src/lib.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-08-01 04:52:50 +0900
committernsfisis <nsfisis@gmail.com>2026-08-01 04:52:50 +0900
commitb8d46b0495d00815a699932ced0b43955c949ab9 (patch)
tree17c340f51cbf259ea631ca7da7549714c91b916f /crates/shirabe-php-src/src/lib.rs
parent8e8a3c147aa388c4b0fc021a08b30113eb590727 (diff)
downloadphp-shirabe-b8d46b0495d00815a699932ced0b43955c949ab9.tar.gz
php-shirabe-b8d46b0495d00815a699932ced0b43955c949ab9.tar.zst
php-shirabe-b8d46b0495d00815a699932ced0b43955c949ab9.zip
feat(php-src): add a BSD-licensed crate for php-src derived code
The audit in .ken/php-shim-copying.md judged 14 functions in shirabe-php-shim (plus php_wordwrap in shirabe-external-packages) to be line-by-line transcriptions or structural imitations of php-src. PHP's relicensing to 3-clause BSD makes keeping them legal, but the boundary between BSD-derived and MIT code was invisible in the source tree. Moving them into their own crate puts the license into the build metadata (so NOTICE generation follows the binary), makes a reverse dependency a compile error, and encodes the origin in the module path, which mirrors php-src's ext tree. Each function records its origin in a fixed-format doc comment, and a new php_src_derivation_boundary linter fails if `php-src` appears in any Rust source outside the crate. Public paths under shirabe_php_shim:: are unchanged: functions that are themselves derived are re-exported with `pub use`, and the wrappers that only validate arguments stay on the MIT side. This also resolves the duplicate wordwrap implementation. shirabe_php_shim::wordwrap was todo!(), so SymfonyStyle::block panicked, while shirabe-external-packages carried its own copy. Both now go through the single port, verified against real PHP on 13 cases covering multi-character breaks and cut. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe-php-src/src/lib.rs')
-rw-r--r--crates/shirabe-php-src/src/lib.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/crates/shirabe-php-src/src/lib.rs b/crates/shirabe-php-src/src/lib.rs
new file mode 100644
index 00000000..1e2c2a0f
--- /dev/null
+++ b/crates/shirabe-php-src/src/lib.rs
@@ -0,0 +1,19 @@
+//! Rust port from the original C implementation in php-src.
+//! See `LICENSE.md` at the repository root.
+//!
+//! Rules for this crate:
+//!
+//! * Any code written while looking at php-src belongs here, and nowhere else. `shirabe-php-shim`
+//! must not contain php-src derived code; it depends on this crate instead.
+//! * The dependency direction is `shirabe-php-shim` -> `shirabe-php-src` only. This crate must not
+//! depend on any other crate in the workspace, so that BSD-derived code cannot pull in
+//! MIT-licensed types.
+//! * The module layout mirrors php-src's own tree (`src/standard/string.rs` holds code derived
+//! from `ext/standard/string.c`), so the origin of a function is visible from its path.
+//! * Every item carries a fixed-format origin comment:
+//!
+//! ```text
+//! /// php-src: ext/standard/strnatcmp.c `strnatcmp_ex` (PHP 8.5.2)
+//! ```
+
+pub mod standard;