diff --git a/src/resizable.cc b/src/resizable.cc index 84751d1..9dfe92d 100644 --- a/src/resizable.cc +++ b/src/resizable.cc @@ -41,16 +41,18 @@ namespace php_arma Z_PARAM_ZVAL(other) ZEND_PARSE_PARAMETERS_END(); - if (UNEXPECTED(Z_TYPE_P(other) != IS_OBJECT || instanceof_function(Z_OBJCE_P(other), base_ce))) { + if (UNEXPECTED(Z_TYPE_P(other) != IS_OBJECT || !instanceof_function(Z_OBJCE_P(other), base_ce))) { ex_bad_type(ZSTR_VAL(base_ce->name), zval_get_type_name(other)); return; } std::variant other_native_v; - if (instanceof_function(Z_OBJCE_P(other), diagonal_ce)) { - other_native_v = to_native_object(Z_OBJ_P(other)); - } else if (instanceof_function(Z_OBJCE_P(other), subview_ce)) { - other_native_v = to_native_object(Z_OBJ_P(other)); + if (instanceof_function(Z_OBJCE_P(other), subview_ce)) { + if (instanceof_function(Z_OBJCE_P(other), diagonal_ce)) { + other_native_v = to_native_object(Z_OBJ_P(other)); + } else { + other_native_v = to_native_object(Z_OBJ_P(other)); + } } else { other_native_v = to_native_object(Z_OBJ_P(other)); } diff --git a/tests/020-copy-size.phpt b/tests/020-copy-size.phpt new file mode 100644 index 0000000..836df3c --- /dev/null +++ b/tests/020-copy-size.phpt @@ -0,0 +1,25 @@ +--TEST-- +Test for method `copySize()` +--SKIPIF-- + +--FILE-- +copySize($dmat->submat(0, 1, 1, 3)); +$imat->copySize($imat->diag()); +batch_assert('method `copySize()`', + [$dmat->nRows(), 2], + [$dmat->nCols(), 3], + [$imat->nRows(), 3], + [$imat->nCols(), 1] +); + +?> +--EXPECT--