aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-08-18 01:57:02 +0900
committernsfisis <nsfisis@gmail.com>2026-08-18 01:57:02 +0900
commitfed0a6e7ac361af9b963c1f62411b1a85478230c (patch)
tree5cde64a24845c761890fbcbe05e0d702f1ec8df7 /crates
parente093b2be1c333e67c96aebb0a5291bea9ae3d6db (diff)
downloadphp-shirabe-fed0a6e7ac361af9b963c1f62411b1a85478230c.tar.gz
php-shirabe-fed0a6e7ac361af9b963c1f62411b1a85478230c.tar.zst
php-shirabe-fed0a6e7ac361af9b963c1f62411b1a85478230c.zip
refactor(preg): add preg_is_match for existence-only call sites
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>
Diffstat (limited to 'crates')
-rw-r--r--crates/shirabe-class-map-generator/src/class_map.rs4
-rw-r--r--crates/shirabe-class-map-generator/src/class_map_generator.rs13
-rw-r--r--crates/shirabe-php-shim/src/preg.rs8
-rw-r--r--crates/shirabe-semver/src/version_parser.rs24
-rw-r--r--crates/shirabe-symfony-console/src/command/command.rs4
-rw-r--r--crates/shirabe-symfony-console/src/helper/helper.rs6
-rw-r--r--crates/shirabe-symfony-console/src/helper/table.rs7
-rw-r--r--crates/shirabe-symfony-console/src/input/input.rs4
-rw-r--r--crates/shirabe-symfony-console/src/output/stream_output.rs5
-rw-r--r--crates/shirabe-symfony-console/src/question/choice_question.rs8
-rw-r--r--crates/shirabe-symfony-console/src/question/confirmation_question.rs4
-rw-r--r--crates/shirabe-symfony-finder/src/finder.rs14
-rw-r--r--crates/shirabe-symfony-process/src/process.rs4
-rw-r--r--crates/shirabe/src/advisory/auditor.rs5
-rw-r--r--crates/shirabe/src/autoload/autoload_generator.rs8
-rw-r--r--crates/shirabe/src/cache.rs7
-rw-r--r--crates/shirabe/src/command/bump_command.rs4
-rw-r--r--crates/shirabe/src/command/completion_trait.rs10
-rw-r--r--crates/shirabe/src/command/config_command.rs17
-rw-r--r--crates/shirabe/src/command/init_command.rs21
-rw-r--r--crates/shirabe/src/command/package_discovery_trait.rs6
-rw-r--r--crates/shirabe/src/command/reinstall_command.rs4
-rw-r--r--crates/shirabe/src/command/repository_command.rs6
-rw-r--r--crates/shirabe/src/command/show_command.rs12
-rw-r--r--crates/shirabe/src/command/update_command.rs8
-rw-r--r--crates/shirabe/src/composer.rs6
-rw-r--r--crates/shirabe/src/config.rs12
-rw-r--r--crates/shirabe/src/dependency_resolver/lock_transaction.rs11
-rw-r--r--crates/shirabe/src/dependency_resolver/pool_builder.rs8
-rw-r--r--crates/shirabe/src/dependency_resolver/problem.rs10
-rw-r--r--crates/shirabe/src/downloader/download_manager.rs6
-rw-r--r--crates/shirabe/src/downloader/fossil_downloader.rs4
-rw-r--r--crates/shirabe/src/downloader/git_downloader.rs21
-rw-r--r--crates/shirabe/src/downloader/svn_downloader.rs20
-rw-r--r--crates/shirabe/src/event_dispatcher/event_dispatcher.rs10
-rw-r--r--crates/shirabe/src/filter/platform_requirement_filter/ignore_list_platform_requirement_filter.rs11
-rw-r--r--crates/shirabe/src/io/base_io.rs5
-rw-r--r--crates/shirabe/src/json/json_file.rs6
-rw-r--r--crates/shirabe/src/json/json_manipulator.rs16
-rw-r--r--crates/shirabe/src/package/archiver/archive_manager.rs4
-rw-r--r--crates/shirabe/src/package/archiver/base_exclude_filter.rs4
-rw-r--r--crates/shirabe/src/package/loader/array_loader.rs6
-rw-r--r--crates/shirabe/src/package/loader/root_package_loader.rs6
-rw-r--r--crates/shirabe/src/package/loader/validating_array_loader.rs22
-rw-r--r--crates/shirabe/src/package/locker.rs5
-rw-r--r--crates/shirabe/src/package/package.rs14
-rw-r--r--crates/shirabe/src/package/version/version_bumper.rs4
-rw-r--r--crates/shirabe/src/package/version/version_guesser.rs23
-rw-r--r--crates/shirabe/src/package/version/version_parser.rs5
-rw-r--r--crates/shirabe/src/package/version/version_selector.rs6
-rw-r--r--crates/shirabe/src/plugin/plugin_manager.rs8
-rw-r--r--crates/shirabe/src/question/strict_confirmation_question.rs6
-rw-r--r--crates/shirabe/src/repository/array_repository.rs9
-rw-r--r--crates/shirabe/src/repository/composer_repository.rs8
-rw-r--r--crates/shirabe/src/repository/filter_repository.rs6
-rw-r--r--crates/shirabe/src/repository/path_repository.rs6
-rw-r--r--crates/shirabe/src/repository/platform_repository.rs6
-rw-r--r--crates/shirabe/src/repository/vcs/fossil_driver.rs10
-rw-r--r--crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs8
-rw-r--r--crates/shirabe/src/repository/vcs/git_driver.rs14
-rw-r--r--crates/shirabe/src/repository/vcs/github_driver.rs8
-rw-r--r--crates/shirabe/src/repository/vcs/gitlab_driver.rs4
-rw-r--r--crates/shirabe/src/repository/vcs/hg_driver.rs9
-rw-r--r--crates/shirabe/src/repository/vcs/perforce_driver.rs6
-rw-r--r--crates/shirabe/src/repository/vcs/svn_driver.rs8
-rw-r--r--crates/shirabe/src/repository/vcs/vcs_driver.rs6
-rw-r--r--crates/shirabe/src/repository/vcs_repository.rs6
-rw-r--r--crates/shirabe/src/self_update/versions.rs4
-rw-r--r--crates/shirabe/src/util/auth_helper.rs4
-rw-r--r--crates/shirabe/src/util/composer_mirror.rs4
-rw-r--r--crates/shirabe/src/util/config_validator.rs13
-rw-r--r--crates/shirabe/src/util/filesystem.rs22
-rw-r--r--crates/shirabe/src/util/git.rs32
-rw-r--r--crates/shirabe/src/util/github.rs6
-rw-r--r--crates/shirabe/src/util/http/curl_downloader.rs7
-rw-r--r--crates/shirabe/src/util/http/response.rs4
-rw-r--r--crates/shirabe/src/util/http_downloader.rs6
-rw-r--r--crates/shirabe/src/util/platform.rs4
-rw-r--r--crates/shirabe/src/util/process_executor.rs15
-rw-r--r--crates/shirabe/src/util/remote_filesystem.rs17
-rw-r--r--crates/shirabe/src/util/url.rs4
-rw-r--r--crates/shirabe/tests/common/io_mock.rs4
-rw-r--r--crates/shirabe/tests/dependency_resolver/pool_builder_test.rs4
-rw-r--r--crates/shirabe/tests/dependency_resolver/pool_optimizer_test.rs4
-rw-r--r--crates/shirabe/tests/installer_test.rs6
85 files changed, 357 insertions, 389 deletions
diff --git a/crates/shirabe-class-map-generator/src/class_map.rs b/crates/shirabe-class-map-generator/src/class_map.rs
index 1d980129..4870d481 100644
--- a/crates/shirabe-class-map-generator/src/class_map.rs
+++ b/crates/shirabe-class-map-generator/src/class_map.rs
@@ -1,7 +1,7 @@
//! ref: composer/vendor/composer/class-map-generator/src/ClassMap.php
use indexmap::IndexMap;
-use shirabe_php_shim::{OutOfBoundsException, preg_match, rtrim, strpos, strtr};
+use shirabe_php_shim::{OutOfBoundsException, preg_is_match, rtrim, strpos, strtr};
#[derive(Debug, Clone)]
pub struct PsrViolationEntry {
@@ -66,7 +66,7 @@ impl ClassMap {
for (class, paths) in &self.ambiguous_classes {
let paths: Vec<String> = paths
.iter()
- .filter(|path| preg_match(duplicates_filter, &strtr(path, "\\", "/")).is_none())
+ .filter(|path| !preg_is_match(duplicates_filter, &strtr(path, "\\", "/")))
.cloned()
.collect();
if !paths.is_empty() {
diff --git a/crates/shirabe-class-map-generator/src/class_map_generator.rs b/crates/shirabe-class-map-generator/src/class_map_generator.rs
index da2f62c5..254e3a3f 100644
--- a/crates/shirabe-class-map-generator/src/class_map_generator.rs
+++ b/crates/shirabe-class-map-generator/src/class_map_generator.rs
@@ -5,9 +5,9 @@ use crate::file_list::FileList;
use crate::php_file_parser::PhpFileParser;
use shirabe_php_shim::{
InvalidArgumentException, LogicException, PATHINFO_EXTENSION, RuntimeException, explode,
- getcwd, implode, is_dir, is_file, pathinfo, php_regex, preg_match, preg_quote, preg_replace,
- preg_replace_callback, realpath, str_replace, stream_get_wrappers, strlen, strpos, strrpos,
- strtr, substr,
+ getcwd, implode, is_dir, is_file, pathinfo, php_regex, preg_is_match, preg_match, preg_quote,
+ preg_replace, preg_replace_callback, realpath, str_replace, stream_get_wrappers, strlen,
+ strpos, strrpos, strtr, substr,
};
use shirabe_symfony_finder::Finder;
use std::path::PathBuf;
@@ -134,8 +134,7 @@ impl ClassMapGenerator {
continue;
}
- let is_stream_wrapper_path =
- preg_match(&self.stream_wrappers_regex, &file_path).is_some();
+ let is_stream_wrapper_path = preg_is_match(&self.stream_wrappers_regex, &file_path);
if !Self::is_absolute_path(&file_path) && !is_stream_wrapper_path {
file_path = format!("{}/{}", cwd, file_path);
file_path = Self::normalize_path(&file_path);
@@ -183,11 +182,11 @@ impl ClassMapGenerator {
// check the realpath of the file against the excluded paths as the path might be a symlink and the excluded path is realpath'd so symlink are resolved
if let Some(ref excluded) = excluded {
- if preg_match(excluded, &strtr(&real_path, "\\", "/")).is_some() {
+ if preg_is_match(excluded, &strtr(&real_path, "\\", "/")) {
continue;
}
// check non-realpath of file for directories symlink in project dir
- if preg_match(excluded, &strtr(&file_path, "\\", "/")).is_some() {
+ if preg_is_match(excluded, &strtr(&file_path, "\\", "/")) {
continue;
}
}
diff --git a/crates/shirabe-php-shim/src/preg.rs b/crates/shirabe-php-shim/src/preg.rs
index d36d61c7..c4060a34 100644
--- a/crates/shirabe-php-shim/src/preg.rs
+++ b/crates/shirabe-php-shim/src/preg.rs
@@ -149,6 +149,14 @@ pub fn preg_quote(str: &str, delimiter: Option<char>) -> String {
out
}
+// Whether the pattern matches, for the call sites that ignore the capture groups.
+pub fn preg_is_match(pattern: impl PregPattern, subject: &str) -> bool {
+ let __resolved = pattern.resolve();
+ let re = __resolved.regex();
+
+ re.is_match(subject)
+}
+
// Returns None if the pattern did not match; otherwise the match's capture groups.
pub fn preg_match<'h>(pattern: impl PregPattern, subject: &'h str) -> Option<PregMatches<'h>> {
let __resolved = pattern.resolve();
diff --git a/crates/shirabe-semver/src/version_parser.rs b/crates/shirabe-semver/src/version_parser.rs
index 79c368bb..8d86de2e 100644
--- a/crates/shirabe-semver/src/version_parser.rs
+++ b/crates/shirabe-semver/src/version_parser.rs
@@ -4,7 +4,9 @@ use crate::constraint::AnyConstraint;
use crate::constraint::MatchAllConstraint;
use crate::constraint::MultiConstraint;
use crate::constraint::SimpleConstraint;
-use shirabe_php_shim::{php_regex, preg_match, preg_quote, preg_replace, preg_split};
+use shirabe_php_shim::{
+ php_regex, preg_is_match, preg_match, preg_quote, preg_replace, preg_split,
+};
// Regex to match pre-release data (sort of).
//
@@ -194,30 +196,26 @@ impl VersionParser {
}
}
- let extra_message = if preg_match(
+ let extra_message = if preg_is_match(
format!(
"{{ +as +{}(?:@(?:{}))?$}}",
preg_quote(&version, None),
STABILITIES_REGEX
),
&full_version,
- )
- .is_some()
- {
+ ) {
format!(
" in \"{}\", the alias must be an exact version",
full_version
)
- } else if preg_match(
+ } else if preg_is_match(
format!(
"{{^{}(?:@(?:{}))? +as +}}",
preg_quote(&version, None),
STABILITIES_REGEX
),
&full_version,
- )
- .is_some()
- {
+ ) {
format!(
" in \"{}\", the alias source must be an exact version, if it is a branch name \
you should prefix it with dev-",
@@ -615,7 +613,7 @@ impl VersionParser {
// dev-foobar except if the constraint uses a known operator, in which
// case it must be a parse error
if version_str.ends_with("-dev")
- && preg_match(php_regex!("{^[0-9a-zA-Z-./]+$}"), &version_str).is_some()
+ && preg_is_match(php_regex!("{^[0-9a-zA-Z-./]+$}"), &version_str)
{
self.normalize(
&format!("dev-{}", &version_str[..version_str.len() - 4]),
@@ -640,12 +638,10 @@ impl VersionParser {
}
if op == "<" || op == ">=" {
let modifier_pattern = format!("{{-{}$}}", MODIFIER_REGEX);
- if preg_match(
+ if !preg_is_match(
&modifier_pattern,
&shirabe_php_shim::strtolower(&version_str),
- )
- .is_none()
- && !version_str.starts_with("dev-")
+ ) && !version_str.starts_with("dev-")
{
version = format!("{}-dev", version);
}
diff --git a/crates/shirabe-symfony-console/src/command/command.rs b/crates/shirabe-symfony-console/src/command/command.rs
index 848cece3..27966ec1 100644
--- a/crates/shirabe-symfony-console/src/command/command.rs
+++ b/crates/shirabe-symfony-console/src/command/command.rs
@@ -11,7 +11,7 @@ use crate::input::InputInterface;
use crate::input::InputOption;
use crate::output::OutputInterface;
use indexmap::IndexMap;
-use shirabe_php_shim::{PhpMixed, php_regex, preg_match};
+use shirabe_php_shim::{PhpMixed, php_regex, preg_is_match};
use std::cell::{Cell, Ref};
/// The base-class state of the PHP `Command` class.
@@ -108,7 +108,7 @@ impl CommandData {
///
/// Throws InvalidArgumentException when the name is invalid.
fn validate_name(&self, name: &str) -> anyhow::Result<Result<(), InvalidArgumentException>> {
- if preg_match(php_regex!(r"/^[^\:]++(\:[^\:]++)*$/"), name).is_none() {
+ if !preg_is_match(php_regex!(r"/^[^\:]++(\:[^\:]++)*$/"), name) {
return Ok(Err(InvalidArgumentException::new(format!(
"Command name \"{}\" is invalid.",
name
diff --git a/crates/shirabe-symfony-console/src/helper/helper.rs b/crates/shirabe-symfony-console/src/helper/helper.rs
index 435648ca..a740964a 100644
--- a/crates/shirabe-symfony-console/src/helper/helper.rs
+++ b/crates/shirabe-symfony-console/src/helper/helper.rs
@@ -2,7 +2,7 @@
use crate::formatter::OutputFormatterInterface;
use crate::helper::HelperSet;
-use shirabe_php_shim::{php_regex, preg_match, preg_replace};
+use shirabe_php_shim::{php_regex, preg_is_match, preg_replace};
use shirabe_symfony_string::unicode_string::UnicodeString;
/// Helper is the base class for all helper classes.
@@ -40,7 +40,7 @@ impl Helper {
/// Returns the width of a string, using mb_strwidth if it is available.
/// The width is how many characters positions the string will use.
pub fn width(string: &str) -> i64 {
- if preg_match(php_regex!("//u"), string).is_some() {
+ if preg_is_match(php_regex!("//u"), string) {
return UnicodeString::new(string).width(false);
}
@@ -56,7 +56,7 @@ impl Helper {
/// Returns the length of a string, using mb_strlen if it is available.
/// The length is related to how many bytes the string will use.
pub fn length(string: &str) -> i64 {
- if preg_match(php_regex!("//u"), string).is_some() {
+ if preg_is_match(php_regex!("//u"), string) {
return UnicodeString::new(string).length();
}
diff --git a/crates/shirabe-symfony-console/src/helper/table.rs b/crates/shirabe-symfony-console/src/helper/table.rs
index 777f44c7..e9ea12c8 100644
--- a/crates/shirabe-symfony-console/src/helper/table.rs
+++ b/crates/shirabe-symfony-console/src/helper/table.rs
@@ -8,7 +8,7 @@ use crate::helper::{
};
use crate::output::OutputInterface;
use indexmap::IndexMap;
-use shirabe_php_shim::{PhpMixed, php_regex, preg_match};
+use shirabe_php_shim::{PhpMixed, php_regex, preg_is_match};
/// A single cell within a table row.
///
@@ -655,11 +655,10 @@ impl Table {
let mut cell_format = cell_format;
let mut pad_type = style.get_pad_type();
if cell.is_table_cell() && cell.style().is_some() {
- let is_not_styled_by_tag = preg_match(
+ let is_not_styled_by_tag = !preg_is_match(
php_regex!("/^<(\\w+|(\\w+=[\\w,]+;?)*)>.+<\\/(\\w+|(\\w+=\\w+;?)*)?>$/"),
&cell_str,
- )
- .is_none();
+ );
if is_not_styled_by_tag {
let cell_style = cell.style().unwrap();
match cell_style.get_cell_format() {
diff --git a/crates/shirabe-symfony-console/src/input/input.rs b/crates/shirabe-symfony-console/src/input/input.rs
index 4712a713..88bb9f94 100644
--- a/crates/shirabe-symfony-console/src/input/input.rs
+++ b/crates/shirabe-symfony-console/src/input/input.rs
@@ -4,7 +4,7 @@ use crate::exception::InvalidArgumentException;
use crate::exception::RuntimeException;
use crate::input::InputDefinition;
use indexmap::IndexMap;
-use shirabe_php_shim::{PhpMixed, PhpResource, php_regex, preg_match};
+use shirabe_php_shim::{PhpMixed, PhpResource, php_regex, preg_is_match};
/// Input is the base class for all concrete Input classes.
///
@@ -207,7 +207,7 @@ impl Input {
/// Escapes a token through escapeshellarg if it contains unsafe chars.
pub fn escape_token(&self, token: &str) -> String {
- if preg_match(php_regex!("{^[\\w-]+$}"), token).is_some() {
+ if preg_is_match(php_regex!("{^[\\w-]+$}"), token) {
token.to_string()
} else {
shirabe_php_shim::escapeshellarg(token)
diff --git a/crates/shirabe-symfony-console/src/output/stream_output.rs b/crates/shirabe-symfony-console/src/output/stream_output.rs
index 14565012..0d59fe2c 100644
--- a/crates/shirabe-symfony-console/src/output/stream_output.rs
+++ b/crates/shirabe-symfony-console/src/output/stream_output.rs
@@ -5,7 +5,7 @@ use crate::formatter::OutputFormatterInterface;
use crate::output::OutputInterface;
use crate::output::VERBOSITY_NORMAL;
use crate::output::{DoWrite, Output};
-use shirabe_php_shim::{php_regex, preg_match};
+use shirabe_php_shim::{php_regex, preg_is_match};
/// StreamOutput writes the output to a given stream.
///
@@ -120,13 +120,12 @@ impl StreamOutput {
}
// See https://github.com/chalk/supports-color/blob/d4f413efaf8da045c5ab440ed418ef02dbb28bf1/index.js#L157
- preg_match(
+ preg_is_match(
php_regex!(
"/^((screen|xterm|vt100|vt220|putty|rxvt|ansi|cygwin|linux).*)|(.*-256(color)?(-bce)?)$/"
),
&term,
)
- .is_some()
}
}
diff --git a/crates/shirabe-symfony-console/src/question/choice_question.rs b/crates/shirabe-symfony-console/src/question/choice_question.rs
index 84cba360..a29fdf2a 100644
--- a/crates/shirabe-symfony-console/src/question/choice_question.rs
+++ b/crates/shirabe-symfony-console/src/question/choice_question.rs
@@ -5,7 +5,7 @@ use crate::exception::LogicException;
use crate::question::Question;
use crate::question::QuestionInterface;
use indexmap::IndexMap;
-use shirabe_php_shim::{PhpMixed, php_regex, preg_match};
+use shirabe_php_shim::{PhpMixed, php_regex, preg_is_match};
/// Represents a choice question.
#[derive(Debug)]
@@ -122,12 +122,10 @@ impl ChoiceQuestion {
let selected_choices: Vec<PhpMixed> = if multiselect {
// Check for a separated comma values
- if preg_match(
+ if !preg_is_match(
php_regex!("/^[^,]+(?:,[^,]+)*$/"),
&shirabe_php_shim::strval(&selected),
- )
- .is_none()
- {
+ ) {
return Err(InvalidArgumentException::new(shirabe_php_shim::sprintf(
&error_message,
std::slice::from_ref(&selected),
diff --git a/crates/shirabe-symfony-console/src/question/confirmation_question.rs b/crates/shirabe-symfony-console/src/question/confirmation_question.rs
index 5a18a045..6b8eb389 100644
--- a/crates/shirabe-symfony-console/src/question/confirmation_question.rs
+++ b/crates/shirabe-symfony-console/src/question/confirmation_question.rs
@@ -3,7 +3,7 @@
use crate::exception::InvalidArgumentException;
use crate::question::Question;
use crate::question::QuestionInterface;
-use shirabe_php_shim::{PhpMixed, preg_match};
+use shirabe_php_shim::{PhpMixed, preg_is_match};
/// Represents a yes/no question.
#[derive(Debug)]
@@ -38,7 +38,7 @@ impl ConfirmationQuestion {
return answer;
}
- let answer_is_true = preg_match(&regex, &shirabe_php_shim::strval(&answer)).is_some();
+ let answer_is_true = preg_is_match(&regex, &shirabe_php_shim::strval(&answer));
// false === $default
if matches!(default, PhpMixed::Bool(false)) {
diff --git a/crates/shirabe-symfony-finder/src/finder.rs b/crates/shirabe-symfony-finder/src/finder.rs
index b32418db..fa29a3a7 100644
--- a/crates/shirabe-symfony-finder/src/finder.rs
+++ b/crates/shirabe-symfony-finder/src/finder.rs
@@ -9,7 +9,9 @@
use crate::glob::Glob;
use chrono::{NaiveDate, NaiveDateTime};
use indexmap::IndexSet;
-use shirabe_php_shim::{file_exists, glob, is_dir, php_regex, preg_match, preg_quote, rtrim};
+use shirabe_php_shim::{
+ file_exists, glob, is_dir, php_regex, preg_is_match, preg_match, preg_quote, rtrim,
+};
use std::path::{Path, PathBuf};
use std::time::UNIX_EPOCH;
@@ -310,7 +312,7 @@ impl Finder {
let dir = rtrim(dir, Some("/"));
- if preg_match(php_regex!("#^(ssh2\\.)?s?ftp://#"), &dir).is_some() {
+ if preg_is_match(php_regex!("#^(ssh2\\.)?s?ftp://#"), &dir) {
format!("{dir}/")
} else {
dir
@@ -591,7 +593,7 @@ fn exclude_accept(
};
let path = path.replace('\\', "/");
- return preg_match(pattern, &path).is_none();
+ return !preg_is_match(pattern, &path);
}
true
@@ -618,14 +620,14 @@ fn to_regex_path(pattern: &str) -> String {
/// `MultiplePcreFilterIterator::isAccepted`.
fn is_accepted(string: &str, match_regexps: &[String], nomatch_regexps: &[String]) -> bool {
for regex in nomatch_regexps {
- if preg_match(regex, string).is_some() {
+ if preg_is_match(regex, string) {
return false;
}
}
if !match_regexps.is_empty() {
for regex in match_regexps {
- if preg_match(regex, string).is_some() {
+ if preg_is_match(regex, string) {
return true;
}
}
@@ -655,7 +657,7 @@ fn is_regex(str: &str) -> bool {
.unwrap_or_default();
if start == end {
- return preg_match(php_regex!("/[*?[:alnum:] \\\\]/"), &start).is_none();
+ return !preg_is_match(php_regex!("/[*?[:alnum:] \\\\]/"), &start);
}
for (open, close) in [("{", "}"), ("(", ")"), ("[", "]"), ("<", ">")] {
diff --git a/crates/shirabe-symfony-process/src/process.rs b/crates/shirabe-symfony-process/src/process.rs
index 6a42d263..991bdd08 100644
--- a/crates/shirabe-symfony-process/src/process.rs
+++ b/crates/shirabe-symfony-process/src/process.rs
@@ -12,7 +12,7 @@ use crate::pipes::windows_pipes::WindowsPipes;
use crate::process_utils::ProcessUtils;
use indexmap::IndexMap;
use shirabe_php_shim::{
- Descriptor, PhpMixed, PhpResource, PregMatches, php_regex, preg_match, preg_replace,
+ Descriptor, PhpMixed, PhpResource, PregMatches, php_regex, preg_is_match, preg_replace,
preg_replace_callback,
};
use std::sync::OnceLock;
@@ -1043,7 +1043,7 @@ impl Process {
if argument.contains('\0') {
argument = argument.replace('\0', "?");
}
- if preg_match(php_regex!(r#"/[()%!^"<>&|\s\[\]=;*?'$]/"#), &argument).is_none() {
+ if !preg_is_match(php_regex!(r#"/[()%!^"<>&|\s\[\]=;*?'$]/"#), &argument) {
return argument;
}
argument = preg_replace(php_regex!(r"/(\\+)$/"), "$1$1", &argument);
diff --git a/crates/shirabe/src/advisory/auditor.rs b/crates/shirabe/src/advisory/auditor.rs
index 2ae64659..fb4b105d 100644
--- a/crates/shirabe/src/advisory/auditor.rs
+++ b/crates/shirabe/src/advisory/auditor.rs
@@ -14,7 +14,7 @@ use crate::util::PackageInfo;
use indexmap::IndexMap;
use shirabe_php_shim::{
DATE_ATOM, InvalidArgumentException, PhpMixed, array_all, array_any, array_key_exists,
- array_keys, array_reduce, get_class, preg_match,
+ array_keys, array_reduce, get_class, preg_is_match,
};
use shirabe_symfony_console::formatter::OutputFormatter;
use shirabe_symfony_console::helper::Cell;
@@ -289,8 +289,7 @@ impl Auditor {
continue;
};
if pkg.is_abandoned()
- && (filter.is_none()
- || preg_match(filter.as_ref().unwrap(), &pkg.get_name()).is_none())
+ && (filter.is_none() || !preg_is_match(filter.as_ref().unwrap(), &pkg.get_name()))
{
result.push(pkg);
}
diff --git a/crates/shirabe/src/autoload/autoload_generator.rs b/crates/shirabe/src/autoload/autoload_generator.rs
index d5e1fcba..5f435566 100644
--- a/crates/shirabe/src/autoload/autoload_generator.rs
+++ b/crates/shirabe/src/autoload/autoload_generator.rs
@@ -26,9 +26,9 @@ use shirabe_class_map_generator::class_map_generator::ClassMapGenerator;
use shirabe_php_shim::{
InvalidArgumentException, PhpMixed, PregMatches, array_keys, array_map, array_merge_map,
array_merge_recursive, array_shift, array_slice_strs, array_unique, bin2hex, explode,
- file_exists, file_get_contents, hash, implode, is_array, ksort, ltrim, php_regex, preg_match,
- preg_quote, preg_replace, preg_replace_callback, random_bytes, realpath, str_replace, strlen,
- strpos, strtr, substr, substr_count, trim, unlink, var_export,
+ file_exists, file_get_contents, hash, implode, is_array, ksort, ltrim, php_regex,
+ preg_is_match, preg_match, preg_quote, preg_replace, preg_replace_callback, random_bytes,
+ realpath, str_replace, strlen, strpos, strtr, substr, substr_count, trim, unlink, var_export,
};
use shirabe_semver::constraint::Bound;
use shirabe_symfony_console::formatter::OutputFormatter;
@@ -1126,7 +1126,7 @@ return array(
}
}
- if preg_match(php_regex!("{\\.phar([\\\\/]|$)}"), &path).is_some() {
+ if preg_is_match(php_regex!("{\\.phar([\\\\/]|$)}"), &path) {
base_dir = format!("'phar://' . {}", base_dir);
}
diff --git a/crates/shirabe/src/cache.rs b/crates/shirabe/src/cache.rs
index 919d0ac2..edfe584c 100644
--- a/crates/shirabe/src/cache.rs
+++ b/crates/shirabe/src/cache.rs
@@ -9,8 +9,8 @@ use chrono::Utc;
use shirabe_php_shim::{
ErrorException, bin2hex, clearstatcache, date_format_to_strftime, dirname, disk_free_space,
file_exists, file_get_contents, file_put_contents, filemtime, function_exists, hash_file,
- is_dir, is_writable, mkdir, php_regex, preg_match, preg_replace, random_bytes, random_int,
- rename, time, unlink,
+ is_dir, is_writable, mkdir, php_regex, preg_is_match, preg_match, preg_replace, random_bytes,
+ random_int, rename, time, unlink,
};
use shirabe_symfony_finder::Finder;
use std::sync::Mutex;
@@ -94,11 +94,10 @@ impl Cache {
}
pub fn is_usable(path: &str) -> bool {
- preg_match(
+ !preg_is_match(
php_regex!(r"{(^|[\\\\/])(\$null|nul|NUL|/dev/null)([\\\\/]|$)}"),
path,
)
- .is_none()
}
pub fn is_enabled(&mut self) -> bool {
diff --git a/crates/shirabe/src/command/bump_command.rs b/crates/shirabe/src/command/bump_command.rs
index 3c75c937..3b680a29 100644
--- a/crates/shirabe/src/command/bump_command.rs
+++ b/crates/shirabe/src/command/bump_command.rs
@@ -18,7 +18,7 @@ use crate::util::Filesystem;
use crate::util::Silencer;
use shirabe_php_shim::{
PhpMixed, file_get_contents, file_put_contents, impl_php_class, is_writable, php_regex,
- preg_match, preg_replace, strtolower,
+ preg_is_match, preg_replace, strtolower,
};
use shirabe_symfony_console::command::Command;
use shirabe_symfony_console::input::InputInterface;
@@ -186,7 +186,7 @@ impl BumpCommand {
.collect();
let pattern = base_package::package_names_to_regexp(&unique_lower, "{^(?:%s)$}iD");
for (key, reqs) in tasks.iter_mut() {
- reqs.retain(|pkg_name, _| preg_match(&pattern, pkg_name).is_some());
+ reqs.retain(|pkg_name, _| preg_is_match(&pattern, pkg_name));
}
packages_filter
} else {
diff --git a/crates/shirabe/src/command/completion_trait.rs b/crates/shirabe/src/command/completion_trait.rs
index eda80164..851c62b8 100644
--- a/crates/shirabe/src/command/completion_trait.rs
+++ b/crates/shirabe/src/command/completion_trait.rs
@@ -11,7 +11,7 @@ use crate::repository::RepositoryInterfaceHandle;
use crate::repository::RootPackageRepository;
use crate::repository::repository_interface::{SEARCH_NAME, SEARCH_VENDOR, SearchResult};
use indexmap::IndexMap;
-use shirabe_php_shim::{PhpMixed, php_regex, preg_match, preg_quote};
+use shirabe_php_shim::{PhpMixed, php_regex, preg_is_match, preg_quote};
/// Adds completion to arguments and options.
///
@@ -256,12 +256,10 @@ pub trait CompletionTrait: BaseCommand {
/// platform packages from the ones available on the currently-running PHP
fn suggest_available_package_incl_platform(&self) -> SuggestedValues {
SuggestedValues::Closure(Box::new(|this, input, suggestions| {
- let matches = if preg_match(
+ let matches = if preg_is_match(
php_regex!(r"{^(ext|lib|php)(-|$)|^com}"),
&input.get_completion_value(),
- )
- .is_some()
- {
+ ) {
this.suggest_platform_package()
.call(this, input, suggestions)?
} else {
@@ -296,7 +294,7 @@ pub trait CompletionTrait: BaseCommand {
let mut names: Vec<String> = vec![];
for package in repos.get_packages()? {
let name = package.get_name();
- if preg_match(pattern.clone(), &name).is_some() {
+ if preg_is_match(pattern.clone(), &name) {
names.push(name);
}
}
diff --git a/crates/shirabe/src/command/config_command.rs b/crates/shirabe/src/command/config_command.rs
index f1eb14b0..0788d694 100644
--- a/crates/shirabe/src/command/config_command.rs
+++ b/crates/shirabe/src/command/config_command.rs
@@ -22,8 +22,8 @@ use shirabe_php_shim::{
InvalidArgumentException, PhpMixed, RuntimeException, array_is_list, array_merge,
escapeshellcmd, exec, explode, file_exists, impl_php_class, implode, in_array_loose,
in_array_strict, is_array, is_bool, is_dir, is_numeric, is_object, is_string, json_encode,
- php_regex, preg_match, preg_replace, str_replace, strpos, strtolower, system, touch,
- var_export,
+ php_regex, preg_is_match, preg_match, preg_replace, str_replace, strpos, strtolower, system,
+ touch, var_export,
};
use shirabe_semver::VersionParser;
use shirabe_symfony_console::command::Command;
@@ -1449,7 +1449,7 @@ impl Command for ConfigCommand {
}
// Check if the header is in correct "Name: Value" format
- if preg_match(php_regex!("/^[^:]+:\\s*.+$/"), header).is_none() {
+ if !preg_is_match(php_regex!("/^[^:]+:\\s*.+$/"), header) {
return Err(RuntimeException::new(format!(
"Header \"{}\" is not in \"Header-Name: Header-Value\" format",
header
@@ -1735,13 +1735,10 @@ fn build_unique_config_values() -> IndexMap<String, (ValidatorFn, NormalizerFn)>
"cache-files-maxsize".to_string(),
(
Box::new(|val| {
- PhpMixed::Bool(
- preg_match(
- php_regex!("/^\\s*([0-9.]+)\\s*(?:([kmg])(?:i?b)?)?\\s*$/i"),
- val.as_string().unwrap_or(""),
- )
- .is_some(),
- )
+ PhpMixed::Bool(preg_is_match(
+ php_regex!("/^\\s*([0-9.]+)\\s*(?:([kmg])(?:i?b)?)?\\s*$/i"),
+ val.as_string().unwrap_or(""),
+ ))
}),
Box::new(|val| val.clone()),
),
diff --git a/crates/shirabe/src/command/init_command.rs b/crates/shirabe/src/command/init_command.rs
index 3ca6c0fb..54ebc995 100644
--- a/crates/shirabe/src/command/init_command.rs
+++ b/crates/shirabe/src/command/init_command.rs
@@ -24,8 +24,8 @@ use shirabe_php_shim::{
CaptureKey, FILE_IGNORE_NEW_LINES, InvalidArgumentException, PHP_EOL, PHP_SERVER, PhpMixed,
array_flip_strings, array_intersect_key, array_map, basename, empty, explode, file,
file_exists, file_get_contents, file_put_contents, get_current_user, impl_php_class, implode,
- is_dir, is_string, php_regex, preg_match, preg_match_all, preg_quote, preg_replace, realpath,
- str_replace, strpos, strtolower, trim, ucwords,
+ is_dir, is_string, php_regex, preg_is_match, preg_match, preg_match_all, preg_quote,
+ preg_replace, realpath, str_replace, strpos, strtolower, trim, ucwords,
};
use shirabe_spdx_licenses::SpdxLicenses;
use shirabe_symfony_console::command::Command;
@@ -209,7 +209,7 @@ impl InitCommand {
let lines = file(ignore_file, FILE_IGNORE_NEW_LINES).unwrap_or_default();
for line in &lines {
- if preg_match(&pattern, line).is_some() {
+ if preg_is_match(&pattern, line) {
return true;
}
}
@@ -497,14 +497,13 @@ impl Command for InitCommand {
});
if options.contains_key("name")
- && preg_match(
+ && !preg_is_match(
php_regex!(r"{^[a-z0-9]([_.-]?[a-z0-9]+)*\/[a-z0-9](([_.]|-{1,2})?[a-z0-9]+)*$}D"),
options
.get("name")
.and_then(|v| v.as_string())
.unwrap_or(""),
)
- .is_none()
{
return Err(InvalidArgumentException::new(format!(
"The package name {} is invalid, it should be lowercase and have a vendor name, a forward slash, and a package name, matching: [a-z0-9_.-]+/[a-z0-9_.-]+",
@@ -908,9 +907,12 @@ impl Command for InitCommand {
return Ok(PhpMixed::String(name_for_validate.clone()));
}
- if preg_match(php_regex!(r"{^[a-z0-9]([_.-]?[a-z0-9]+)*\/[a-z0-9](([_.]|-{1,2})?[a-z0-9]+)*$}D"), value.as_string().unwrap_or(""))
- .is_none()
- {
+ if !preg_is_match(
+ php_regex!(
+ r"{^[a-z0-9]([_.-]?[a-z0-9]+)*\/[a-z0-9](([_.]|-{1,2})?[a-z0-9]+)*$}D"
+ ),
+ value.as_string().unwrap_or(""),
+ ) {
return Err(InvalidArgumentException::new(format!(
"The package name {} is invalid, it should be lowercase and have a vendor name, a forward slash, and a package name, matching: [a-z0-9_.-]+/[a-z0-9_.-]+",
value.as_string().unwrap_or("")
@@ -1220,8 +1222,7 @@ impl Command for InitCommand {
value_str
};
- if preg_match(php_regex!(r"{^[^/][A-Za-z0-9\-_/]+/$}"), &value_or_default)
- .is_none()
+ if !preg_is_match(php_regex!(r"{^[^/][A-Za-z0-9\-_/]+/$}"), &value_or_default)
{
return Err(InvalidArgumentException::new(format!(
"The src folder name \"{}\" is invalid. Please add a relative path with tailing forward slash. [A-Za-z0-9_-/]+/",
diff --git a/crates/shirabe/src/command/package_discovery_trait.rs b/crates/shirabe/src/command/package_discovery_trait.rs
index 8e25c1b9..b743b5c1 100644
--- a/crates/shirabe/src/command/package_discovery_trait.rs
+++ b/crates/shirabe/src/command/package_discovery_trait.rs
@@ -23,7 +23,8 @@ use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
Exception, InvalidArgumentException, LogicException, PHP_EOL, PhpMixed, array_keys,
array_slice, asort, explode, file_get_contents, implode, in_array_strict, is_array, is_file,
- is_numeric, json_decode_assoc, levenshtein, php_regex, preg_match, strlen, strpos, trim,
+ is_numeric, json_decode_assoc, levenshtein, php_regex, preg_is_match, preg_match, strlen,
+ strpos, trim,
};
use shirabe_symfony_console::input::InputInterface;
use shirabe_symfony_console::output::OutputInterface;
@@ -143,11 +144,10 @@ pub trait PackageDiscoveryTrait: BaseCommand {
for mut requirement in requires_norm {
if requirement.contains_key("version")
- && preg_match(
+ && preg_is_match(
php_regex!(r"{^\d+(\.\d+)?$}"),
requirement.get("version").map(|s| s.as_str()).unwrap_or(""),
)
- .is_some()
{
io.write_error3(
&format!(
diff --git a/crates/shirabe/src/command/reinstall_command.rs b/crates/shirabe/src/command/reinstall_command.rs
index d0b36778..010d2b5d 100644
--- a/crates/shirabe/src/command/reinstall_command.rs
+++ b/crates/shirabe/src/command/reinstall_command.rs
@@ -15,7 +15,7 @@ use crate::plugin::CommandEvent;
use crate::plugin::PluginEvents;
use crate::script::ScriptEvents;
use crate::util::Platform;
-use shirabe_php_shim::{InvalidArgumentException, impl_php_class, preg_match};
+use shirabe_php_shim::{InvalidArgumentException, impl_php_class, preg_is_match};
use shirabe_symfony_console::command::Command;
use shirabe_symfony_console::input::InputInterface;
use shirabe_symfony_console::output::OutputInterface;
@@ -136,7 +136,7 @@ impl Command for ReinstallCommand {
let pattern_regexp = base_package::package_name_to_regexp(pattern);
let mut matched = false;
for package in local_repo.get_canonical_packages()? {
- if preg_match(&pattern_regexp, &package.get_name()).is_some() {
+ if preg_is_match(&pattern_regexp, &package.get_name()) {
matched = true;
package_names_to_reinstall.push(package.get_name());
packages_to_reinstall.push(package);
diff --git a/crates/shirabe/src/command/repository_command.rs b/crates/shirabe/src/command/repository_command.rs
index daeaaf74..8f68b16b 100644
--- a/crates/shirabe/src/command/repository_command.rs
+++ b/crates/shirabe/src/command/repository_command.rs
@@ -12,7 +12,7 @@ use crate::json::JsonFile;
use indexmap::IndexMap;
use shirabe_php_shim::{
InvalidArgumentException, PhpMixed, RuntimeException, impl_php_class, parse_url, php_regex,
- preg_match, strtolower,
+ preg_is_match, strtolower,
};
use shirabe_symfony_console::command::Command;
use shirabe_symfony_console::input::InputInterface;
@@ -368,9 +368,7 @@ impl Command for RepositoryCommand {
.into());
}
let arg1_str = arg1.as_deref().unwrap();
- let repo_config: PhpMixed = if preg_match(php_regex!(r"{^\s*\{}"), arg1_str)
- .is_some()
- {
+ let repo_config: PhpMixed = if preg_is_match(php_regex!(r"{^\s*\{}"), arg1_str) {
JsonFile::parse_json(Some(arg1_str), None)?
} else {
if arg2.is_none() {
diff --git a/crates/shirabe/src/command/show_command.rs b/crates/shirabe/src/command/show_command.rs
index acb4f5c8..9c7bf47d 100644
--- a/crates/shirabe/src/command/show_command.rs
+++ b/crates/shirabe/src/command/show_command.rs
@@ -39,8 +39,8 @@ use indexmap::IndexMap;
use shirabe_php_shim::{
CmpOp, DATE_ATOM, InvalidArgumentException, LogicException, PhpMixed, UnexpectedValueException,
array_search, date_format_to_strftime, date_local, extension_loaded, impl_php_class,
- in_array_loose, in_array_strict, php_regex, preg_match, preg_quote, preg_replace, realpath,
- strtolower, version_compare,
+ in_array_loose, in_array_strict, php_regex, preg_is_match, preg_match, preg_quote,
+ preg_replace, realpath, strtolower, version_compare,
};
use shirabe_semver::Semver;
use shirabe_semver::constraint::AnyConstraint;
@@ -2341,7 +2341,7 @@ impl Command for ShowCommand {
}
let matches_filter = match &package_filter_regex {
None => true,
- Some(r) => preg_match(r, &p.get_name()).is_some(),
+ Some(r) => preg_is_match(r, &p.get_name()),
};
if matches_filter {
let matches_list = match &package_list_filter {
@@ -2420,8 +2420,7 @@ impl Command for ShowCommand {
if show_latest && *show_version {
for package_or_name in type_packages.values() {
if let PackageOrName::Pkg(package) = package_or_name
- && preg_match(&ignored_packages_regex, &package.get_pretty_name())
- .is_none()
+ && !preg_is_match(&ignored_packages_regex, &package.get_pretty_name())
{
let latest = self.find_latest_package(
package.clone(),
@@ -2492,8 +2491,7 @@ impl Command for ShowCommand {
package_is_up_to_date =
package_is_up_to_date || (latest_package.is_none() && show_major_only);
let package_is_ignored =
- preg_match(&ignored_packages_regex, &package.get_pretty_name())
- .is_some();
+ preg_is_match(&ignored_packages_regex, &package.get_pretty_name());
if input.borrow().get_option("outdated")?.as_bool() == Some(true)
&& (package_is_up_to_date || package_is_ignored)
{
diff --git a/crates/shirabe/src/command/update_command.rs b/crates/shirabe/src/command/update_command.rs
index dcfbc371..213ac248 100644
--- a/crates/shirabe/src/command/update_command.rs
+++ b/crates/shirabe/src/command/update_command.rs
@@ -29,8 +29,8 @@ use crate::util::HttpDownloader;
use indexmap::IndexMap;
use shirabe_php_shim::{
InvalidArgumentException, PhpMixed, RuntimeException, array_filter, array_intersect,
- array_keys, array_merge_map, array_search_in_vec, impl_php_class, php_regex, preg_match,
- preg_replace, strtolower,
+ array_keys, array_merge_map, array_search_in_vec, impl_php_class, php_regex, preg_is_match,
+ preg_match, preg_replace, strtolower,
};
use shirabe_semver::Intervals;
use shirabe_semver::constraint::MultiConstraint;
@@ -115,7 +115,7 @@ impl UpdateCommand {
let mut version_selector = self.create_version_selector(composer)?;
for package in &installed_packages {
if let Some(filter) = &filter
- && preg_match(filter, &package.get_name()).is_none()
+ && !preg_is_match(filter, &package.get_name())
{
continue;
}
@@ -378,7 +378,7 @@ impl Command for UpdateCommand {
if !packages.is_empty() {
let allowlist_packages_with_requirements: Vec<String> =
array_filter(&packages, |pkg: &String| -> bool {
- preg_match(php_regex!(r"{\S+[ =:]\S+}"), pkg).is_some()
+ preg_is_match(php_regex!(r"{\S+[ =:]\S+}"), pkg)
});
for (package, constraint) in
self.format_requirements(allowlist_packages_with_requirements.clone())?
diff --git a/crates/shirabe/src/composer.rs b/crates/shirabe/src/composer.rs
index 1ed7abd0..2f38c706 100644
--- a/crates/shirabe/src/composer.rs
+++ b/crates/shirabe/src/composer.rs
@@ -11,7 +11,7 @@ use crate::package::{LockerInterface, RootPackageInterfaceHandle};
use crate::plugin::PluginManager;
use crate::repository::RepositoryManagerInterface;
use crate::util::r#loop::Loop;
-use shirabe_php_shim::{php_regex, preg_match};
+use shirabe_php_shim::{php_regex, preg_is_match};
/// The Composer version this port tracks. Kept as-is so `Composer::VERSION`, the `composer`
/// platform package and the HTTP User-Agent keep reporting a value plugins and servers can
@@ -42,9 +42,7 @@ pub fn get_version() -> String {
if VERSION == "@package_version@" {
return SOURCE_VERSION.to_string();
}
- if !BRANCH_ALIAS_VERSION.is_empty()
- && preg_match(php_regex!("{^[a-f0-9]{40}$}"), VERSION).is_some()
- {
+ if !BRANCH_ALIAS_VERSION.is_empty() && preg_is_match(php_regex!("{^[a-f0-9]{40}$}"), VERSION) {
return format!("{}+{}", BRANCH_ALIAS_VERSION, VERSION);
}
VERSION.to_string()
diff --git a/crates/shirabe/src/config.rs b/crates/shirabe/src/config.rs
index 7e37a544..d1f34477 100644
--- a/crates/shirabe/src/config.rs
+++ b/crates/shirabe/src/config.rs
@@ -11,8 +11,9 @@ use indexmap::IndexMap;
use shirabe_php_shim::{
E_USER_DEPRECATED, PhpMixed, PregMatches, RuntimeException, array_key_exists, array_merge,
array_search_mixed, array_unique, empty, filter_var_url, implode, in_array_loose,
- in_array_strict, intval, is_array, is_string, parse_url, php_regex, php_to_string, preg_match,
- preg_replace_callback, rtrim, strtolower, strtoupper, strtr, substr, trigger_error,
+ in_array_strict, intval, is_array, is_string, parse_url, php_regex, php_to_string,
+ preg_is_match, preg_match, preg_replace_callback, rtrim, strtolower, strtoupper, strtr, substr,
+ trigger_error,
};
use crate::advisory::Auditor;
@@ -481,11 +482,10 @@ impl Config {
.unwrap_or("")
.to_string();
if is_composer
- && preg_match(
+ && preg_is_match(
php_regex!(r"{^https?://(?:[a-z0-9-.]+\.)?packagist.org(/|$)}"),
&repo_url,
)
- .is_some()
{
self.disable_repo_by_name("packagist.org");
}
@@ -971,7 +971,7 @@ impl Config {
///
/// Since the dirs might not exist yet we can not call realpath or it will fail.
fn realpath(&self, path: &str) -> String {
- if preg_match(php_regex!(r"{^(?:/|[a-z]:|[a-z0-9.]+://|\\\\\\\\)}i"), path).is_some() {
+ if preg_is_match(php_regex!(r"{^(?:/|[a-z]:|[a-z0-9.]+://|\\\\\\\\)}i"), path) {
return path.to_string();
}
@@ -1013,7 +1013,7 @@ impl Config {
repo_options: &IndexMap<String, PhpMixed>,
) -> anyhow::Result<()> {
// Return right away if the URL is malformed or custom (see issue #5173), but only for non-HTTP(S) URLs
- if !filter_var_url(url) && preg_match(php_regex!(r"{^https?://}"), url).is_none() {
+ if !filter_var_url(url) && !preg_is_match(php_regex!(r"{^https?://}"), url) {
return Ok(());
}
diff --git a/crates/shirabe/src/dependency_resolver/lock_transaction.rs b/crates/shirabe/src/dependency_resolver/lock_transaction.rs
index 71609658..a0004fd4 100644
--- a/crates/shirabe/src/dependency_resolver/lock_transaction.rs
+++ b/crates/shirabe/src/dependency_resolver/lock_transaction.rs
@@ -5,7 +5,7 @@ use crate::dependency_resolver::Pool;
use crate::dependency_resolver::Transaction;
use crate::package::PackageInterfaceHandle;
use indexmap::IndexMap;
-use shirabe_php_shim::{PregMatches, php_regex, preg_match, preg_replace_callback};
+use shirabe_php_shim::{PregMatches, php_regex, preg_is_match, preg_replace_callback};
#[derive(Debug)]
pub struct LockTransaction {
@@ -158,9 +158,12 @@ impl LockTransaction {
if package.get_dist_url().is_some()
&& present_package.get_dist_reference().is_some()
- && preg_match(php_regex!(
- r"{^https?://(?:(?:www\.)?bitbucket\.org|(api\.)?github\.com|(?:www\.)?gitlab\.com)/}i"
- ), &package.get_dist_url().unwrap()).is_some()
+ && preg_is_match(
+ php_regex!(
+ r"{^https?://(?:(?:www\.)?bitbucket\.org|(api\.)?github\.com|(?:www\.)?gitlab\.com)/}i"
+ ),
+ &package.get_dist_url().unwrap(),
+ )
{
// Regex pattern compatibility:
// The `regex` crate has no look-around, so `(?<=/|sha=)[a-f0-9]{40}(?=/|$)` is
diff --git a/crates/shirabe/src/dependency_resolver/pool_builder.rs b/crates/shirabe/src/dependency_resolver/pool_builder.rs
index 354a794c..98a0948d 100644
--- a/crates/shirabe/src/dependency_resolver/pool_builder.rs
+++ b/crates/shirabe/src/dependency_resolver/pool_builder.rs
@@ -21,7 +21,7 @@ use crate::repository::RootPackageRepository;
use indexmap::IndexMap;
use shirabe_php_shim::{
CmpOp, LogicException, PhpMixed, array_flip_strings, array_map, in_array_strict, microtime,
- number_format, preg_match, round, strpos,
+ number_format, preg_is_match, round, strpos,
};
use shirabe_semver::CompilingMatcher;
use shirabe_semver::Intervals;
@@ -785,7 +785,7 @@ impl PoolBuilder {
fn is_update_allowed(&self, package: PackageInterfaceHandle) -> bool {
for pattern in &self.update_allow_list {
let pattern_regexp = base_package::package_name_to_regexp(pattern);
- if preg_match(&pattern_regexp, &package.get_name()).is_some() {
+ if preg_is_match(&pattern_regexp, &package.get_name()) {
return true;
}
}
@@ -812,13 +812,13 @@ impl PoolBuilder {
.borrow_mut()
.get_packages()?
{
- if preg_match(&pattern_regexp, &package.get_name()).is_some() {
+ if preg_is_match(&pattern_regexp, &package.get_name()) {
continue 'outer;
}
}
// update pattern matches a root require? => all good, probably a new package
for (package_name, _constraint) in request.get_requires() {
- if preg_match(&pattern_regexp, package_name).is_some() {
+ if preg_is_match(&pattern_regexp, package_name) {
if PlatformRepository::is_platform_package(package_name) {
matched_platform_package = true;
continue;
diff --git a/crates/shirabe/src/dependency_resolver/problem.rs b/crates/shirabe/src/dependency_resolver/problem.rs
index 6c1ae8c0..ba6f43bd 100644
--- a/crates/shirabe/src/dependency_resolver/problem.rs
+++ b/crates/shirabe/src/dependency_resolver/problem.rs
@@ -12,8 +12,8 @@ use crate::repository::RepositorySet;
use indexmap::IndexMap;
use shirabe_php_shim::{
CmpOp, LogicException, PhpMixed, extension_loaded, implode, loosely_compare, php_regex,
- preg_match, preg_replace, spl_object_hash, sprintf, str_replace, stripos, strpos, strtolower,
- substr, substr_count, version_compare,
+ preg_is_match, preg_match, preg_replace, spl_object_hash, sprintf, str_replace, stripos,
+ strpos, strtolower, substr, substr_count, version_compare,
};
use shirabe_semver::constraint::AnyConstraint;
use shirabe_semver::constraint::MultiConstraint;
@@ -556,7 +556,7 @@ impl Problem {
if let Some(c) = constraint
&& c.is_constraint()
&& c.get_operator() == Some(CmpOp::Eq)
- && preg_match(php_regex!(r"{^dev-.*#.*}"), &c.get_pretty_string()).is_some()
+ && preg_is_match(php_regex!(r"{^dev-.*#.*}"), &c.get_pretty_string())
{
let new_constraint = preg_replace(
php_regex!(r"{ +as +([^,\s|]+)$}"),
@@ -990,7 +990,7 @@ impl Problem {
));
}
- if preg_match(php_regex!(r"{^[A-Za-z0-9_./-]+$}"), package_name).is_none() {
+ if !preg_is_match(php_regex!(r"{^[A-Za-z0-9_./-]+$}"), package_name) {
let illegal_chars = preg_replace(php_regex!(r"{[A-Za-z0-9_./-]+}"), "", package_name);
return Ok((
@@ -1380,7 +1380,7 @@ impl Problem {
&& c.get_operator() == Some(CmpOp::Eq)
&& !c.get_version().starts_with("dev-")
{
- if preg_match(php_regex!(r"{^\d+(?:\.\d+)*$}"), &c.get_pretty_string()).is_none() {
+ if !preg_is_match(php_regex!(r"{^\d+(?:\.\d+)*$}"), &c.get_pretty_string()) {
return format!(" {} (exact version match)", c.get_pretty_string());
}
diff --git a/crates/shirabe/src/downloader/download_manager.rs b/crates/shirabe/src/downloader/download_manager.rs
index 85e05bea..d7c6eec1 100644
--- a/crates/shirabe/src/downloader/download_manager.rs
+++ b/crates/shirabe/src/downloader/download_manager.rs
@@ -11,8 +11,8 @@ use indexmap::IndexMap;
use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
InvalidArgumentException, LogicException, PhpMixed, RuntimeException, array_keys,
- array_reverse, array_shift, dirname, implode, in_array_strict, preg_match, preg_quote, rtrim,
- str_replace, strtolower, usort,
+ array_reverse, array_shift, dirname, implode, in_array_strict, preg_is_match, preg_quote,
+ rtrim, str_replace, strtolower, usort,
};
/// Downloaders manager.
@@ -430,7 +430,7 @@ impl DownloadManager {
"{{^{}$}}i",
str_replace("\\*", ".*", &preg_quote(pattern, None)),
);
- if preg_match(&pattern_regex, &package.get_name()).is_some() {
+ if preg_is_match(&pattern_regex, &package.get_name()) {
if "dist" == preference || (!package.is_dev() && "auto" == preference) {
return "dist".to_string();
}
diff --git a/crates/shirabe/src/downloader/fossil_downloader.rs b/crates/shirabe/src/downloader/fossil_downloader.rs
index 40d5153f..96886ca0 100644
--- a/crates/shirabe/src/downloader/fossil_downloader.rs
+++ b/crates/shirabe/src/downloader/fossil_downloader.rs
@@ -13,7 +13,7 @@ use crate::util::Filesystem;
use crate::util::ProcessExecutor;
use indexmap::IndexMap;
use shirabe_php_shim::{
- PhpMixed, RuntimeException, impl_php_class, php_regex, preg_match, preg_split,
+ PhpMixed, RuntimeException, impl_php_class, php_regex, preg_is_match, preg_split,
};
#[derive(Debug)]
@@ -228,7 +228,7 @@ impl VcsDownloader for FossilDownloader {
};
for line in lines {
- if preg_match(&match_pattern, &line).is_some() {
+ if preg_is_match(&match_pattern, &line) {
break;
}
log.push_str(&line);
diff --git a/crates/shirabe/src/downloader/git_downloader.rs b/crates/shirabe/src/downloader/git_downloader.rs
index be3205b5..a8a4344d 100644
--- a/crates/shirabe/src/downloader/git_downloader.rs
+++ b/crates/shirabe/src/downloader/git_downloader.rs
@@ -19,8 +19,9 @@ use crate::util::Url;
use indexmap::IndexMap;
use shirabe_php_shim::{
CaptureKey, CmpOp, PhpMixed, RuntimeException, array_map, basename, dirname, impl_php_class,
- implode, in_array_strict, is_dir, php_regex, preg_match, preg_match_all, preg_quote,
- preg_replace, preg_split, realpath, rtrim, strlen, strpos, substr, trim, version_compare,
+ implode, in_array_strict, is_dir, php_regex, preg_is_match, preg_match, preg_match_all,
+ preg_quote, preg_replace, preg_split, realpath, rtrim, strlen, strpos, substr, trim,
+ version_compare,
};
#[derive(Debug)]
@@ -298,13 +299,12 @@ impl GitDownloader {
// check whether non-commitish are branches or tags, and fetch branches with the remote name
let git_ref = reference.to_string();
- if preg_match(php_regex!(r"{^[a-f0-9]{40}$}"), reference).is_none()
+ if !preg_is_match(php_regex!(r"{^[a-f0-9]{40}$}"), reference)
&& branches.is_some()
- && preg_match(
+ && preg_is_match(
format!("{{^\\s+composer/{}$}}m", preg_quote(reference, None)),
branches.as_deref().unwrap_or(""),
)
- .is_some()
{
let mut command1: Vec<String> = vec!["git".to_string(), "checkout".to_string()];
command1.extend(force.clone());
@@ -345,19 +345,17 @@ impl GitDownloader {
}
// try to checkout branch by name and then reset it so it's on the proper branch name
- if preg_match(php_regex!(r"{^[a-f0-9]{40}$}"), reference).is_some() {
+ if preg_is_match(php_regex!(r"{^[a-f0-9]{40}$}"), reference) {
// add 'v' in front of the branch if it was stripped when generating the pretty name
if branches.is_some()
- && preg_match(
+ && !preg_is_match(
format!("{{^\\s+composer/{}$}}m", preg_quote(&branch, None)),
branches.as_deref().unwrap_or(""),
)
- .is_none()
- && preg_match(
+ && preg_is_match(
format!("{{^\\s+composer/v{}$}}m", preg_quote(&branch, None)),
branches.as_deref().unwrap_or(""),
)
- .is_some()
{
branch = format!("v{}", branch);
}
@@ -642,8 +640,7 @@ impl GitDownloader {
}
fn get_short_hash(&self, reference: &str) -> String {
- if !self.inner.io.is_verbose()
- && preg_match(php_regex!(r"{^[0-9a-f]{40}$}"), reference).is_some()
+ if !self.inner.io.is_verbose() && preg_is_match(php_regex!(r"{^[0-9a-f]{40}$}"), reference)
{
return substr(reference, 0, Some(10));
}
diff --git a/crates/shirabe/src/downloader/svn_downloader.rs b/crates/shirabe/src/downloader/svn_downloader.rs
index 42152eb3..93b860f0 100644
--- a/crates/shirabe/src/downloader/svn_downloader.rs
+++ b/crates/shirabe/src/downloader/svn_downloader.rs
@@ -16,8 +16,8 @@ use crate::util::ProcessExecutor;
use crate::util::Svn as SvnUtil;
use indexmap::IndexMap;
use shirabe_php_shim::{
- CmpOp, PhpMixed, RuntimeException, impl_php_class, is_dir, php_regex, preg_match, preg_replace,
- preg_split, version_compare,
+ CmpOp, PhpMixed, RuntimeException, impl_php_class, is_dir, php_regex, preg_is_match,
+ preg_match, preg_replace, preg_split, version_compare,
};
#[derive(Debug)]
@@ -353,8 +353,8 @@ impl VcsDownloader for SvnDownloader {
to_reference: &str,
path: &str,
) -> anyhow::Result<String> {
- if preg_match(php_regex!(r"{@(\d+)$}"), from_reference).is_some()
- && preg_match(php_regex!(r"{@(\d+)$}"), to_reference).is_some()
+ if preg_is_match(php_regex!(r"{@(\d+)$}"), from_reference)
+ && preg_is_match(php_regex!(r"{@(\d+)$}"), to_reference)
{
// retrieve the svn base url from the checkout folder
let command = vec![
@@ -452,13 +452,11 @@ impl ChangeReportInterface for SvnDownloader {
Some(path),
);
- Ok(
- if preg_match(php_regex!("{^ *[^X ] +}m"), &output).is_some() {
- Some(output)
- } else {
- None
- },
- )
+ Ok(if preg_is_match(php_regex!("{^ *[^X ] +}m"), &output) {
+ Some(output)
+ } else {
+ None
+ })
}
}
diff --git a/crates/shirabe/src/event_dispatcher/event_dispatcher.rs b/crates/shirabe/src/event_dispatcher/event_dispatcher.rs
index 9cb38599..b22c7c0a 100644
--- a/crates/shirabe/src/event_dispatcher/event_dispatcher.rs
+++ b/crates/shirabe/src/event_dispatcher/event_dispatcher.rs
@@ -29,8 +29,8 @@ use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
InvalidArgumentException, PhpMixed, RuntimeException, array_pop, array_push,
array_search_in_vec, array_splice, file_exists, get_class, hash, implode, ini_get, is_array,
- is_callable, is_object, is_string, krsort, php_regex, preg_match, preg_quote, preg_replace,
- preg_replace_callback, realpath, spl_autoload_functions, spl_autoload_register,
+ is_callable, is_object, is_string, krsort, php_regex, preg_is_match, preg_match, preg_quote,
+ preg_replace, preg_replace_callback, realpath, spl_autoload_functions, spl_autoload_register,
spl_autoload_unregister, spl_object_hash, str_replace, strlen, strpos, strtoupper, substr,
trim,
};
@@ -922,12 +922,10 @@ try {{
.get_binaries();
if !possible_local_binaries.is_empty() {
for local_exec in &possible_local_binaries {
- if preg_match(
+ if preg_is_match(
format!("{{\\b{}$}}", preg_quote(&callable_str, None)),
local_exec,
- )
- .is_some()
- {
+ ) {
let caller =
BinaryInstaller::determine_binary_caller(local_exec);
exec = preg_replace(
diff --git a/crates/shirabe/src/filter/platform_requirement_filter/ignore_list_platform_requirement_filter.rs b/crates/shirabe/src/filter/platform_requirement_filter/ignore_list_platform_requirement_filter.rs
index de71a6ab..a1f1d090 100644
--- a/crates/shirabe/src/filter/platform_requirement_filter/ignore_list_platform_requirement_filter.rs
+++ b/crates/shirabe/src/filter/platform_requirement_filter/ignore_list_platform_requirement_filter.rs
@@ -3,7 +3,7 @@
use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterface;
use crate::package::base_package::{self};
use crate::repository::PlatformRepository;
-use shirabe_php_shim::preg_match;
+use shirabe_php_shim::preg_is_match;
use shirabe_semver::Interval;
use shirabe_semver::Intervals;
use shirabe_semver::constraint::AnyConstraint;
@@ -47,12 +47,11 @@ impl IgnoreListPlatformRequirementFilter {
return Ok(constraint);
}
- if !allow_upper_bound_override || preg_match(&self.ignore_upper_bound_regex, req).is_none()
- {
+ if !allow_upper_bound_override || !preg_is_match(&self.ignore_upper_bound_regex, req) {
return Ok(constraint);
}
- if preg_match(&self.ignore_regex, req).is_some() {
+ if preg_is_match(&self.ignore_regex, req) {
return Ok(MatchAllConstraint::new(None).into());
}
@@ -86,14 +85,14 @@ impl PlatformRequirementFilterInterface for IgnoreListPlatformRequirementFilter
if !PlatformRepository::is_platform_package(req) {
return false;
}
- preg_match(&self.ignore_regex, req).is_some()
+ preg_is_match(&self.ignore_regex, req)
}
fn is_upper_bound_ignored(&self, req: &str) -> bool {
if !PlatformRepository::is_platform_package(req) {
return false;
}
- self.is_ignored(req) || preg_match(&self.ignore_upper_bound_regex, req).is_some()
+ self.is_ignored(req) || preg_is_match(&self.ignore_upper_bound_regex, req)
}
fn as_any(&self) -> &dyn std::any::Any {
diff --git a/crates/shirabe/src/io/base_io.rs b/crates/shirabe/src/io/base_io.rs
index f6f75267..4bc34ed6 100644
--- a/crates/shirabe/src/io/base_io.rs
+++ b/crates/shirabe/src/io/base_io.rs
@@ -8,7 +8,8 @@ use crate::util::Silencer;
use indexmap::IndexMap;
use shirabe_php_shim::{
JSON_INVALID_UTF8_IGNORE, JSON_UNESCAPED_SLASHES, JSON_UNESCAPED_UNICODE, PhpMixed,
- UnexpectedValueException, array_merge, in_array_strict, json_encode_ex, php_regex, preg_match,
+ UnexpectedValueException, array_merge, in_array_strict, json_encode_ex, php_regex,
+ preg_is_match,
};
/// ref: composer/vendor/psr/log/Psr/Log/LogLevel.php
@@ -156,7 +157,7 @@ pub trait BaseIO: IOInterface {
config.merge(&config_outer, "implicit-due-to-auth");
}
- if preg_match(php_regex!(r"{^[.A-Za-z0-9_]+$}"), &token_str).is_none() {
+ if !preg_is_match(php_regex!(r"{^[.A-Za-z0-9_]+$}"), &token_str) {
return Err(UnexpectedValueException::new(format!(
"Your github oauth token for {} contains invalid characters: \"{}\"",
domain, token_str
diff --git a/crates/shirabe/src/json/json_file.rs b/crates/shirabe/src/json/json_file.rs
index 8d992449..fed8318d 100644
--- a/crates/shirabe/src/json/json_file.rs
+++ b/crates/shirabe/src/json/json_file.rs
@@ -13,8 +13,8 @@ use shirabe_php_shim::{
InvalidArgumentException, JSON_PRETTY_PRINT, JSON_UNESCAPED_SLASHES, JSON_UNESCAPED_UNICODE,
PhpMixed, PregMatches, RuntimeException, UnexpectedValueException, dirname, file_exists,
file_get_contents, file_put_contents, is_dir, is_file, json_decode_assoc, json_decode_obj,
- json_encode_ex, mkdir, php_regex, preg_match, preg_replace_callback, preg_replace2, realpath,
- str_repeat, strlen, strpos, usleep,
+ json_encode_ex, mkdir, php_regex, preg_is_match, preg_match, preg_replace_callback,
+ preg_replace2, realpath, str_repeat, strlen, strpos, usleep,
};
use shirabe_seld_json_lint::{ParsingException, ParsingExceptionDetails};
@@ -107,7 +107,7 @@ impl JsonFile {
http_downloader: Option<std::rc::Rc<std::cell::RefCell<HttpDownloader>>>,
io: Option<std::rc::Rc<std::cell::RefCell<dyn IOInterface>>>,
) -> anyhow::Result<Self> {
- if http_downloader.is_none() && preg_match(php_regex!(r"{^https?://}i"), &path).is_some() {
+ if http_downloader.is_none() && preg_is_match(php_regex!(r"{^https?://}i"), &path) {
return Err(InvalidArgumentException::new(
"http urls require a HttpDownloader instance to be passed".to_string(),
)
diff --git a/crates/shirabe/src/json/json_manipulator.rs b/crates/shirabe/src/json/json_manipulator.rs
index e224e68e..b580b0ec 100644
--- a/crates/shirabe/src/json/json_manipulator.rs
+++ b/crates/shirabe/src/json/json_manipulator.rs
@@ -7,9 +7,9 @@ use indexmap::IndexMap;
use shirabe_php_shim::{
InvalidArgumentException, LogicException, PhpMixed, addcslashes, array_key_exists, array_keys,
array_reverse, empty, explode, implode, in_array_loose, is_array, is_int, is_numeric,
- json_decode_assoc, json_decode_obj, php_regex, php_truthy, preg_match, preg_quote,
- preg_replace, preg_replace2, rtrim, str_repeat, str_replace, strlen, strnatcmp, strpos, substr,
- trim, uksort,
+ json_decode_assoc, json_decode_obj, php_regex, php_truthy, preg_is_match, preg_match,
+ preg_quote, preg_replace, preg_replace2, rtrim, str_repeat, str_replace, strlen, strnatcmp,
+ strpos, substr, trim, uksort,
};
#[derive(Debug)]
@@ -35,7 +35,7 @@ impl JsonManipulator {
if contents.is_empty() {
contents = "{}".to_string();
}
- if preg_match(php_regex!("#^\\{(.*)\\}$#s"), &contents).is_none() {
+ if !preg_is_match(php_regex!("#^\\{(.*)\\}$#s"), &contents) {
return Err(InvalidArgumentException::new(
"The json file must be an object ({})".to_string(),
)
@@ -890,7 +890,7 @@ impl JsonManipulator {
// try and find a match for the subkey
let key_regex = str_replace("/", "\\\\?/", &preg_quote(&name_owned, None));
let mut children_clean: Option<String> = None;
- if preg_match(format!("{{\"{}\"\\s*:}}i", key_regex), &children).is_some() {
+ if preg_is_match(format!("{{\"{}\"\\s*:}}i", key_regex), &children) {
// find best match for the value of "name". The PHP pattern `"name"\s*:\s*(?&json)` is
// not anchored, so it can match the key at several nesting levels; collect every such
// occurrence and keep the longest, reproducing PHP's behaviour.
@@ -1390,8 +1390,8 @@ impl JsonManipulator {
// check that we are not leaving a dangling comma on the previous line if the last line was removed
let mut start = self.contents[..m.key_pos].to_string();
let end = self.contents[e..].to_string();
- if preg_match(php_regex!("#,\\s*$#"), &start).is_some()
- && preg_match(php_regex!("#^\\}$#"), &end).is_some()
+ if preg_is_match(php_regex!("#,\\s*$#"), &start)
+ && preg_is_match(php_regex!("#^\\}$#"), &end)
{
start = rtrim(
&preg_replace(php_regex!("#,(\\s*)$#"), "$1", &start),
@@ -1400,7 +1400,7 @@ impl JsonManipulator {
}
self.contents = format!("{}{}", start, end);
- if preg_match(php_regex!("#^\\{\\s*\\}\\s*$#"), &self.contents).is_some() {
+ if preg_is_match(php_regex!("#^\\{\\s*\\}\\s*$#"), &self.contents) {
self.contents = "{\n}".to_string();
}
diff --git a/crates/shirabe/src/package/archiver/archive_manager.rs b/crates/shirabe/src/package/archiver/archive_manager.rs
index 83d5cc94..ceda099b 100644
--- a/crates/shirabe/src/package/archiver/archive_manager.rs
+++ b/crates/shirabe/src/package/archiver/archive_manager.rs
@@ -11,7 +11,7 @@ use crate::util::SyncHelper;
use crate::util::r#loop::Loop;
use indexmap::IndexMap;
use shirabe_php_shim::{
- InvalidArgumentException, RuntimeException, bin2hex, file_exists, php_regex, preg_match,
+ InvalidArgumentException, RuntimeException, bin2hex, file_exists, php_regex, preg_is_match,
preg_replace, random_bytes, realpath, sys_get_temp_dir,
};
@@ -65,7 +65,7 @@ impl ArchiveManager {
let dist_reference = package.get_dist_reference();
if let Some(ref dist_ref) = dist_reference {
- if preg_match(php_regex!("{^[a-f0-9]{40}$}"), dist_ref).is_some() {
+ if preg_is_match(php_regex!("{^[a-f0-9]{40}$}"), dist_ref) {
parts.insert("dist_reference".to_string(), dist_ref.to_string());
if let Some(dist_type) = package.get_dist_type() {
parts.insert("dist_type".to_string(), dist_type);
diff --git a/crates/shirabe/src/package/archiver/base_exclude_filter.rs b/crates/shirabe/src/package/archiver/base_exclude_filter.rs
index 8186e95c..d036623c 100644
--- a/crates/shirabe/src/package/archiver/base_exclude_filter.rs
+++ b/crates/shirabe/src/package/archiver/base_exclude_filter.rs
@@ -1,6 +1,6 @@
//! ref: composer/src/Composer/Package/Archiver/BaseExcludeFilter.php
-use shirabe_php_shim::preg_match;
+use shirabe_php_shim::preg_is_match;
use shirabe_symfony_finder::Glob;
#[derive(Debug)]
@@ -86,7 +86,7 @@ pub trait BaseExcludeFilter {
relative_path
};
- if preg_match(pattern, path).is_some() {
+ if preg_is_match(pattern, path) {
exclude = !negate;
}
}
diff --git a/crates/shirabe/src/package/loader/array_loader.rs b/crates/shirabe/src/package/loader/array_loader.rs
index 00f9026e..698e1f03 100644
--- a/crates/shirabe/src/package/loader/array_loader.rs
+++ b/crates/shirabe/src/package/loader/array_loader.rs
@@ -19,8 +19,8 @@ use chrono::Utc;
use indexmap::IndexMap;
use shirabe_php_shim::{
AnyThrowable, E_USER_DEPRECATED, PhpMixed, UnexpectedValueException, is_scalar, is_string,
- json_encode, ltrim, php_regex, preg_match, preg_replace, stripos, strpos, strtolower, strval,
- substr, trigger_error, trim,
+ json_encode, ltrim, php_regex, preg_is_match, preg_replace, stripos, strpos, strtolower,
+ strval, substr, trigger_error, trim,
};
#[derive(Debug)]
@@ -339,7 +339,7 @@ impl ArrayLoader {
&& !shirabe_php_shim::empty(time_value)
{
let time_str = time_value.as_string().unwrap_or("");
- let time = if preg_match(php_regex!(r"/^\d++$/D"), time_str).is_some() {
+ let time = if preg_is_match(php_regex!(r"/^\d++$/D"), time_str) {
format!("@{}", time_str)
} else {
time_str.to_string()
diff --git a/crates/shirabe/src/package/loader/root_package_loader.rs b/crates/shirabe/src/package/loader/root_package_loader.rs
index 491961a6..ece29b41 100644
--- a/crates/shirabe/src/package/loader/root_package_loader.rs
+++ b/crates/shirabe/src/package/loader/root_package_loader.rs
@@ -16,8 +16,8 @@ use crate::util::Platform;
use crate::util::ProcessExecutor;
use indexmap::IndexMap;
use shirabe_php_shim::{
- PhpMixed, RuntimeException, UnexpectedValueException, php_regex, preg_match, preg_replace,
- preg_split, strtolower,
+ PhpMixed, RuntimeException, UnexpectedValueException, php_regex, preg_is_match, preg_match,
+ preg_replace, preg_split, strtolower,
};
#[derive(Debug)]
@@ -337,7 +337,7 @@ impl RootPackageLoader {
for constraint in &constraints {
let req_version_stripped =
preg_replace(php_regex!(r"{^([^,\s@]+) as .+$}"), "$1", constraint);
- if preg_match(php_regex!(r"{^[^,\s@]+$}"), &req_version_stripped).is_some() {
+ if preg_is_match(php_regex!(r"{^[^,\s@]+$}"), &req_version_stripped) {
let stability_name = VersionParser::parse_stability(&req_version_stripped);
if stability_name != "stable" {
let name = strtolower(req_name);
diff --git a/crates/shirabe/src/package/loader/validating_array_loader.rs b/crates/shirabe/src/package/loader/validating_array_loader.rs
index e893756a..70c09014 100644
--- a/crates/shirabe/src/package/loader/validating_array_loader.rs
+++ b/crates/shirabe/src/package/loader/validating_array_loader.rs
@@ -10,7 +10,7 @@ use indexmap::IndexMap;
use shirabe_php_shim::{
CmpOp, E_USER_DEPRECATED, PHP_EOL, PhpMixed, array_intersect_key, array_values,
filter_var_email, get_debug_type, is_array, is_bool, is_int, is_numeric, is_scalar, is_string,
- json_encode, parse_url, php_regex, php_to_string, preg_match, preg_replace, str_replace,
+ json_encode, parse_url, php_regex, php_to_string, preg_is_match, preg_replace, str_replace,
strcasecmp, strtolower, strtotime, substr, trigger_error, trim, var_export,
};
use shirabe_semver::Intervals;
@@ -73,14 +73,12 @@ impl ValidatingArrayLoader {
return None;
}
- if preg_match(
+ if !preg_is_match(
php_regex!(
"{^[a-z0-9](?:[_.-]?[a-z0-9]++)*+/[a-z0-9](?:(?:[_.]|-{1,2})?[a-z0-9]++)*+$}iD"
),
name,
- )
- .is_none()
- {
+ ) {
return Some(format!(
"{} is invalid, it should have a vendor name, a forward slash, and a package name. The vendor and package name can be words separated by -, . or _. The complete name should match \"^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9](([_.]?|-{{0,2}})[a-z0-9]+)*$\".",
name
@@ -101,14 +99,14 @@ impl ValidatingArrayLoader {
));
}
- if preg_match(php_regex!("{\\.json$}"), name).is_some() {
+ if preg_is_match(php_regex!("{\\.json$}"), name) {
return Some(format!(
"{} is invalid, package names can not end in .json, consider renaming it or perhaps using a -json suffix instead.",
name
));
}
- if preg_match(php_regex!("{[A-Z]}"), name).is_some() {
+ if preg_is_match(php_regex!("{[A-Z]}"), name) {
if is_link {
return Some(format!(
"{} is invalid, it should not contain uppercase characters. Please use {} instead.",
@@ -142,7 +140,7 @@ impl ValidatingArrayLoader {
.as_string()
.unwrap_or("")
.to_string();
- if preg_match(format!("{{^{}$}}u", regex), &value).is_none() {
+ if !preg_is_match(format!("{{^{}$}}u", regex), &value) {
let message = format!(
"{} : invalid value ({}), must match {}",
property, value, regex
@@ -257,7 +255,7 @@ impl ValidatingArrayLoader {
if let Some(regex_str) = regex {
let value_str = php_to_string(&value);
- if preg_match(format!("{{^{}$}}u", regex_str), &value_str).is_none() {
+ if !preg_is_match(format!("{{^{}$}}u", regex_str), &value_str) {
self.warnings.borrow_mut().push(format!(
"{}.{} : invalid value ({}), must match {}",
property, key, value_str, regex_str
@@ -1186,7 +1184,7 @@ impl LoaderInterface for ValidatingArrayLoader {
self.warnings
.borrow_mut()
.push(format!("{}.{}", link_type, err));
- } else if preg_match(php_regex!("{^[A-Za-z0-9_./-]+$}"), &package).is_none() {
+ } else if !preg_is_match(php_regex!("{^[A-Za-z0-9_./-]+$}"), &package) {
self.errors.borrow_mut().push(format!(
"{}.{} : invalid key, package names must be strings containing only [A-Za-z0-9_./-]",
link_type, package
@@ -1449,7 +1447,7 @@ impl LoaderInterface for ValidatingArrayLoader {
}
if let Some(ref_val) = section.get("reference").filter(|_| isset("reference")) {
let ref_str = php_to_string(ref_val);
- if preg_match(php_regex!("{^\\s*-}"), &ref_str).is_some() {
+ if preg_is_match(php_regex!("{^\\s*-}"), &ref_str) {
self.errors.borrow_mut().push(format!(
"{}.reference : must not start with a \"-\", \"{}\" given",
src_type, ref_str
@@ -1458,7 +1456,7 @@ impl LoaderInterface for ValidatingArrayLoader {
}
if let Some(url_val) = section.get("url").filter(|_| isset("url")) {
let url_str = php_to_string(url_val);
- if preg_match(php_regex!("{^\\s*-}"), &url_str).is_some() {
+ if preg_is_match(php_regex!("{^\\s*-}"), &url_str) {
self.errors.borrow_mut().push(format!(
"{}.url : must not start with a \"-\", \"{}\" given",
src_type, url_str
diff --git a/crates/shirabe/src/package/locker.rs b/crates/shirabe/src/package/locker.rs
index 017bcb6a..ec8d86e7 100644
--- a/crates/shirabe/src/package/locker.rs
+++ b/crates/shirabe/src/package/locker.rs
@@ -28,7 +28,8 @@ use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
DATE_RFC3339, LogicException, PhpMixed, RuntimeException, array_intersect, array_keys,
array_map, array_merge, file_get_contents, filemtime, function_exists, hash, in_array_loose,
- is_int, ksort, php_regex, preg_match, realpath, strcmp, strtolower, touch2, trim, usort,
+ is_int, ksort, php_regex, preg_is_match, preg_match, realpath, strcmp, strtolower, touch2,
+ trim, usort,
};
use shirabe_seld_json_lint::ParsingException;
@@ -823,7 +824,7 @@ impl Locker {
),
None,
);
- if preg_match(php_regex!(r"{^\s*\d+\s*$}"), &output_str).is_some() {
+ if preg_is_match(php_regex!(r"{^\s*\d+\s*$}"), &output_str) {
let ts = trim(&output_str, None).parse::<i64>().unwrap_or(0);
datetime = chrono::DateTime::from_timestamp(ts, 0);
}
diff --git a/crates/shirabe/src/package/package.rs b/crates/shirabe/src/package/package.rs
index cbc027ba..388280fd 100644
--- a/crates/shirabe/src/package/package.rs
+++ b/crates/shirabe/src/package/package.rs
@@ -11,8 +11,8 @@ use crate::util::ComposerMirror;
use chrono::{DateTime, Utc};
use indexmap::{IndexMap, IndexSet};
use shirabe_php_shim::{
- E_USER_DEPRECATED, LogicException, PhpMixed, PregMatches, php_regex, preg_match, preg_replace,
- preg_replace_callback, strpos, trigger_error,
+ E_USER_DEPRECATED, LogicException, PhpMixed, PregMatches, php_regex, preg_is_match,
+ preg_replace, preg_replace_callback, strpos, trigger_error,
};
/// Mirror entry, e.g. `['url' => 'https://...', 'preferred' => true]`.
@@ -416,10 +416,12 @@ impl Package {
// only bitbucket, github and gitlab have auto generated dist URLs that easily allow replacing the reference in the dist URL
// TODO generalize this a bit for self-managed/on-prem versions? Some kind of replace token in dist urls which allow this?
if self.get_dist_url().is_some()
- && preg_match(php_regex!(
- "{^https?://(?:(?:www\\.)?bitbucket\\.org|(api\\.)?github\\.com|(?:www\\.)?gitlab\\.com)/}i"
- ), &self.get_dist_url().unwrap_or_default())
- .is_some()
+ && preg_is_match(
+ php_regex!(
+ "{^https?://(?:(?:www\\.)?bitbucket\\.org|(api\\.)?github\\.com|(?:www\\.)?gitlab\\.com)/}i"
+ ),
+ &self.get_dist_url().unwrap_or_default(),
+ )
{
self.set_dist_reference(Some(reference.clone()));
// Regex pattern compatibility:
diff --git a/crates/shirabe/src/package/version/version_bumper.rs b/crates/shirabe/src/package/version/version_bumper.rs
index e75dea33..075663d4 100644
--- a/crates/shirabe/src/package/version/version_bumper.rs
+++ b/crates/shirabe/src/package/version/version_bumper.rs
@@ -6,7 +6,7 @@ use crate::package::loader::ArrayLoader;
use crate::package::version::VersionParser;
use crate::util::Platform;
use shirabe_php_shim::{
- CaptureKey, php_regex, preg_match, preg_match_all_offset_capture, preg_replace,
+ CaptureKey, php_regex, preg_is_match, preg_match_all_offset_capture, preg_replace,
};
use shirabe_semver::Intervals;
use shirabe_semver::constraint::AnyConstraint;
@@ -51,7 +51,7 @@ impl VersionBumper {
preg_replace(php_regex!(r"{(?:\.(?:0|9999999))+(-dev)?$}"), "", &version);
let new_pretty_constraint = format!("^{}", version_without_suffix);
- if preg_match(php_regex!(r"{^\^\d+(\.\d+)*$}"), &new_pretty_constraint).is_none() {
+ if !preg_is_match(php_regex!(r"{^\^\d+(\.\d+)*$}"), &new_pretty_constraint) {
return Ok(pretty_constraint);
}
diff --git a/crates/shirabe/src/package/version/version_guesser.rs b/crates/shirabe/src/package/version/version_guesser.rs
index 668fce02..3c47d5b2 100644
--- a/crates/shirabe/src/package/version/version_guesser.rs
+++ b/crates/shirabe/src/package/version/version_guesser.rs
@@ -14,8 +14,8 @@ use crate::util::sync_executor;
use indexmap::IndexMap;
use shirabe_php_shim::{
PhpMixed, RuntimeException, array_keys, array_map, array_merge, empty, function_exists,
- implode, is_string, json_encode, php_regex, preg_match, preg_quote, preg_replace, str_replace,
- strlen, strnatcasecmp, strpos, substr, trim, usort,
+ implode, is_string, json_encode, php_regex, preg_is_match, preg_match, preg_quote,
+ preg_replace, str_replace, strlen, strnatcasecmp, strpos, substr, trim, usort,
};
/// Seam over the parts of [`VersionGuesser`] that consumers depend on, so they can be exercised
@@ -156,11 +156,10 @@ impl VersionGuesser {
}
if "-dev" == substr(version_data.version.as_deref().unwrap_or(""), -4, None)
- && preg_match(
+ && preg_is_match(
php_regex!(r"{\.9{7}}"),
version_data.version.as_deref().unwrap_or(""),
)
- .is_some()
{
version_data.pretty_version = Some(preg_replace(
php_regex!(r"{(\.9{7})+}"),
@@ -181,11 +180,10 @@ impl VersionGuesser {
-4,
None,
)
- && preg_match(
+ && preg_is_match(
php_regex!(r"{\.9{7}}"),
version_data.feature_version.as_deref().unwrap_or(""),
)
- .is_some()
{
version_data.feature_pretty_version = Some(preg_replace(
php_regex!(r"{(\.9{7})+}"),
@@ -257,7 +255,7 @@ impl VersionGuesser {
}
if !branch.is_empty()
- && preg_match(php_regex!(r"{^ *.+/HEAD }"), &branch).is_none()
+ && !preg_is_match(php_regex!(r"{^ *.+/HEAD }"), &branch)
&& let Some(m) = preg_match(
php_regex!(
r"{^(?:\* )? *((?:remotes/(?:origin|upstream)/)?[^\s/]+) *([a-f0-9]+) .*$}"
@@ -608,10 +606,13 @@ impl VersionGuesser {
non_feature_branches = implode("|", &names);
}
- preg_match(format!(
- r"{{^({}|master|main|latest|next|current|support|tip|trunk|default|develop|\d+\..+)$}}",
- non_feature_branches,
- ), branch_name.unwrap_or("")).is_none()
+ !preg_is_match(
+ format!(
+ r"{{^({}|master|main|latest|next|current|support|tip|trunk|default|develop|\d+\..+)$}}",
+ non_feature_branches,
+ ),
+ branch_name.unwrap_or(""),
+ )
}
fn guess_fossil_version(&mut self, path: &str) -> anyhow::Result<VersionData> {
diff --git a/crates/shirabe/src/package/version/version_parser.rs b/crates/shirabe/src/package/version/version_parser.rs
index 6e7c5825..906e99f9 100644
--- a/crates/shirabe/src/package/version/version_parser.rs
+++ b/crates/shirabe/src/package/version/version_parser.rs
@@ -2,7 +2,7 @@
use crate::repository::PlatformRepository;
use indexmap::IndexMap;
-use shirabe_php_shim::{php_regex, preg_match, preg_replace};
+use shirabe_php_shim::{php_regex, preg_is_match, preg_replace};
use shirabe_semver::Semver;
use shirabe_semver::VersionParser as SemverVersionParser;
use shirabe_semver::constraint::AnyConstraint;
@@ -57,11 +57,10 @@ impl VersionParser {
if !pair.contains(' ')
&& i + 1 < count
&& !pairs[i + 1].contains('/')
- && preg_match(
+ && !preg_is_match(
php_regex!(r"{(?<=[a-z0-9_/-])\*|\*(?=[a-z0-9_/-])}i"),
&pairs[i + 1],
)
- .is_none()
&& !PlatformRepository::is_platform_package(&pairs[i + 1])
{
pair += &format!(" {}", pairs[i + 1]);
diff --git a/crates/shirabe/src/package/version/version_selector.rs b/crates/shirabe/src/package/version/version_selector.rs
index 91929c40..61435870 100644
--- a/crates/shirabe/src/package/version/version_selector.rs
+++ b/crates/shirabe/src/package/version/version_selector.rs
@@ -16,7 +16,9 @@ use crate::repository::PlatformRepository;
use crate::repository::RepositoryInterface;
use crate::repository::RepositorySetInterface;
use indexmap::IndexMap;
-use shirabe_php_shim::{CmpOp, php_regex, preg_match, preg_replace, strtolower, version_compare};
+use shirabe_php_shim::{
+ CmpOp, php_regex, preg_is_match, preg_replace, strtolower, version_compare,
+};
use shirabe_semver::constraint::AnyConstraint;
use shirabe_semver::constraint::SimpleConstraint;
@@ -302,7 +304,7 @@ impl VersionSelector {
let semantic_version_parts: Vec<&str> = version.split('.').collect();
if semantic_version_parts.len() == 4
- && preg_match(php_regex!(r"{^\d+\D?}"), semantic_version_parts[3]).is_some()
+ && preg_is_match(php_regex!(r"{^\d+\D?}"), semantic_version_parts[3])
{
let mut parts: Vec<String> = semantic_version_parts
.iter()
diff --git a/crates/shirabe/src/plugin/plugin_manager.rs b/crates/shirabe/src/plugin/plugin_manager.rs
index 28616903..2fff2d74 100644
--- a/crates/shirabe/src/plugin/plugin_manager.rs
+++ b/crates/shirabe/src/plugin/plugin_manager.rs
@@ -28,8 +28,8 @@ use indexmap::IndexMap;
use shirabe_php_rpc::{PluginValue, call_function_with_dispatcher};
use shirabe_php_shim::{
CmpOp, E_USER_DEPRECATED, PhpMixed, RuntimeException, UnexpectedValueException, dirname, empty,
- file_get_contents, implode, ksort, php_regex, preg_match, preg_quote, preg_replace2, strrpos,
- strtr_array, substr, trigger_error, trim, var_export, var_export_str, version_compare,
+ file_get_contents, implode, ksort, php_regex, preg_is_match, preg_quote, preg_replace2,
+ strrpos, strtr_array, substr, trigger_error, trim, var_export, var_export_str, version_compare,
};
use shirabe_semver::constraint::SimpleConstraint;
@@ -259,7 +259,7 @@ impl PluginManager {
}
if package.get_name() == "symfony/flex"
- && preg_match(php_regex!("{^[0-9.]+$}"), &package.get_version()).is_some()
+ && preg_is_match(php_regex!("{^[0-9.]+$}"), &package.get_version())
&& version_compare(&package.get_version(), "1.9.8", CmpOp::Lt)
{
self.io.write_error(&format!("<warning>The \"{}\" plugin {}was skipped because it is not compatible with Composer 2+. Make sure to update it to version 1.9.8 or greater.</warning>",
@@ -1242,7 +1242,7 @@ impl PluginManager {
.map(|(k, v)| (k.clone(), *v))
.collect();
for (pattern, allow) in &rules_snapshot {
- if preg_match(pattern, package).is_some() {
+ if preg_is_match(pattern, package) {
return Ok(*allow);
}
}
diff --git a/crates/shirabe/src/question/strict_confirmation_question.rs b/crates/shirabe/src/question/strict_confirmation_question.rs
index dbc39574..a0c1d92f 100644
--- a/crates/shirabe/src/question/strict_confirmation_question.rs
+++ b/crates/shirabe/src/question/strict_confirmation_question.rs
@@ -1,6 +1,6 @@
//! ref: composer/src/Composer/Question/StrictConfirmationQuestion.php
-use shirabe_php_shim::{PhpMixed, empty, is_bool, preg_match};
+use shirabe_php_shim::{PhpMixed, empty, is_bool, preg_is_match};
use shirabe_symfony_console::exception::InvalidArgumentException;
use shirabe_symfony_console::question::Question;
use shirabe_symfony_console::question::QuestionInterface;
@@ -53,10 +53,10 @@ impl StrictConfirmationQuestion {
return default.clone();
}
if let PhpMixed::String(s) = &answer {
- if preg_match(&true_regex, s).is_some() {
+ if preg_is_match(&true_regex, s) {
return PhpMixed::Bool(true);
}
- if preg_match(&false_regex, s).is_some() {
+ if preg_is_match(&false_regex, s) {
return PhpMixed::Bool(false);
}
}
diff --git a/crates/shirabe/src/repository/array_repository.rs b/crates/shirabe/src/repository/array_repository.rs
index b475b0e0..12b9714e 100644
--- a/crates/shirabe/src/repository/array_repository.rs
+++ b/crates/shirabe/src/repository/array_repository.rs
@@ -12,7 +12,7 @@ use crate::repository::{
RepositoryInterfaceHandle, RepositoryInterfaceWeakHandle, SearchResult,
};
use indexmap::IndexMap;
-use shirabe_php_shim::{implode, php_regex, preg_match, preg_quote, preg_split, strtolower};
+use shirabe_php_shim::{implode, php_regex, preg_is_match, preg_quote, preg_split, strtolower};
use shirabe_semver::constraint::AnyConstraint;
use shirabe_semver::constraint::SimpleConstraint;
use std::rc::Weak;
@@ -357,7 +357,7 @@ impl RepositoryInterface for ArrayRepository {
let fulltext_match = mode == crate::repository::SEARCH_FULLTEXT
&& complete.is_some()
- && preg_match(
+ && preg_is_match(
&regex,
&format!(
"{} {}",
@@ -368,10 +368,9 @@ impl RepositoryInterface for ArrayRepository {
.get_description()
.unwrap_or_default()
),
- )
- .is_some();
+ );
- if preg_match(&regex, &name).is_some() || fulltext_match {
+ if preg_is_match(&regex, &name) || fulltext_match {
if mode == crate::repository::SEARCH_VENDOR {
matches.insert(
name.clone(),
diff --git a/crates/shirabe/src/repository/composer_repository.rs b/crates/shirabe/src/repository/composer_repository.rs
index fbf9f767..79588fc5 100644
--- a/crates/shirabe/src/repository/composer_repository.rs
+++ b/crates/shirabe/src/repository/composer_repository.rs
@@ -43,7 +43,7 @@ use shirabe_php_shim::{
json_decode_assoc, parse_url, php_regex, preg_split, realpath, strtolower, strtr, urlencode,
var_export,
};
-use shirabe_php_shim::{Catch as _, preg_grep, preg_match, preg_replace};
+use shirabe_php_shim::{Catch as _, preg_grep, preg_is_match, preg_match, preg_replace};
use shirabe_semver::CompilingMatcher;
use shirabe_semver::constraint::AnyConstraint;
use shirabe_semver::constraint::MatchAllConstraint;
@@ -161,7 +161,7 @@ impl ComposerRepository {
.and_then(|v| v.as_string())
.unwrap_or("")
.to_string();
- if preg_match(php_regex!(r"{^[\w.]+\??://}"), &url_str).is_none() {
+ if !preg_is_match(php_regex!(r"{^[\w.]+\??://}"), &url_str) {
if let Some(local_file_path) = realpath(&url_str) {
// it is a local path, add file scheme
repo_config.insert(
@@ -2708,7 +2708,7 @@ impl ComposerRepository {
// url-encode $ signs in URLs as bad proxies choke on them
if let Some(pos) = filename.find('$')
&& pos > 0
- && preg_match(php_regex!(r"{^https?://}i"), &filename).is_some()
+ && preg_is_match(php_regex!(r"{^https?://}i"), &filename)
{
filename = format!("{}%24{}", &filename[..pos], &filename[pos + 1..]);
}
@@ -3307,7 +3307,7 @@ impl ComposerRepository {
if let Some(ref patterns) = self.available_package_patterns {
for provider_regex in patterns.iter() {
- if preg_match(provider_regex, name).is_some() {
+ if preg_is_match(provider_regex, name) {
return Ok(true);
}
}
diff --git a/crates/shirabe/src/repository/filter_repository.rs b/crates/shirabe/src/repository/filter_repository.rs
index 77236a21..77c492fa 100644
--- a/crates/shirabe/src/repository/filter_repository.rs
+++ b/crates/shirabe/src/repository/filter_repository.rs
@@ -9,7 +9,7 @@ use crate::repository::{
RepositoryInterfaceHandle, SearchResult,
};
use indexmap::IndexMap;
-use shirabe_php_shim::{InvalidArgumentException, PhpMixed, preg_match};
+use shirabe_php_shim::{InvalidArgumentException, PhpMixed, preg_is_match};
use shirabe_semver::constraint::AnyConstraint;
#[derive(Debug)]
@@ -123,14 +123,14 @@ impl FilterRepository {
}
if let Some(only) = &self.only {
- return preg_match(only, name).is_some();
+ return preg_is_match(only, name);
}
if self.exclude.is_none() {
return true;
}
- preg_match(self.exclude.as_ref().unwrap(), name).is_none()
+ !preg_is_match(self.exclude.as_ref().unwrap(), name)
}
}
diff --git a/crates/shirabe/src/repository/path_repository.rs b/crates/shirabe/src/repository/path_repository.rs
index 3d36f65c..05b68382 100644
--- a/crates/shirabe/src/repository/path_repository.rs
+++ b/crates/shirabe/src/repository/path_repository.rs
@@ -25,7 +25,7 @@ use crate::util::Url;
use indexmap::IndexMap;
use shirabe_php_shim::{
GLOB_BRACE, GLOB_MARK, GLOB_ONLYDIR, PhpMixed, RuntimeException, defined, file_exists,
- file_get_contents, glob_with_flags, hash, php_regex, preg_match, realpath, serialize,
+ file_get_contents, glob_with_flags, hash, php_regex, preg_is_match, realpath, serialize,
};
#[derive(Debug)]
@@ -158,9 +158,9 @@ impl PathRepository {
let url_matches = self.get_url_matches()?;
if url_matches.is_empty() {
- if preg_match(php_regex!(r"{[*{}]}"), &self.url).is_some() {
+ if preg_is_match(php_regex!(r"{[*{}]}"), &self.url) {
let mut url = self.url.clone();
- while preg_match(php_regex!(r"{[*{}]}"), &url).is_some() {
+ while preg_is_match(php_regex!(r"{[*{}]}"), &url) {
url = shirabe_php_shim::dirname(&url);
}
// the parent directory before any wildcard exists, so we assume it is correctly configured but simply empty
diff --git a/crates/shirabe/src/repository/platform_repository.rs b/crates/shirabe/src/repository/platform_repository.rs
index 839d17d6..30627dbf 100644
--- a/crates/shirabe/src/repository/platform_repository.rs
+++ b/crates/shirabe/src/repository/platform_repository.rs
@@ -19,8 +19,8 @@ use indexmap::IndexMap;
use shirabe_php_rpc::PlatformInfo;
use shirabe_php_shim::{
InvalidArgumentException, PhpMixed, UnexpectedValueException, array_map_str_fn,
- array_slice_strs, explode, get_class, implode, is_string, php_regex, preg_match, preg_replace,
- str_replace, strpos, strtolower, var_export,
+ array_slice_strs, explode, get_class, implode, is_string, php_regex, preg_is_match, preg_match,
+ preg_replace, str_replace, strpos, strtolower, var_export,
};
use shirabe_semver::constraint::SimpleConstraint;
use std::sync::{LazyLock, Mutex};
@@ -1604,7 +1604,7 @@ impl PlatformRepository {
return cached;
}
- let result = preg_match(Self::PLATFORM_PACKAGE_REGEX, name).is_some();
+ let result = preg_is_match(Self::PLATFORM_PACKAGE_REGEX, name);
cache.insert(name.to_string(), result);
result
}
diff --git a/crates/shirabe/src/repository/vcs/fossil_driver.rs b/crates/shirabe/src/repository/vcs/fossil_driver.rs
index d5a9334f..9a678284 100644
--- a/crates/shirabe/src/repository/vcs/fossil_driver.rs
+++ b/crates/shirabe/src/repository/vcs/fossil_driver.rs
@@ -13,7 +13,7 @@ use chrono::{DateTime, FixedOffset, Utc};
use indexmap::IndexMap;
use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
- PhpMixed, RuntimeException, dirname, is_dir, is_file, is_writable, php_regex, preg_match,
+ PhpMixed, RuntimeException, dirname, is_dir, is_file, is_writable, php_regex, preg_is_match,
preg_replace,
};
@@ -301,16 +301,14 @@ impl FossilDriver {
url: &str,
deep: bool,
) -> anyhow::Result<bool> {
- if preg_match(
+ if preg_is_match(
php_regex!(r"#(^(?:https?|ssh)://(?:[^@]@)?(?:chiselapp\.com|fossil\.))#i"),
url,
- )
- .is_some()
- {
+ ) {
return Ok(true);
}
- if preg_match(php_regex!(r"!/fossil/|\.fossil!"), url).is_some() {
+ if preg_is_match(php_regex!(r"!/fossil/|\.fossil!"), url) {
return Ok(true);
}
diff --git a/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs b/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs
index a05e9835..b1960974 100644
--- a/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs
+++ b/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs
@@ -19,7 +19,7 @@ use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
InvalidArgumentException, LogicException, PhpMixed, RuntimeException, array_key_exists,
array_search_mixed, extension_loaded, http_build_query, implode, is_array, php_regex,
- preg_match, preg_replace, strpos,
+ preg_is_match, preg_match, preg_replace, strpos,
};
#[derive(Debug)]
@@ -797,12 +797,10 @@ impl GitBitbucketDriver {
url: &str,
_deep: bool,
) -> anyhow::Result<bool> {
- if preg_match(
+ if !preg_is_match(
php_regex!(r"#^https?://bitbucket\.org/([^/]+)/([^/]+?)(\.git|/?)?$#i"),
url,
- )
- .is_none()
- {
+ ) {
return Ok(false);
}
diff --git a/crates/shirabe/src/repository/vcs/git_driver.rs b/crates/shirabe/src/repository/vcs/git_driver.rs
index 63598517..f45dbcaa 100644
--- a/crates/shirabe/src/repository/vcs/git_driver.rs
+++ b/crates/shirabe/src/repository/vcs/git_driver.rs
@@ -16,8 +16,8 @@ use chrono::{DateTime, FixedOffset, Utc};
use indexmap::IndexMap;
use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
- InvalidArgumentException, RuntimeException, dirname, is_dir, is_writable, preg_match,
- preg_replace, realpath, sys_get_temp_dir,
+ InvalidArgumentException, RuntimeException, dirname, is_dir, is_writable, preg_is_match,
+ preg_match, preg_replace, realpath, sys_get_temp_dir,
};
use shirabe_php_shim::{PhpMixed, php_regex};
@@ -98,7 +98,7 @@ impl GitDriver {
.into());
}
- if preg_match(php_regex!(r"{^ssh://[^@]+@[^:]+:[^0-9]+}"), &self.inner.url).is_some() {
+ if preg_is_match(php_regex!(r"{^ssh://[^@]+@[^:]+:[^0-9]+}"), &self.inner.url) {
return Err(InvalidArgumentException::new(format!(
"The source URL {} is invalid, ssh URLs should have a port number after \":\".\nUse ssh://git@example.com:22/path or just git@example.com:path if you do not want to provide a password or custom port.",
self.inner.url
@@ -343,7 +343,7 @@ impl GitDriver {
);
for branch in self.inner.process.borrow().split_lines(&output) {
if !branch.is_empty()
- && preg_match(php_regex!(r"{^ *[^/]+/HEAD }"), &branch).is_none()
+ && !preg_is_match(php_regex!(r"{^ *[^/]+/HEAD }"), &branch)
&& let Some(caps) = preg_match(
php_regex!(r"{^(?:\* )? *(\S+) *([a-f0-9]+)(?: .*)?$}"),
&branch,
@@ -367,12 +367,10 @@ impl GitDriver {
url: &str,
deep: bool,
) -> anyhow::Result<bool> {
- if preg_match(
+ if preg_is_match(
php_regex!(r"#(^git://|\.git/?$|git(?:olite)?@|//git\.|//github.com/)#i"),
url,
- )
- .is_some()
- {
+ ) {
return Ok(true);
}
diff --git a/crates/shirabe/src/repository/vcs/github_driver.rs b/crates/shirabe/src/repository/vcs/github_driver.rs
index f310da3d..c41cc2d0 100644
--- a/crates/shirabe/src/repository/vcs/github_driver.rs
+++ b/crates/shirabe/src/repository/vcs/github_driver.rs
@@ -18,8 +18,8 @@ use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
InvalidArgumentException, PhpMixed, RuntimeException, array_diff, array_map,
array_search_mixed, base64_decode, basename, empty, explode, extension_loaded, in_array_loose,
- parse_url, php_regex, preg_match, preg_replace, preg_split, strpos, strtolower, substr, trim,
- urlencode,
+ parse_url, php_regex, preg_is_match, preg_match, preg_replace, preg_split, strpos, strtolower,
+ substr, trim, urlencode,
};
#[derive(Debug)]
@@ -642,9 +642,7 @@ impl GitHubDriver {
};
if bits.scheme.is_none() && bits.host.is_none() {
- if preg_match(php_regex!(r"{^[a-z0-9-]++\.[a-z]{2,3}$}"), &item_url)
- .is_some()
- {
+ if preg_is_match(php_regex!(r"{^[a-z0-9-]++\.[a-z]{2,3}$}"), &item_url) {
result[key_idx].insert(
"url".to_string(),
PhpMixed::String(format!("https://{}", item_url)),
diff --git a/crates/shirabe/src/repository/vcs/gitlab_driver.rs b/crates/shirabe/src/repository/vcs/gitlab_driver.rs
index 229d043b..b40297da 100644
--- a/crates/shirabe/src/repository/vcs/gitlab_driver.rs
+++ b/crates/shirabe/src/repository/vcs/gitlab_driver.rs
@@ -19,7 +19,7 @@ use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
InvalidArgumentException, LogicException, PhpMixed, RuntimeException, array_search_mixed,
array_shift, ctype_alnum, empty, explode, extension_loaded, implode, in_array_loose, is_array,
- is_string, ord, php_regex, preg_match, preg_replace, strpos, strtolower,
+ is_string, ord, php_regex, preg_is_match, preg_match, preg_replace, strpos, strtolower,
};
/// Driver for GitLab API, use the Git driver for local checkouts.
@@ -382,7 +382,7 @@ impl GitLabDriver {
// Convert the root identifier to a cacheable commit id
let mut identifier = identifier.to_string();
- if preg_match(php_regex!(r"{[a-f0-9]{40}}i"), &identifier).is_none() {
+ if !preg_is_match(php_regex!(r"{[a-f0-9]{40}}i"), &identifier) {
let branches = self.get_branches()?;
if let Some(sha) = branches.get(&identifier) {
identifier = sha.clone();
diff --git a/crates/shirabe/src/repository/vcs/hg_driver.rs b/crates/shirabe/src/repository/vcs/hg_driver.rs
index 977d6b97..54341070 100644
--- a/crates/shirabe/src/repository/vcs/hg_driver.rs
+++ b/crates/shirabe/src/repository/vcs/hg_driver.rs
@@ -13,7 +13,8 @@ use chrono::{DateTime, FixedOffset, Utc};
use indexmap::IndexMap;
use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
- PhpMixed, RuntimeException, dirname, is_dir, is_writable, php_regex, preg_match, preg_replace,
+ PhpMixed, RuntimeException, dirname, is_dir, is_writable, php_regex, preg_is_match, preg_match,
+ preg_replace,
};
#[derive(Debug)]
@@ -305,14 +306,12 @@ impl HgDriver {
url: &str,
deep: bool,
) -> anyhow::Result<bool> {
- if preg_match(
+ if preg_is_match(
php_regex!(
r"#(^(?:https?|ssh)://(?:[^@]+@)?bitbucket.org|https://(?:.*?)\.kilnhg.com)#i"
),
url,
- )
- .is_some()
- {
+ ) {
return Ok(true);
}
diff --git a/crates/shirabe/src/repository/vcs/perforce_driver.rs b/crates/shirabe/src/repository/vcs/perforce_driver.rs
index 16dad1e9..d55d361c 100644
--- a/crates/shirabe/src/repository/vcs/perforce_driver.rs
+++ b/crates/shirabe/src/repository/vcs/perforce_driver.rs
@@ -9,7 +9,9 @@ use crate::util::PerforceInterface;
use crate::util::ProcessExecutor;
use crate::util::http::Response;
use indexmap::IndexMap;
-use shirabe_php_shim::{BadMethodCallException, PhpMixed, RuntimeException, php_regex, preg_match};
+use shirabe_php_shim::{
+ BadMethodCallException, PhpMixed, RuntimeException, php_regex, preg_is_match,
+};
#[derive(Debug)]
pub struct PerforceDriver {
@@ -188,7 +190,7 @@ impl PerforceDriver {
url: &str,
deep: bool,
) -> anyhow::Result<bool> {
- if deep || preg_match(php_regex!(r"#\b(perforce|p4)\b#i"), url).is_some() {
+ if deep || preg_is_match(php_regex!(r"#\b(perforce|p4)\b#i"), url) {
return Ok(Perforce::check_server_exists(
url,
&mut ProcessExecutor::new(Some(io)),
diff --git a/crates/shirabe/src/repository/vcs/svn_driver.rs b/crates/shirabe/src/repository/vcs/svn_driver.rs
index 28239452..0431c33b 100644
--- a/crates/shirabe/src/repository/vcs/svn_driver.rs
+++ b/crates/shirabe/src/repository/vcs/svn_driver.rs
@@ -15,8 +15,8 @@ use chrono::{DateTime, FixedOffset, Utc};
use indexmap::IndexMap;
use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
- PhpMixed, RuntimeException, php_regex, preg_match, preg_replace, stripos, strrpos, strtr,
- substr, trim,
+ PhpMixed, RuntimeException, php_regex, preg_is_match, preg_match, preg_replace, stripos,
+ strrpos, strtr, substr, trim,
};
#[derive(Debug)]
@@ -153,7 +153,7 @@ impl SvnDriver {
}
fn should_cache(&self, identifier: &str) -> bool {
- self.inner.cache.is_some() && preg_match(php_regex!(r"{@\d+$}"), identifier).is_some()
+ self.inner.cache.is_some() && preg_is_match(php_regex!(r"{@\d+$}"), identifier)
}
pub fn get_composer_information(
@@ -440,7 +440,7 @@ impl SvnDriver {
deep: bool,
) -> anyhow::Result<bool> {
let url = Self::normalize_url(url);
- if preg_match(php_regex!(r"#(^svn://|^svn\+ssh://|svn\.)#i"), &url).is_some() {
+ if preg_is_match(php_regex!(r"#(^svn://|^svn\+ssh://|svn\.)#i"), &url) {
return Ok(true);
}
diff --git a/crates/shirabe/src/repository/vcs/vcs_driver.rs b/crates/shirabe/src/repository/vcs/vcs_driver.rs
index 439275f1..17616c36 100644
--- a/crates/shirabe/src/repository/vcs/vcs_driver.rs
+++ b/crates/shirabe/src/repository/vcs/vcs_driver.rs
@@ -13,7 +13,7 @@ use crate::util::http::Response;
use chrono::{DateTime, FixedOffset};
use indexmap::IndexMap;
use shirabe_php_shim::Catch as _;
-use shirabe_php_shim::{DATE_RFC3339, PhpMixed, extension_loaded, php_regex, preg_match};
+use shirabe_php_shim::{DATE_RFC3339, PhpMixed, extension_loaded, php_regex, preg_is_match};
#[derive(Debug)]
pub struct VcsDriverBase {
@@ -56,7 +56,7 @@ impl VcsDriverBase {
}
pub fn should_cache(&self, identifier: &str) -> bool {
- self.cache.is_some() && preg_match(php_regex!("{^[a-f0-9]{40}$}iD"), identifier).is_some()
+ self.cache.is_some() && preg_is_match(php_regex!("{^[a-f0-9]{40}$}iD"), identifier)
}
pub fn get_scheme(&self) -> &str {
@@ -201,7 +201,7 @@ pub trait VcsDriver: VcsDriverInterface {
fn cache_mut(&mut self) -> Option<&mut Cache>;
fn should_cache(&self, identifier: &str) -> bool {
- self.cache().is_some() && preg_match(php_regex!("{^[a-f0-9]{40}$}iD"), identifier).is_some()
+ self.cache().is_some() && preg_is_match(php_regex!("{^[a-f0-9]{40}$}iD"), identifier)
}
fn get_composer_information(
diff --git a/crates/shirabe/src/repository/vcs_repository.rs b/crates/shirabe/src/repository/vcs_repository.rs
index f22ab618..6cdc957a 100644
--- a/crates/shirabe/src/repository/vcs_repository.rs
+++ b/crates/shirabe/src/repository/vcs_repository.rs
@@ -29,8 +29,8 @@ use crate::util::Url;
use indexmap::IndexMap;
use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
- InvalidArgumentException, PhpClass, PhpMixed, php_regex, preg_match, preg_replace, str_replace,
- strpos,
+ InvalidArgumentException, PhpClass, PhpMixed, php_regex, preg_is_match, preg_replace,
+ str_replace, strpos,
};
use shirabe_semver::constraint::SimpleConstraint;
@@ -510,7 +510,7 @@ impl VcsRepository {
// broken package, version doesn't match tag
if version_normalized != parsed_tag {
if is_very_verbose {
- if preg_match(php_regex!(r"{(^dev-|[.-]?dev$)}i"), &parsed_tag).is_some() {
+ if preg_is_match(php_regex!(r"{(^dev-|[.-]?dev$)}i"), &parsed_tag) {
self.io.write_error(&format!(
"<warning>Skipped tag {}, invalid tag name, tags can not use dev prefixes or suffixes</warning>",
tag
diff --git a/crates/shirabe/src/self_update/versions.rs b/crates/shirabe/src/self_update/versions.rs
index f5800a65..70c6c187 100644
--- a/crates/shirabe/src/self_update/versions.rs
+++ b/crates/shirabe/src/self_update/versions.rs
@@ -6,7 +6,7 @@ use crate::io::IOInterfaceImmutable;
use crate::util::HttpDownloader;
use indexmap::IndexMap;
use shirabe_php_shim::{
- InvalidArgumentException, PHP_EOL, PhpMixed, UnexpectedValueException, php_regex, preg_match,
+ InvalidArgumentException, PHP_EOL, PhpMixed, UnexpectedValueException, php_regex, preg_is_match,
};
pub struct Versions {
@@ -89,7 +89,7 @@ impl Versions {
self.channel = Some(channel.clone());
// rewrite '2' and '1' channels to stable for future self-updates, but LTS ones like '2.2' remain pinned
- let stored_channel = if preg_match(php_regex!(r"{^\d+$}D"), &channel).is_some() {
+ let stored_channel = if preg_is_match(php_regex!(r"{^\d+$}D"), &channel) {
"stable".to_string()
} else {
channel
diff --git a/crates/shirabe/src/util/auth_helper.rs b/crates/shirabe/src/util/auth_helper.rs
index 3da49258..72f50aa3 100644
--- a/crates/shirabe/src/util/auth_helper.rs
+++ b/crates/shirabe/src/util/auth_helper.rs
@@ -11,7 +11,7 @@ use crate::util::GitLab;
use indexmap::IndexMap;
use shirabe_php_shim::{
PhpMixed, RuntimeException, base64_encode, explode, in_array_loose, in_array_strict, is_array,
- is_string, json_decode_assoc, parse_url, php_regex, preg_match, str_replace, strpos,
+ is_string, json_decode_assoc, parse_url, php_regex, preg_is_match, str_replace, strpos,
strtolower, substr, trim,
};
@@ -536,7 +536,7 @@ impl AuthHelper {
}
} else if origin == "github.com" && password == "x-oauth-basic" {
// only add the access_token if it is actually a github API URL
- if preg_match(php_regex!(r"{^https?://api\.github\.com/}"), url).is_some() {
+ if preg_is_match(php_regex!(r"{^https?://api\.github\.com/}"), url) {
headers.push(PhpMixed::String(format!(
"Authorization: token {}",
username,
diff --git a/crates/shirabe/src/util/composer_mirror.rs b/crates/shirabe/src/util/composer_mirror.rs
index 0fb38716..910c3835 100644
--- a/crates/shirabe/src/util/composer_mirror.rs
+++ b/crates/shirabe/src/util/composer_mirror.rs
@@ -1,6 +1,6 @@
//! ref: composer/src/Composer/Util/ComposerMirror.php
-use shirabe_php_shim::{hash, php_regex, preg_match, preg_replace};
+use shirabe_php_shim::{hash, php_regex, preg_is_match, preg_match, preg_replace};
pub struct ComposerMirror;
@@ -14,7 +14,7 @@ impl ComposerMirror {
pretty_version: Option<&str>,
) -> String {
let reference = reference.map(|r| {
- if preg_match(php_regex!(r"{^([a-f0-9]*|%reference%)$}"), r).is_some() {
+ if preg_is_match(php_regex!(r"{^([a-f0-9]*|%reference%)$}"), r) {
r.to_string()
} else {
hash("md5", r)
diff --git a/crates/shirabe/src/util/config_validator.rs b/crates/shirabe/src/util/config_validator.rs
index e9282a9f..f8018fe5 100644
--- a/crates/shirabe/src/util/config_validator.rs
+++ b/crates/shirabe/src/util/config_validator.rs
@@ -10,7 +10,7 @@ use crate::package::loader::ValidatingArrayLoader;
use indexmap::IndexMap;
use serde::de::Error as _;
use shirabe_php_shim::Catch as _;
-use shirabe_php_shim::{PhpMixed, php_regex, preg_match, preg_replace};
+use shirabe_php_shim::{PhpMixed, php_regex, preg_is_match, preg_replace};
use shirabe_spdx_licenses::SpdxLicenses;
#[derive(Debug)]
@@ -117,16 +117,13 @@ impl ConfigValidator {
for license in &licenses {
let spdx_license = license_validator.get_license_by_identifier(license);
if spdx_license.is_some_and(|l| l.is_deprecated_license_id) {
- if preg_match(php_regex!(r"{^[AL]?GPL-[123](\.[01])?\+$}i"), license).is_some()
- {
+ if preg_is_match(php_regex!(r"{^[AL]?GPL-[123](\.[01])?\+$}i"), license) {
warnings.push(format!(
"License \"{}\" is a deprecated SPDX license identifier, use \"{}-or-later\" instead",
license,
license.replace('+', "")
));
- } else if preg_match(php_regex!(r"{^[AL]?GPL-[123](\.[01])?$}i"), license)
- .is_some()
- {
+ } else if preg_is_match(php_regex!(r"{^[AL]?GPL-[123](\.[01])?$}i"), license) {
warnings.push(format!(
"License \"{}\" is a deprecated SPDX license identifier, use \"{}-only\" or \"{}-or-later\" instead",
license, license, license
@@ -147,7 +144,7 @@ impl ConfigValidator {
if let Some(PhpMixed::String(name)) = manifest.get("name")
&& !name.is_empty()
- && preg_match(php_regex!(r"{[A-Z]}"), name).is_some()
+ && preg_is_match(php_regex!(r"{[A-Z]}"), name)
{
let suggest_name = preg_replace(
php_regex!(r"{(?:([a-z])([A-Z])|([A-Z])([A-Z][a-z]))}"),
@@ -224,7 +221,7 @@ impl ConfigValidator {
packages.extend(require_dev);
for (package, version) in &packages {
if let PhpMixed::String(version_str) = version
- && preg_match(php_regex!(r"{#}"), version_str).is_some()
+ && preg_is_match(php_regex!(r"{#}"), version_str)
{
warnings.push(format!(
"The package \"{}\" is pointing to a commit-ref, this is bad practice and can cause unforeseen issues.",
diff --git a/crates/shirabe/src/util/filesystem.rs b/crates/shirabe/src/util/filesystem.rs
index ae19a998..41b81b7b 100644
--- a/crates/shirabe/src/util/filesystem.rs
+++ b/crates/shirabe/src/util/filesystem.rs
@@ -8,9 +8,9 @@ use shirabe_php_shim::{
chdir, clearstatcache, clearstatcache2, copy, dirname, explode, fclose, feof, file_exists,
file_get_contents, file_put_contents, fileatime, filemtime, filesize, fopen, fread,
function_exists, fwrite, implode, is_dir, is_file, is_link, is_readable, lstat, mkdir,
- php_regex, preg_match, preg_replace, preg_replace_callback, rename, rmdir, rtrim, str_repeat,
- str_replace, strlen, strpos, strtoupper, strtr, substr, substr_count, symlink, touch, unlink,
- usleep, var_export,
+ php_regex, preg_is_match, preg_match, preg_replace, preg_replace_callback, rename, rmdir,
+ rtrim, str_repeat, str_replace, strlen, strpos, strtoupper, strtr, substr, substr_count,
+ symlink, touch, unlink, usleep, var_export,
};
use shirabe_symfony_filesystem::exception::IOException;
use shirabe_symfony_finder::Finder;
@@ -246,7 +246,7 @@ impl Filesystem {
return Ok(Some(true));
}
- if preg_match(php_regex!("{^(?:[a-z]:)?[/\\\\]+$}i"), directory).is_some() {
+ if preg_is_match(php_regex!("{^(?:[a-z]:)?[/\\\\]+$}i"), directory) {
return Err(RuntimeException::new(format!("Aborting an attempted deletion of {}, this was probably not intended, if it is a real use case please report it.", directory))
.into());
}
@@ -578,7 +578,7 @@ impl Filesystem {
let mut common_path = to.clone();
while strpos(&format!("{}/", from), &format!("{}/", common_path)) != Some(0)
&& "/" != common_path
- && preg_match(php_regex!("{^[A-Z]:/?$}i"), &common_path).is_none()
+ && !preg_is_match(php_regex!("{^[A-Z]:/?$}i"), &common_path)
{
common_path = strtr(&dirname(&common_path), "\\", "/");
}
@@ -635,7 +635,7 @@ impl Filesystem {
let mut common_path = to.clone();
while strpos(&format!("{}/", from), &format!("{}/", common_path)) != Some(0)
&& "/" != common_path
- && preg_match(php_regex!("{^[A-Z]:/?$}i"), &common_path).is_none()
+ && !preg_is_match(php_regex!("{^[A-Z]:/?$}i"), &common_path)
&& "." != common_path
{
common_path = strtr(&dirname(&common_path), "\\", "/");
@@ -778,7 +778,7 @@ impl Filesystem {
/// And other possible unforeseen disasters, see https://github.com/composer/composer/pull/9422
pub fn trim_trailing_slash(path: &str) -> String {
let mut path = path.to_string();
- if preg_match(php_regex!("{^[/\\\\]+$}"), &path).is_none() {
+ if !preg_is_match(php_regex!("{^[/\\\\]+$}"), &path) {
path = rtrim(&path, Some("/\\"));
}
@@ -790,20 +790,18 @@ impl Filesystem {
// on windows, \\foo indicates network paths so we exclude those from local paths, however it is unsafe
// on linux as file:////foo (which would be a network path \\foo on windows) will resolve to /foo which could be a local path
if Platform::is_windows() {
- return preg_match(
+ return preg_is_match(
php_regex!(
"{^(file://(?!//)|/(?!/)|/?[a-z]:[\\\\/]|\\.\\.[\\\\/]|[a-z0-9_.-]+[\\\\/])}i"
),
path,
- )
- .is_some();
+ );
}
- preg_match(
+ preg_is_match(
php_regex!("{^(file://|/|/?[a-z]:[\\\\/]|\\.\\.[\\\\/]|[a-z0-9_.-]+[\\\\/])}i"),
path,
)
- .is_some()
}
pub fn get_platform_path(path: &str) -> String {
diff --git a/crates/shirabe/src/util/git.rs b/crates/shirabe/src/util/git.rs
index 2426780f..78c1acb5 100644
--- a/crates/shirabe/src/util/git.rs
+++ b/crates/shirabe/src/util/git.rs
@@ -17,8 +17,8 @@ use indexmap::IndexMap;
use shirabe_php_shim::{
AnyThrowable, CmpOp, InvalidArgumentException, PHP_EOL, PhpMixed, PregMatches,
RuntimeException, array_map, clearstatcache, explode, implode, in_array_loose, in_array_strict,
- is_dir, php_regex, preg_match, preg_quote, preg_replace, rawurldecode, rawurlencode,
- str_replace_array, strlen, strpos, substr, trim, version_compare,
+ is_dir, php_regex, preg_is_match, preg_match, preg_quote, preg_replace, rawurldecode,
+ rawurlencode, str_replace_array, strlen, strpos, substr, trim, version_compare,
};
use std::sync::Mutex;
@@ -209,7 +209,7 @@ impl Git {
status
};
- if preg_match(php_regex!(r"{^ssh://[^@]+@[^:]+:[^0-9]+}"), url).is_some() {
+ if preg_is_match(php_regex!(r"{^ssh://[^@]+@[^:]+:[^0-9]+}"), url) {
return Err(InvalidArgumentException::new(format!(
"The source URL {} is invalid, ssh URLs should have a port number after \":\".\nUse ssh://git@example.com:22/path or just git@example.com:path if you do not want to provide a password or custom port.",
url
@@ -310,21 +310,19 @@ impl Git {
.collect(),
_ => vec![],
};
- let bypass_ssh_for_github = preg_match(
+ let bypass_ssh_for_github = preg_is_match(
format!(
"{{^git@{}:(.+?)\\.git$}}i",
Self::get_github_domains_regex(&self.config.borrow())
),
url,
- )
- .is_some()
- && !in_array_strict(
- "ssh".to_string(),
- &protocols_list
- .iter()
- .map(|s| PhpMixed::String(s.clone()))
- .collect::<Vec<_>>(),
- );
+ ) && !in_array_strict(
+ "ssh".to_string(),
+ &protocols_list
+ .iter()
+ .map(|s| PhpMixed::String(s.clone()))
+ .collect::<Vec<_>>(),
+ );
let mut auth: Option<IndexMap<String, Option<String>>> = None;
let mut credentials: Vec<String> = vec![];
@@ -915,7 +913,7 @@ impl Git {
pretty_version: Option<&str>,
) -> anyhow::Result<bool> {
if self.check_ref_is_in_mirror(dir, r#ref)? {
- if preg_match(php_regex!(r"{^[a-f0-9]{40}$}"), r#ref).is_some()
+ if preg_is_match(php_regex!(r"{^[a-f0-9]{40}$}"), r#ref)
&& let Some(pretty_version) = pretty_version
{
let branch = preg_replace(
@@ -949,17 +947,15 @@ impl Git {
// this can occur if a git tag gets created *after* the reference is already put into the cache, as the ref check above will then not sync the new tags
// see https://github.com/composer/composer/discussions/11002
if branches.is_some()
- && preg_match(
+ && !preg_is_match(
format!(r"{{^[\s*]*v?{}$}}m", preg_quote(&branch, None)),
branches.as_deref().unwrap_or(""),
)
- .is_none()
&& tags.is_some()
- && preg_match(
+ && !preg_is_match(
format!(r"{{^[\s*]*{}$}}m", preg_quote(&branch, None)),
tags.as_deref().unwrap_or(""),
)
- .is_none()
{
self.sync_mirror(url, dir)?;
}
diff --git a/crates/shirabe/src/util/github.rs b/crates/shirabe/src/util/github.rs
index a50f928a..ccfedcf8 100644
--- a/crates/shirabe/src/util/github.rs
+++ b/crates/shirabe/src/util/github.rs
@@ -10,7 +10,7 @@ use crate::util::ProcessExecutor;
use indexmap::IndexMap;
use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
- PhpMixed, date_local, in_array_loose, php_regex, preg_match, stripos, strtolower,
+ PhpMixed, date_local, in_array_loose, php_regex, preg_is_match, preg_match, stripos, strtolower,
};
#[derive(Debug)]
@@ -336,7 +336,7 @@ impl GitHub {
pub fn is_rate_limited(&self, headers: &[String]) -> bool {
for header in headers {
- if preg_match(php_regex!(r"{^x-ratelimit-remaining: *0$}i"), header.trim()).is_some() {
+ if preg_is_match(php_regex!(r"{^x-ratelimit-remaining: *0$}i"), header.trim()) {
return true;
}
}
@@ -346,7 +346,7 @@ impl GitHub {
pub fn requires_sso(&self, headers: &[String]) -> bool {
for header in headers {
- if preg_match(php_regex!(r"{^x-github-sso: required}i"), header.trim()).is_some() {
+ if preg_is_match(php_regex!(r"{^x-github-sso: required}i"), header.trim()) {
return true;
}
}
diff --git a/crates/shirabe/src/util/http/curl_downloader.rs b/crates/shirabe/src/util/http/curl_downloader.rs
index 6754f784..b1e89a07 100644
--- a/crates/shirabe/src/util/http/curl_downloader.rs
+++ b/crates/shirabe/src/util/http/curl_downloader.rs
@@ -32,7 +32,7 @@ use crate::util::http::Response;
use crate::util::{AuthHelper, PromptAuthResult, StoreAuth};
use indexmap::IndexMap;
use shirabe_php_shim::{
- PhpMixed, in_array_loose, in_array_strict, parse_url, php_regex, preg_match, preg_quote,
+ PhpMixed, in_array_loose, in_array_strict, parse_url, php_regex, preg_is_match, preg_quote,
preg_replace, rename, strpos, substr, unlink_silent,
};
use std::sync::atomic::{AtomicBool, Ordering};
@@ -146,7 +146,7 @@ impl CurlDownloader {
// check URL can be accessed (i.e. is not insecure), but allow insecure Packagist calls to
// $hashed providers as file integrity is verified with sha256
- if preg_match(php_regex!(r"{^http://(repo\.)?packagist\.org/p/}"), url).is_none()
+ if !preg_is_match(php_regex!(r"{^http://(repo\.)?packagist\.org/p/}"), url)
|| (strpos(url, "$").is_none() && strpos(url, "%24").is_none())
{
self.config.borrow_mut().prohibit_url_by_config(
@@ -746,14 +746,13 @@ impl CurlDownloader {
&& substr(url, -4, None) == ".zip"
&& (location_header.is_none()
|| substr(location_header.as_deref().unwrap_or(""), -4, None) != ".zip")
- && preg_match(
+ && preg_is_match(
php_regex!(r"{^text/html\b}i"),
&response
.inner
.get_header("content-type")
.unwrap_or_default(),
)
- .is_some()
{
needs_auth_retry = Some("Bitbucket requires authentication and it was not provided");
}
diff --git a/crates/shirabe/src/util/http/response.rs b/crates/shirabe/src/util/http/response.rs
index 6fe95200..4f824baa 100644
--- a/crates/shirabe/src/util/http/response.rs
+++ b/crates/shirabe/src/util/http/response.rs
@@ -1,7 +1,7 @@
//! ref: composer/src/Composer/Util/Http/Response.php
use crate::json::JsonFile;
-use shirabe_php_shim::{PhpMixed, php_regex, preg_match, preg_quote};
+use shirabe_php_shim::{PhpMixed, php_regex, preg_is_match, preg_match, preg_quote};
#[derive(Debug)]
pub struct Response {
@@ -28,7 +28,7 @@ impl Response {
pub fn get_status_message(&self) -> Option<String> {
let mut value = None;
for header in &self.headers {
- if preg_match(php_regex!(r"{^HTTP/\S+ \d+}i"), header).is_some() {
+ if preg_is_match(php_regex!(r"{^HTTP/\S+ \d+}i"), header) {
// In case of redirects, headers contain the headers of all responses
// so we can not return directly and need to keep iterating
value = Some(header.clone());
diff --git a/crates/shirabe/src/util/http_downloader.rs b/crates/shirabe/src/util/http_downloader.rs
index f022ef4e..36ccb712 100644
--- a/crates/shirabe/src/util/http_downloader.rs
+++ b/crates/shirabe/src/util/http_downloader.rs
@@ -19,8 +19,8 @@ use indexmap::IndexMap;
use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
InvalidArgumentException, LogicException, PhpMixed, array_replace_recursive, extension_loaded,
- file_get_contents, function_exists, implode, is_numeric, php_regex, preg_match, preg_replace,
- rawurldecode, stream_context_create, stripos, strpos, substr, ucfirst,
+ file_get_contents, function_exists, implode, is_numeric, php_regex, preg_is_match, preg_match,
+ preg_replace, rawurldecode, stream_context_create, stripos, strpos, substr, ucfirst,
};
use shirabe_semver::constraint::SimpleConstraint;
@@ -485,7 +485,7 @@ impl HttpDownloader {
return false;
}
- if preg_match(php_regex!(r"{^https?://}i"), url).is_none() {
+ if !preg_is_match(php_regex!(r"{^https?://}i"), url) {
return false;
}
diff --git a/crates/shirabe/src/util/platform.rs b/crates/shirabe/src/util/platform.rs
index 3daf17c6..ccee2953 100644
--- a/crates/shirabe/src/util/platform.rs
+++ b/crates/shirabe/src/util/platform.rs
@@ -6,7 +6,7 @@ use shirabe_php_shim::{
PHP_ENV, PHP_SERVER, PhpMixed, PhpResource, PregMatches, RuntimeException, defined,
file_exists, file_get_contents, fstat, function_exists, getcwd, getenv, ini_get, is_readable,
mb_strlen, php_os_family, php_regex, posix_geteuid, posix_getpwuid, posix_getuid, posix_isatty,
- preg_match, preg_replace_callback, putenv, putenv_clear, realpath, stream_isatty, stripos,
+ preg_is_match, preg_replace_callback, putenv, putenv_clear, realpath, stream_isatty, stripos,
strlen, strtoupper, substr, usleep,
};
use std::sync::Mutex;
@@ -83,7 +83,7 @@ impl Platform {
/// Parses tildes and environment variables in paths.
pub fn expand_path(path: &str) -> String {
- if preg_match(php_regex!(r"#^~[\\/]#"), path).is_some() {
+ if preg_is_match(php_regex!(r"#^~[\\/]#"), path) {
return format!(
"{}{}",
Self::get_user_directory().unwrap(),
diff --git a/crates/shirabe/src/util/process_executor.rs b/crates/shirabe/src/util/process_executor.rs
index 64082064..6d609421 100644
--- a/crates/shirabe/src/util/process_executor.rs
+++ b/crates/shirabe/src/util/process_executor.rs
@@ -11,8 +11,9 @@ use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
LogicException, PHP_EOL, PhpMixed, PregMatches, RuntimeException, array_intersect, array_map,
escapeshellarg, explode, implode, in_array_strict, is_array, is_dir, is_numeric, is_string,
- php_regex, preg_match, preg_replace, preg_replace_callback, preg_replace2, preg_split, rtrim,
- str_replace, strcspn, strlen, strpbrk, strtolower, strtr_array, substr_replace, trim,
+ php_regex, preg_is_match, preg_match, preg_replace, preg_replace_callback, preg_replace2,
+ preg_split, rtrim, str_replace, strcspn, strlen, strpbrk, strtolower, strtr_array,
+ substr_replace, trim,
};
use shirabe_symfony_process::ExecutableFinder;
use shirabe_symfony_process::Process;
@@ -832,15 +833,13 @@ impl ProcessExecutor {
php_regex!(r"{://(?P<user>[^:/\s]+):(?P<password>[^@\s/]+)@}i"),
|m: &PregMatches| -> anyhow::Result<String> {
// if the username looks like a long (12char+) hex string, or a modern github token (e.g. ghp_xxx, github_pat_xxx) we obfuscate that
- if preg_match(
+ if preg_is_match(
GitHub::GITHUB_TOKEN_REGEX,
m.name("user").unwrap_or_default(),
- )
- .is_some()
- {
+ ) {
return Ok("://***:***@".to_string());
}
- if preg_match(r"{^[a-f0-9]{12,}$}", m.name("user").unwrap_or_default()).is_some() {
+ if preg_is_match(r"{^[a-f0-9]{12,}$}", m.name("user").unwrap_or_default()) {
return Ok("://***:***@".to_string());
}
@@ -903,7 +902,7 @@ impl ProcessExecutor {
-1,
Some(&mut dquotes),
);
- let meta = dquotes > 0 || preg_match(php_regex!(r"/%[^%]+%|![^!]+!/"), &argument).is_some();
+ let meta = dquotes > 0 || preg_is_match(php_regex!(r"/%[^%]+%|![^!]+!/"), &argument);
if !meta && !quote {
quote = strpbrk(&argument, "^&|<>()").is_some();
diff --git a/crates/shirabe/src/util/remote_filesystem.rs b/crates/shirabe/src/util/remote_filesystem.rs
index a7901567..b584d722 100644
--- a/crates/shirabe/src/util/remote_filesystem.rs
+++ b/crates/shirabe/src/util/remote_filesystem.rs
@@ -19,8 +19,8 @@ use shirabe_php_shim::{
STREAM_NOTIFY_PROGRESS, array_replace_recursive, base64_encode, explode, extension_loaded,
file_get_contents, file_get_contents5, file_put_contents, filter_var_boolean, gethostbyname,
http_clear_last_response_headers, http_get_last_response_headers, ini_get, json_decode_assoc,
- parse_url, php_regex, preg_match, preg_quote, preg_replace, strpos, strtolower, strtr, substr,
- trim, zlib_decode,
+ parse_url, php_regex, preg_is_match, preg_match, preg_quote, preg_replace, strpos, strtolower,
+ strtr, substr, trim, zlib_decode,
};
/// Result of `RemoteFilesystem::get` — string content, `true` (for copy), or `false`.
@@ -159,7 +159,7 @@ impl RemoteFilesystem {
pub fn find_status_message(&self, headers: &[String]) -> Option<String> {
let mut value: Option<String> = None;
for header in headers {
- if preg_match(php_regex!("{^HTTP/\\S+ \\d+}i"), header).is_some() {
+ if preg_is_match(php_regex!("{^HTTP/\\S+ \\d+}i"), header) {
value = Some(header.clone());
}
}
@@ -285,12 +285,10 @@ impl RemoteFilesystem {
crate::io::DEBUG,
);
- if (preg_match(
+ if (!preg_is_match(
php_regex!("{^http://(repo\\.)?packagist\\.org/p/}"),
&file_url,
- )
- .is_none()
- || (strpos(&file_url, "$").is_none() && strpos(&file_url, "%24").is_none()))
+ ) || (strpos(&file_url, "$").is_none() && strpos(&file_url, "%24").is_none()))
&& !degraded_packagist
{
let _ = self.config.borrow_mut().prohibit_url_by_config(
@@ -474,11 +472,10 @@ impl RemoteFilesystem {
None,
) != ".zip")
&& content_type.is_some()
- && preg_match(
+ && preg_is_match(
php_regex!("{^text/html\\b}i"),
content_type.as_deref().unwrap_or(""),
- )
- .is_some();
+ );
if bitbucket_login_match {
result = None;
if retry_auth_failure {
diff --git a/crates/shirabe/src/util/url.rs b/crates/shirabe/src/util/url.rs
index 75841167..41556913 100644
--- a/crates/shirabe/src/util/url.rs
+++ b/crates/shirabe/src/util/url.rs
@@ -3,7 +3,7 @@
use crate::config::Config;
use crate::util::GitHub;
use shirabe_php_shim::{
- PhpMixed, in_array_strict, parse_url, php_regex, preg_match, preg_replace,
+ PhpMixed, in_array_strict, parse_url, php_regex, preg_is_match, preg_match, preg_replace,
preg_replace_callback,
};
@@ -168,7 +168,7 @@ impl Url {
let user = m.name("user").unwrap_or_default().to_string();
let prefix = m.name("prefix").unwrap_or_default().to_string();
// if the username looks like a long (12char+) hex string, or a modern github token (e.g. ghp_xxx, github_pat_xxx) we obfuscate that
- Ok(if preg_match(GitHub::GITHUB_TOKEN_REGEX, &user).is_some() {
+ Ok(if preg_is_match(GitHub::GITHUB_TOKEN_REGEX, &user) {
format!("{}***:***@", prefix)
} else {
format!("{}{}:***@", prefix, user)
diff --git a/crates/shirabe/tests/common/io_mock.rs b/crates/shirabe/tests/common/io_mock.rs
index a6a407a3..5a5f35b6 100644
--- a/crates/shirabe/tests/common/io_mock.rs
+++ b/crates/shirabe/tests/common/io_mock.rs
@@ -5,7 +5,7 @@ use shirabe::io::buffer_io::BufferIO;
use shirabe::io::io_interface;
use shirabe::io::{IOInterface, IOInterfaceImmutable, IOInterfaceMutable};
use shirabe::util::platform::Platform;
-use shirabe_php_shim::{PHP_EOL, PhpMixed, php_regex, preg_match, preg_quote, preg_split};
+use shirabe_php_shim::{PHP_EOL, PhpMixed, php_regex, preg_is_match, preg_quote, preg_split};
use shirabe_symfony_console::output::output_interface;
use std::collections::VecDeque;
@@ -166,7 +166,7 @@ impl IOMock {
};
while let Some(line) = lines.pop_front() {
- if preg_match(&pattern, &line).is_some() {
+ if preg_is_match(&pattern, &line) {
continue 'expects;
}
diff --git a/crates/shirabe/tests/dependency_resolver/pool_builder_test.rs b/crates/shirabe/tests/dependency_resolver/pool_builder_test.rs
index e04e2ca9..a9b59596 100644
--- a/crates/shirabe/tests/dependency_resolver/pool_builder_test.rs
+++ b/crates/shirabe/tests/dependency_resolver/pool_builder_test.rs
@@ -19,7 +19,7 @@ use shirabe::repository::handle::{LockArrayRepositoryHandle, RepositoryInterface
use shirabe::repository::lock_array_repository::LockArrayRepository;
use shirabe::repository::repository_factory::RepositoryFactory;
use shirabe::repository::repository_set::{RepositorySet, RootAliasInput};
-use shirabe_php_shim::{PhpMixed, php_regex, preg_match, preg_split_delim_capture};
+use shirabe_php_shim::{PhpMixed, php_regex, preg_is_match, preg_split_delim_capture};
use std::path::PathBuf;
/// Maps the PHP `$loadPackage` closure: pops the optional `id` from the data, loads the
@@ -137,7 +137,7 @@ fn get_integration_tests(fixtures_dir: &std::path::Path) -> IndexMap<String, Int
for file in files {
let file = file.to_str().unwrap().to_string();
- if preg_match(php_regex!(r"/\.test$/"), &file).is_none() {
+ if !preg_is_match(php_regex!(r"/\.test$/"), &file) {
continue;
}
diff --git a/crates/shirabe/tests/dependency_resolver/pool_optimizer_test.rs b/crates/shirabe/tests/dependency_resolver/pool_optimizer_test.rs
index e40d5257..b84d152e 100644
--- a/crates/shirabe/tests/dependency_resolver/pool_optimizer_test.rs
+++ b/crates/shirabe/tests/dependency_resolver/pool_optimizer_test.rs
@@ -11,7 +11,7 @@ use shirabe::package::loader::{ArrayLoader, LoaderInterface};
use shirabe::package::version::version_parser::VersionParser;
use shirabe::repository::handle::LockArrayRepositoryHandle;
use shirabe::repository::lock_array_repository::LockArrayRepository;
-use shirabe_php_shim::{PhpMixed, php_regex, preg_match, preg_split_delim_capture};
+use shirabe_php_shim::{PhpMixed, php_regex, preg_is_match, preg_split_delim_capture};
use std::path::PathBuf;
fn load_package(package_data: &PhpMixed) -> BasePackageHandle {
@@ -140,7 +140,7 @@ fn provide_integration_tests() -> IndexMap<
for file in files {
let file = file.to_str().unwrap().to_string();
- if preg_match(php_regex!(r"/\.test$/"), &file).is_none() {
+ if !preg_is_match(php_regex!(r"/\.test$/"), &file) {
continue;
}
diff --git a/crates/shirabe/tests/installer_test.rs b/crates/shirabe/tests/installer_test.rs
index 606baacc..05776557 100644
--- a/crates/shirabe/tests/installer_test.rs
+++ b/crates/shirabe/tests/installer_test.rs
@@ -42,7 +42,9 @@ use shirabe::util::r#loop::Loop;
use shirabe::util::platform::Platform;
use shirabe::util::process_executor::ProcessExecutor;
use shirabe_class_map_generator::class_map::ClassMap;
-use shirabe_php_shim::{PhpMixed, php_regex, preg_match, preg_replace, preg_split_delim_capture};
+use shirabe_php_shim::{
+ PhpMixed, php_regex, preg_is_match, preg_match, preg_replace, preg_split_delim_capture,
+};
use shirabe_semver::VersionParser;
use shirabe_semver::constraint::AnyConstraint;
use shirabe_symfony_console::command::Command as SymfonyCommand;
@@ -691,7 +693,7 @@ fn load_integration_tests(path: &str) -> Vec<IntegrationCase> {
return;
}
if let Some(url) = repo.get("url").and_then(|u| u.as_str())
- && preg_match(php_regex!(r"{^file://[^/]}"), url).is_some()
+ && preg_is_match(php_regex!(r"{^file://[^/]}"), url)
{
let new_url = format!("file://{}/{}", fixtures_str, &url[7..]);
repo["url"] = serde_json::Value::String(new_url);