| Age | Commit message (Collapse) | Author |
|
The Cargo.toml section-header pattern only matched single-bracket
headers, so a `[[bench]]` / `[[bin]]` / `[[test]]` table left the
previous section active and its keys were attributed to whatever
`[dependencies]` block preceded it.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
Cache::read()/write() rewrite every character outside the allowlist to
"-", so a package name containing "_" was stored and looked up under a
file name Composer never writes: the repository metadata cache was never
hit for those packages, and "vendor/foo_bar" collided with
"vendor/foo-bar". With no cached copy there is no last-modified date to
send either, so a degraded repository resolved such packages as not
found instead of serving the cached metadata.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
PHP's PREG_PATTERN_ORDER is column-oriented, but 7 of the 10 call sites
read it row-wise, rebuilding each occurrence by indexing every column at
the same offset. Return an iterator of PregMatches instead, which is also
what the set-order and offset-capture variants were carrying, so the
three functions collapse into one and PregMatchesAll,
PregMatchesAllWithOffsets, CaptureKey and preg_match_map! all go away.
The offset-capture call sites are served by the new PregMatches
get_offset/name_offset accessors.
The search stays eager: regex::Captures borrows only the subject, so the
matches outlive the pattern resolved for the call, and PHP's
preg_match_all is eager too.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
The capture groups were discarded at 162 of the preg_match call sites,
which only tested the Option. They now call preg_is_match, which lets the
regex engine skip capture tracking.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
Every call site but one passed offset 0. The remaining one, the UTF-8
chunking loop in Application, slices the subject instead: its pattern has
no anchor or lookaround, so matching a suffix is equivalent to starting
the search at that offset.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
PhpFileCleaner::clean scans for the single class/interface/trait keyword
of a one-declaration file with a pattern PHP runs anchored (`A`) one char
before the keyword. The port dropped the anchor and relied on the
leftmost match of an offset search instead, on the grounds that the
keyword sits exactly one char past the offset.
That holds for the keyword but not for the guards around it: where the
preceding char makes PCRE fail (`Foo::class`, `$class`, `->class`), the
unanchored search does not fail, it matches the next declaration further
down the file and returns the cleaned prefix cut short there. Given
<?php
namespace A {
$x = Foo::class;
}
namespace B {
class Bar {}
}
PhpFileParser::findClasses reported A\Bar where PHP reports B\Bar,
because the `namespace B {` the cleaner skipped past never reached the
parser.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
The shim carried the PCRE A (anchored) modifier alongside every compiled
pattern so preg_match2 could honour it by searching the sub-slice at the
offset. Only two call sites ever passed such a pattern, and each can cut
that slice itself, so the flag is gone from the cache, ResolvedPattern,
PregPattern and the php_regex! macro, and a pattern still carrying A is
now rejected rather than silently searched unanchored.
StringInput::tokenize and PhpFileCleaner::match search from their cursor
with a `^`-prefixed pattern instead. The rule is written down in
docs/dev/regex-porting.md.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
The two preg_match_all variants took the same arguments and differed
only in what they returned: a Vec of columns, or the named-and-numbered
PregMatchesAll. The latter is the one all but two call sites already
used, so preg_match_all2 takes over the plain PHP name and the Vec
variant goes away.
Its remaining readers only ever wanted group 0's column, which they now
take through CaptureKey::ByIndex(0); in the formatter this replaces the
array_shift that popped that column off the PREG_PATTERN_ORDER array.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
preg_match copied every group into a Vec<Option<String>> while
preg_match2 handed back the borrowed captures. They now differ only in
the offset argument, so preg_match delegates with offset 0 and its
callers read groups through PregMatches::get.
Going through preg_match2 also makes preg_match honour the PCRE A
modifier, which it used to ignore; no caller passes such a pattern.
VersionParser::manipulate_version_string takes an index accessor instead
of a slice, and VersionParser::normalize matches against a copy of the
subject because the captures outlive the assignments to $version.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
Preg had shed everything it owned: after the last few rounds its methods
were one-line forwards to the shim's preg_*(), differing only in a
default argument or a wrapper the caller unwrapped anyway. The 460 call
sites now name the shim function, and shirabe-pcre is gone from the
workspace along with its LICENSE entry.
The forwards expand as they read: isMatch becomes
preg_match2(.., 0).is_some() (is_none() where PHP negates it), isMatch3
and match3 drop the .is_some(), matchAll counts through
preg_match_all2(..).occurrence_count(), and replace4/replace5 spell out
the limit and count arguments preg_replace2 takes. Callbacks are the one
place the shapes differ: preg_replace_callback carries an error out of
the callback, so the fourteen infallible closures wrap their result in
Ok() and expect() it back.
Config::process() is the fifteenth, and it drops the `error` cell it
captured to smuggle a failure past a closure that could only return a
String. The `?` in the closure now carries it, which is what the PHP
does -- a throw from the callback leaves preg_replace_callback at the
failing match rather than running the remaining replacements and
reporting the last error.
The module doc that explained why composer/pcre's exceptions and
*StrictGroups() variants have no counterpart moves to the shim's preg
module, where the functions it describes live.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
PregMatches keyed both forms of a capture group through CaptureKey, so
every read built one: a usize wrapped in an enum, or worse, a String
allocated to name a group that regex::Captures can look up from a &str.
It now mirrors regex::Captures instead -- get() takes the group number,
name() the group name -- and the enum drops out of the type entirely.
That is 285 call sites across 59 files, and the named ones carry most of
the win: `matches.get(&CaptureKey::ByName("host".to_string()))` reads as
`matches.name("host")`. ProcessExecutor loses a `user_key` binding that
existed only to build the key once.
CaptureKey stays as the key type of PregMatchesAll and
PregMatchesAllWithOffsets, where numbered and named entries share one
IndexMap and a key type is the point. Five files still name it.
Also retargets the two preg_match_all comments that described the
occurrence count through `matches[&CaptureKey::ByIndex(0)].len()`, an
Index impl these types no longer carry.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
is_match_named and is_match_with_indexed_captures reshaped a match into
a name-keyed map or a number-positioned vec, each allocating a String
per group up front for callers that then read one or two of them. Every
one of the eleven call sites ports a plain Preg::isMatch in PHP, so they
now call is_match3 and reach for the group they want through
get(&CaptureKey::ByIndex(N)) / get(&CaptureKey::ByName(..)), the same
way the rest of the tree already reads a match.
Falling out of that: PregNamedGroups existed only to type the first
variant; PregMatches::iter() only to build both; and PregMatches::pattern
only to give iter() the capture names. PregMatches is now a plain
wrapper over regex::Captures, so preg_replace_callback no longer clones
the resolved pattern for every match, and preg_match_map! is internal to
the shim again.
SvnDriver::get_file_content and get_change_date recover the flat
`isMatch(..) && $match[2] !== null` condition the PHP has, which the vec
shape had forced into a nested if.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
Preg::match4 and Preg::replace_callback gave callers a
PregMatchedGroups: an IndexMap rebuilt from the match with an owned
String per group, plus a second String for a named group's name key.
That is the copy PregMatches shed when it started wrapping
regex::Captures, reinstated one layer up -- and nearly every regex call
in the tree goes through Preg rather than the shim's preg_* directly, so
almost nothing saw the borrow.
PregMatchedGroups existed only to drop the null (unmatched) groups the
old PregMatches held as Option<String> values. PregMatches::get reports
a non-participating group as None on its own, so the two read alike and
the type collapses into it. Call sites still reach groups through
get(&CaptureKey::ByIndex(N)); what changes is that the value arrives as
a &str borrowed from the subject, which the signatures now carry as a
lifetime.
Three places needed the borrow reckoned with rather than a mechanical
rewrite: PhpFileCleaner::clean and Problem::get_messages read their
groups out before mutating what the match borrows, and
Git::get_authentication_failure names the lifetime of its url argument,
which the result borrows instead of self.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
PregMatches was an IndexMap of owned Strings copied out of the match, so
every preg_match2/preg_replace_callback call allocated a String per
capture group (twice over for a named group) whether or not the caller
read it. It now wraps the regex::Captures itself, held alongside the
pattern it came from so groups stay reachable by both their named and
their numbered form, and hands out &str borrowed from the subject. The
subject's lifetime becomes a parameter of the type.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
`Composer\Pcre\Preg` fills `$matches` through a by-ref parameter, and the
port mirrored that with a `&mut` (or `Option<&mut>`) out-param plus a
bool or count return. Callers had to declare an empty map one line ahead
of the call, and the type never said the map is only meaningful when the
call matched. Return the matches instead:
- match3/match4/is_match3/is_match4 -> Option<PregMatchedGroups>
- is_match_named -> Option<PregNamedGroups>
- match_all2/is_match_all -> PregMatchesAll
- is_match_all_with_offsets3 -> PregMatchesAllWithOffsets
Nothing is lost: the bool is `Option::is_some()`, and the occurrence
count is the length of any one column of a PREG_PATTERN_ORDER map, now
spelled `PregMatchesAll::occurrence_count()`. is_match() still answers
the bool question directly for callers that want no groups.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
PHP fills `$matches` through a by-ref parameter, which the port mirrored
with a `&mut` out-param plus a bool or count return. Every caller then
had to declare an empty binding one line ahead of the call, and nothing
in the type said the binding is only meaningful when the call succeeded.
Return the matches instead: preg_match() and preg_match2() hand back an
Option, and the three preg_match_all* functions hand back the collection
they used to fill.
The occurrence count the two map-shaped preg_match_all* functions used
to return is the length of any one of the map's columns, so it is not
lost -- Preg::match_all() and friends derive it via occurrence_count().
preg_replace2() keeps its `count: Option<&mut usize>`: that one is not
derivable from the replaced string, and callers that do not want it pay
nothing for passing None.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
preg_match_all() and preg_match_all_set_order() were the last preg_*
functions handing back a bare Vec<String>, where a group that did not
participate is indistinguishable from one that captured "". Hand back
Option<String> as the map-shaped functions already do; php_match_row(),
the last of the truncate-then-pad helpers, goes with them.
preg_split_delim_capture() keeps its Vec<String>. preg_split() accepts
no PREG_UNMATCHED_AS_NULL, so there is no null form to move it to, and
its result interleaves split segments -- which can never be absent --
with the captured delimiters.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
The shim carried two reporting modes for the preg_* $matches maps: PHP's
default (trailing unmatched groups dropped, interior ones ""), and the
PREG_UNMATCHED_AS_NULL form, picked by calling a *_unmatched_as_null()
variant. The regex crate hands out Option<Match>, which maps onto the
null form directly, and no caller distinguished a dropped group from a
null one -- preg_match() and preg_match_all2() already reported nulls
unconditionally. Keep only the null form; the shim API no longer mirrors
PHP's flag set, which is intended.
Preg::is_match_with_indexed_captures() modelled PHP's "unset" as a
truncated Vec<String>, and now returns Vec<Option<String>>. That is what
Composer actually does: Preg::isMatch() always sets
PREG_UNMATCHED_AS_NULL, and its callers test groups with `!== null`.
preg_match_all(), preg_match_all_set_order() and
preg_split_delim_capture() still hand back Vec<String> and keep the ""
form.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
The possessive quantifiers in Symfony's tag-matching patterns only
suppress backtracking: the open-tag class excludes backslash, so giving
a character back can never let the \\. alternative or the closing >
match, and the same holds for the close-tag class and >. Removing them
is the documented port for performance-only possessive quantifiers, not
an approximation waiting on a PCRE engine.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
The five IndexMap shapes that the preg_* functions and Preg fill in are
now distinct types generated by preg_match_map!, so a matches map no
longer interchanges with any other map of the same key and value type.
Index<usize> is kept alongside Index<&Q> because call sites such as
config_command and event_dispatcher reach for a group by its position in
the map rather than by its capture key.
|
|
preg_match2() and preg_match_all_offset_capture() each become a pair over
a shared private impl, and their flags arguments are gone: no caller passed
anything but 0 or PREG_UNMATCHED_AS_NULL. Preg::match5()/is_match5() lose
their own flags argument for the same reason -- both call sites passed 0,
and the value had nowhere left to go -- so they are renumbered to
match4()/is_match4(). PREG_UNMATCHED_AS_NULL itself is now unreferenced.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
The alternation that stands in for the original conditional subpattern
reports the branch it did not take as an empty string, so `dvar` was
always present and won over `pvar`, leaving %VAR% unexpanded. `\w+`
cannot capture an empty string, so an empty branch means it did not
participate.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
Each branch of the flag is now its own function. The PREG_UNMATCHED_AS_NULL
variant needs neither the trailing-group truncation nor the empty-string
fallback, so it loses the break condition and the last_participating scan.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
Preg::match5() rejected PREG_OFFSET_CAPTURE and check_set_order() rejected
PREG_SET_ORDER, mirroring the PHP where those flags would change the type
of $matches. The Rust ports of both take a typed `matches` out-param
instead, so neither flag can reach them; check_set_order() already had no
caller. The three constants are unreferenced once the guards are gone.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
The PHP splits with PREG_SPLIT_NO_EMPTY, but the port dropped that flag,
so a leading separator in NO_PROXY kept an empty first entry. That made
"empty($hostNames) || '*' === $hostNames[0]" false for values such as
" *", turning "bypass the proxy for every host" into "use the proxy
for every host".
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
preg_split2()'s limit was always -1 and its flags were always either 0 or
PREG_SPLIT_DELIM_CAPTURE alone, so both arguments are gone: the shim now
exposes preg_split() and preg_split_delim_capture() over a shared
preg_split_impl(). That leaves Preg::split()/split4() as bare
pass-throughs, so callers use the shim functions directly and the wrappers
are dropped along with the now-unreferenced PREG_SPLIT_* constants.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
Every caller of Preg::match_all3()/is_match_all3() passed Some(&mut _),
so the argument is now a plain &mut. Preg::match_all() keeps the
no-captures form with a local throwaway map, and the arity suffixes are
renumbered accordingly (match_all2(), is_match_all()).
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
match_all5() was identical to match_all3(), and replace_impl() only
forwarded its arguments to preg_replace2(). Call the destinations
directly.
|
|
The two functions ran the same search and differed only in how they
reported a non-participating group: one as ("", 0) in a bespoke struct,
the other as (null, -1) in a capture-key map. Neither shape covered both
callers, because PHP reaches preg_match_all() with different flags from
each: Preg::matchAllWithOffsets() always ORs in PREG_UNMATCHED_AS_NULL,
while OutputFormatter::formatAndWrap() passes PREG_OFFSET_CAPTURE alone.
Keep the capture-key map, which also exposes named groups, and take the
flags that decide between null and "" for an unmatched group. The offset
is -1 either way, so the ("", 0) approximation is gone.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
PHP's Preg::matchAll() and matchAllWithOffsets() always set
PREG_UNMATCHED_AS_NULL, so a non-participating group is `null` and its
offset is -1. The Rust wrappers collapsed those to "" and 0, so callers
could not tell a group that did not participate from one that matched an
empty string at offset 0, and the offset value matched no PHP mode at
all.
Hand the shim's representation through unchanged and let each caller
mirror what the PHP original does with it: `isset()` and `(string)`
casts stay lenient, while `assert(is_string(...))` and the
*StrictGroups() variants become `expect()`.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
The sole caller, Preg::match_all_with_offsets5(), always passed flags=0
and offset=0, so PREG_UNMATCHED_AS_NULL is now unconditional and the
subject is scanned from the beginning. That method is only reached from
Preg::match_all_with_offsets(), so it is no longer public either.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
Every caller reached preg_match_all2() through Preg::match_all5(), which
always passed flags = PREG_UNMATCHED_AS_NULL and offset = 0. Inline those
constants and make match_all5() private, since the two public wrappers are
its only callers.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
Callers had to build a temporary Vec<&str> at every call site to satisfy
the &[&str] parameter. Taking IntoIterator and yielding the matched items
lets them pass owned or borrowed strings directly.
The flags variant and PREG_GREP_INVERT go away with it: no caller passes
flags, and Composer's Preg::grep() has no such parameter either.
|
|
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
|
|
preg_replace_callback2 had one caller, Preg::replace_callback6, which
was itself reached only from Preg::replace_callback with the default
limit, count and flags. Fold the two shim functions into one and drop
those parameters along with replace_callback6.
The surviving callback takes callback2's IndexMap of matches: it can be
keyed by group name, and it omits trailing non-participating groups the
way PHP does, which is what the callbacks in Process and ProgressBar
test for.
|
|
The stub token search compared every 18-byte window of the file case
insensitively. The token starts with a byte that ASCII case folding
leaves alone, so memchr can pick out the candidate offsets and leave
only those to the case-insensitive compare.
Over the 35 MB executable, finding the token in the embedded bundle
stub drops from 2.3 ms to 0.1 ms, and a scan that finds nothing drops
from 24 ms to 3.6 ms.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
Running the ignored tests shows several reasons naming a blocker the
test never reaches. The plugin hooks in all_functional_test do run, and
what stops both cases is the worker's Composer\InstalledVersions;
class_loader_test stops at include_file, not class_exists;
auth_helper_test's wrapper is ported and the blocker is trigger_error;
composerRequire is ported as __shirabe_composer_require.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
plugin_installer_test.rs carried its own copy of php_runtime_available,
lock_php_worker and load_composer_php_runtime, and the other ten files
in the binary imported them from there. The bodies matched
tests/common/php_worker.rs, so include that instead.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
AutoloadGenerator.php builds the target-dir pattern by quoting the path
with a <dirsep> marker in place of the separators, then replacing the
quoted marker with [\\/]. The port kept that shape, but preg_quote()
here deliberately leaves < and > alone so the regex crate does not read
\< as a word boundary, so the replacement never matched and the pattern
came out as the literal {^Main<dirsep>Foo<dirsep>}.
A root package's target-dir was therefore never stripped from files,
classmap or exclude-from-classmap, and dumping one failed outright.
Split on the separators and quote each segment instead, so the marker
never passes through preg_quote() at all.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
This is the type Filesystem::directory_size() actually iterates, and it
swallowed a failed stat as 0 the same way. PHP's iterator yields
\SplFileInfo there, so raise the same \RuntimeException it would.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
\SplFileInfo::getSize() throws a \RuntimeException when stat fails, and
neither Symfony's subclass nor Composer's Filesystem::directorySize()
catches it. Returning 0 turned an unreadable file into an empty one.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
PHP keeps three separate environment storages and docs/dev/env-vars-
porting.md maps each to its own shim construct. Reaching for std::env
silently picks one, so the porting target has to be chosen by reading
the PHP source rather than by whichever Rust call is at hand.
Detect var/var_os/vars/vars_os/set_var/remove_var. current_dir, args,
consts, temp_dir, current_exe and the path split/join helpers are not
environment storage and stay allowed.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
These sites have no PHP counterpart to mirror, so they read std::env
directly. Going through the shim's getenv() keeps every environment
read in one place and lets a lint forbid the direct form.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
CaBundle::getEnvVariable() prefers $_SERVER and falls back to getenv()
only under the CLI SAPI. The port read the live process environment for
both SSL_CERT_FILE and SSL_CERT_DIR, skipping the snapshot entirely.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
ProxyManager::initProxyData() reads $_SERVER[$name], a startup snapshot,
while the port read the live process environment. A putenv() issued
after startup changed the proxy the port picked but not the one PHP
would pick.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
Factory::useXdg() enumerates array_keys($_SERVER). The port enumerated
the live process environment instead, so a COMPOSER_HOME resolved
against keys the PHP side never sees.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
The signature took usize, so PHP's negative $start and $length, which
count from the end of the string, could not be expressed. Take i64 and
an optional length, and apply PHP's clamping rules.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
serialize(), var_export() and the string cast each hand-rolled
`format!("{}", f)`, which never emits PHP's exponential spelling and
carries the wrong precision for the string cast. PHP writes 1.0E+20
where Rust writes 1e20, and (string) 1/3 is 0.33333333333333, not the
shortest round-trip form.
Delegate all three to smart_str_append_double, which shirabe-php-src
already provides and shirabe-php-rpc's codec already used: precision -1
for serialize() and var_export(), 14 for the string cast.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
Rust's shortest float formatting rounds a tie away from zero where
zend_dtoa mode 0 rounds to even, so digits taken straight from `{:e}`
diverged from PHP on values such as -166050639803968.125.
Take only the digit count from `{:e}` and re-format at that fixed
precision, which rounds the exact decimal value half to even. The same
routine supplies the fixed-precision mode `php_gcvt` previously refused
with an assert, so both modes now share one path.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|