aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-24 05:14:37 +0900
committernsfisis <nsfisis@gmail.com>2026-06-24 05:19:49 +0900
commit6dcc2125974e350d1844c5ce1bb3562e224f3435 (patch)
tree7287119a8cd6aad599acb41e796095c3e204c35f
parenta8623a5e867825400073d2597dfb3118d6624ef7 (diff)
downloadphp-shirabe-6dcc2125974e350d1844c5ce1bb3562e224f3435.tar.gz
php-shirabe-6dcc2125974e350d1844c5ce1bb3562e224f3435.tar.zst
php-shirabe-6dcc2125974e350d1844c5ce1bb3562e224f3435.zip
refactor(php-shim): remove is_resource/is_resource_value
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/output/stream_output.rs4
-rw-r--r--crates/shirabe-external-packages/src/symfony/process/pipes/abstract_pipes.rs8
-rw-r--r--crates/shirabe-external-packages/src/symfony/process/process_utils.rs3
-rw-r--r--crates/shirabe-php-shim/src/stream.rs4
-rw-r--r--crates/shirabe-php-shim/src/var.rs5
-rw-r--r--crates/shirabe/src/util/error_handler.rs14
-rw-r--r--crates/shirabe/src/util/http/curl_downloader.rs6
7 files changed, 10 insertions, 34 deletions
diff --git a/crates/shirabe-external-packages/src/symfony/console/output/stream_output.rs b/crates/shirabe-external-packages/src/symfony/console/output/stream_output.rs
index fa63557..f517cbe 100644
--- a/crates/shirabe-external-packages/src/symfony/console/output/stream_output.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/output/stream_output.rs
@@ -35,9 +35,7 @@ impl StreamOutput {
) -> anyhow::Result<Result<Self, InvalidArgumentException>> {
let verbosity = verbosity.unwrap_or(VERBOSITY_NORMAL);
- if !shirabe_php_shim::is_resource_value(&stream)
- || "stream" != shirabe_php_shim::get_resource_type(&stream)
- {
+ if shirabe_php_shim::get_resource_type(&stream) != "stream" {
return Ok(Err(InvalidArgumentException(
shirabe_php_shim::InvalidArgumentException {
message: "The StreamOutput class needs a stream as its first argument."
diff --git a/crates/shirabe-external-packages/src/symfony/process/pipes/abstract_pipes.rs b/crates/shirabe-external-packages/src/symfony/process/pipes/abstract_pipes.rs
index 5b85813..bafd146 100644
--- a/crates/shirabe-external-packages/src/symfony/process/pipes/abstract_pipes.rs
+++ b/crates/shirabe-external-packages/src/symfony/process/pipes/abstract_pipes.rs
@@ -17,11 +17,9 @@ impl AbstractPipes {
pub fn new(input: PhpMixed) -> Self {
let mut input_buffer = String::new();
let stored_input;
- // TODO(plugin): `$input instanceof \Iterator` is not modeled. `is_resource` on a PhpMixed is
- // always false, so the resource branch never stores input here.
- if php::is_resource(&input) {
- stored_input = input;
- } else if let PhpMixed::String(s) = &input {
+ // TODO(plugin): `$input instanceof \Iterator` is not modeled. The PHP `is_resource($input)`
+ // branch never applies: a PhpMixed is never a resource, so input is never stored as-is here.
+ if let PhpMixed::String(s) = &input {
input_buffer = s.clone();
stored_input = PhpMixed::Null;
} else {
diff --git a/crates/shirabe-external-packages/src/symfony/process/process_utils.rs b/crates/shirabe-external-packages/src/symfony/process/process_utils.rs
index aec326f..7287b28 100644
--- a/crates/shirabe-external-packages/src/symfony/process/process_utils.rs
+++ b/crates/shirabe-external-packages/src/symfony/process/process_utils.rs
@@ -12,9 +12,6 @@ impl ProcessUtils {
/// Validates and normalizes a Process input.
pub fn validate_input(caller: &str, input: PhpMixed) -> anyhow::Result<PhpMixed> {
if !input.is_null() {
- if php::is_resource(&input) {
- return Ok(input);
- }
if php::is_string(&input) {
return Ok(input);
}
diff --git a/crates/shirabe-php-shim/src/stream.rs b/crates/shirabe-php-shim/src/stream.rs
index 2ecfc62..e5e5200 100644
--- a/crates/shirabe-php-shim/src/stream.rs
+++ b/crates/shirabe-php-shim/src/stream.rs
@@ -240,10 +240,6 @@ pub fn stream_get_contents3(stream: &PhpResource, max_length: i64, offset: i64)
stream_read_remaining(stream, max)
}
-pub fn is_resource_value(_resource: &PhpResource) -> bool {
- true
-}
-
pub fn get_resource_type(resource: &PhpResource) -> String {
match resource {
PhpResource::Process(_) => "process".to_string(),
diff --git a/crates/shirabe-php-shim/src/var.rs b/crates/shirabe-php-shim/src/var.rs
index 0dc7523..adaacec 100644
--- a/crates/shirabe-php-shim/src/var.rs
+++ b/crates/shirabe-php-shim/src/var.rs
@@ -137,11 +137,6 @@ pub fn is_a(_object_or_class: &PhpMixed, _class: &str, _allow_string: bool) -> b
todo!()
}
-pub fn is_resource(_value: &PhpMixed) -> bool {
- // PhpMixed has no resource variant, so a PhpMixed is never a resource.
- false
-}
-
pub fn is_array(_value: &PhpMixed) -> bool {
matches!(_value, PhpMixed::List(_) | PhpMixed::Array(_))
}
diff --git a/crates/shirabe/src/util/error_handler.rs b/crates/shirabe/src/util/error_handler.rs
index 263d80c..d883556 100644
--- a/crates/shirabe/src/util/error_handler.rs
+++ b/crates/shirabe/src/util/error_handler.rs
@@ -4,8 +4,8 @@ use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
use shirabe_php_shim::{
E_ALL, E_DEPRECATED, E_USER_DEPRECATED, E_USER_WARNING, E_WARNING, ErrorException, PHP_EOL,
- PhpMixed, STDERR, debug_backtrace, error_reporting, filter_var_boolean, ini_get,
- is_resource_value, set_error_handler,
+ PhpMixed, STDERR, debug_backtrace, error_reporting, filter_var_boolean, fwrite, ini_get,
+ set_error_handler,
};
use std::cell::{Cell, RefCell};
use std::rc::Rc;
@@ -126,15 +126,7 @@ impl ErrorHandler {
}
if output_even_without_io {
- if is_resource_value(&STDERR) {
- shirabe_php_shim::fwrite(
- &STDERR,
- &format!("Warning: {}{}", message, PHP_EOL),
- None,
- );
- } else {
- print!("Warning: {}{}", message, PHP_EOL);
- }
+ fwrite(&STDERR, &format!("Warning: {}{}", message, PHP_EOL), None);
}
}
}
diff --git a/crates/shirabe/src/util/http/curl_downloader.rs b/crates/shirabe/src/util/http/curl_downloader.rs
index 4b8348f..1a5c7b3 100644
--- a/crates/shirabe/src/util/http/curl_downloader.rs
+++ b/crates/shirabe/src/util/http/curl_downloader.rs
@@ -19,9 +19,9 @@ use shirabe_php_shim::{
curl_init, curl_multi_add_handle, curl_multi_exec, curl_multi_info_read, curl_multi_init,
curl_multi_select, curl_multi_setopt, curl_setopt, curl_setopt_array, curl_share_init,
curl_share_setopt, curl_strerror, curl_version, defined, explode, fclose, fopen,
- function_exists, implode, in_array, ini_get, is_resource, json_decode, parse_url, preg_quote,
- rename, rewind, rtrim, sprintf, str_contains, stream_get_contents,
- stream_get_contents_with_max, stripos, strpos, substr, unlink_silent, usleep, var_export,
+ function_exists, implode, in_array, ini_get, json_decode, parse_url, preg_quote, rename,
+ rewind, rtrim, sprintf, str_contains, stream_get_contents, stream_get_contents_with_max,
+ stripos, strpos, substr, unlink_silent, usleep, var_export,
};
use crate::config::Config;