aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/command/package_discovery_trait.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-20 00:31:45 +0900
committernsfisis <nsfisis@gmail.com>2026-06-20 00:31:49 +0900
commitcac18ef73a39b4ac41fa4d6ccb753804d4c42cb7 (patch)
tree968f438437042e8092752aa521c2d7e6ae28307e /crates/shirabe/src/command/package_discovery_trait.rs
parent7c5162e7c2f9d466e96248b7482aa98350244e8b (diff)
downloadphp-shirabe-cac18ef73a39b4ac41fa4d6ccb753804d4c42cb7.tar.gz
php-shirabe-cac18ef73a39b4ac41fa4d6ccb753804d4c42cb7.tar.zst
php-shirabe-cac18ef73a39b4ac41fa4d6ccb753804d4c42cb7.zip
feat(php-shim): implement count()
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/command/package_discovery_trait.rs')
-rw-r--r--crates/shirabe/src/command/package_discovery_trait.rs25
1 files changed, 5 insertions, 20 deletions
diff --git a/crates/shirabe/src/command/package_discovery_trait.rs b/crates/shirabe/src/command/package_discovery_trait.rs
index c48b4d5..3263444 100644
--- a/crates/shirabe/src/command/package_discovery_trait.rs
+++ b/crates/shirabe/src/command/package_discovery_trait.rs
@@ -268,10 +268,7 @@ pub trait PackageDiscoveryTrait {
None,
)?;
- if count(&PhpMixed::List(
- matches.iter().map(|_| Box::new(PhpMixed::Null)).collect(),
- )) > 0
- {
+ if matches.len() > 0 {
// Remove existing packages from search results.
matches.retain(|found_package| {
!in_array(
@@ -298,10 +295,7 @@ pub trait PackageDiscoveryTrait {
if !exact_match {
let providers: IndexMap<String, crate::repository::ProviderInfo> =
self.get_repos().get_providers(package.clone())?;
- if count(&PhpMixed::List(
- providers.iter().map(|_| Box::new(PhpMixed::Null)).collect(),
- )) > 0
- {
+ if providers.len() > 0 {
// PHP: array_unshift($matches, ['name' => $package, 'description' => '']);
matches.insert(
0,
@@ -536,10 +530,7 @@ pub trait PackageDiscoveryTrait {
// Check if it is a virtual package provided by others
let providers = repo_set.borrow().get_providers(name)?;
- if count(&PhpMixed::List(
- providers.iter().map(|_| Box::new(PhpMixed::Null)).collect(),
- )) > 0
- {
+ if providers.len() > 0 {
let mut constraint = "*".to_string();
if input.borrow().is_interactive() {
let providers_count = providers.len();
@@ -702,10 +693,7 @@ pub trait PackageDiscoveryTrait {
// Check for similar names/typos
let similar = self.find_similar(name)?;
- if count(&PhpMixed::List(
- similar.iter().map(|_| Box::new(PhpMixed::Null)).collect(),
- )) > 0
- {
+ if similar.len() > 0 {
if in_array(
PhpMixed::String(name.to_string()),
&PhpMixed::List(
@@ -925,10 +913,7 @@ pub trait PackageDiscoveryTrait {
}
}
- if count(&PhpMixed::List(
- details.iter().map(|_| Box::new(PhpMixed::Null)).collect(),
- )) == 0
- {
+ if details.is_empty() {
return Ok(String::new());
}