Skip to content

Set up parameter types for pow() #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/standard/basic_functions.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -3136,7 +3136,7 @@ function intdiv(int $num1, int $num2): int {}
function is_infinite(float $num): bool {}

/** @compile-time-eval */
function pow(mixed $num, mixed $exponent): int|float|object {}
function pow(int|float $num, int|float $exponent): int|float {}

/** @compile-time-eval */
function exp(float $num): float {}
Expand Down
8 changes: 4 additions & 4 deletions ext/standard/basic_functions_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions ext/standard/math.c
Original file line number Diff line number Diff line change
Expand Up @@ -570,8 +570,8 @@ PHP_FUNCTION(pow)
zval *zbase, *zexp;

ZEND_PARSE_PARAMETERS_START(2, 2)
Z_PARAM_ZVAL(zbase)
Z_PARAM_ZVAL(zexp)
Z_PARAM_NUMBER(zbase)
Z_PARAM_NUMBER(zexp)
ZEND_PARSE_PARAMETERS_END();

pow_function(return_value, zbase, zexp);
Expand Down
24 changes: 16 additions & 8 deletions ext/standard/tests/math/pow_variation1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,13 @@ float(1.881676371789%dE-27)
float(0.125)

-- Iteration 11 --

Deprecated: pow(): Passing null to parameter #2 ($exponent) of type int|float is deprecated in %s on line %d
int(0)

-- Iteration 12 --

Deprecated: pow(): Passing null to parameter #2 ($exponent) of type int|float is deprecated in %s on line %d
int(0)

-- Iteration 13 --
Expand All @@ -141,31 +145,35 @@ int(1)
int(0)

-- Iteration 17 --
Unsupported operand types: string ** int
pow(): Argument #2 ($exponent) must be of type int|float, string given

-- Iteration 18 --
Unsupported operand types: string ** int
pow(): Argument #2 ($exponent) must be of type int|float, string given

-- Iteration 19 --
Unsupported operand types: array ** int
pow(): Argument #2 ($exponent) must be of type int|float, array given

-- Iteration 20 --
Unsupported operand types: string ** int
pow(): Argument #2 ($exponent) must be of type int|float, string given

-- Iteration 21 --
Unsupported operand types: string ** int
pow(): Argument #2 ($exponent) must be of type int|float, string given

-- Iteration 22 --
Unsupported operand types: string ** int
pow(): Argument #2 ($exponent) must be of type int|float, string given

-- Iteration 23 --
Unsupported operand types: classA ** int
pow(): Argument #2 ($exponent) must be of type int|float, classA given

-- Iteration 24 --

Deprecated: pow(): Passing null to parameter #2 ($exponent) of type int|float is deprecated in %s on line %d
int(0)

-- Iteration 25 --

Deprecated: pow(): Passing null to parameter #2 ($exponent) of type int|float is deprecated in %s on line %d
int(0)

-- Iteration 26 --
Unsupported operand types: resource ** int
pow(): Argument #2 ($exponent) must be of type int|float, resource given
26 changes: 17 additions & 9 deletions ext/standard/tests/math/pow_variation1_64bit.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ foreach($inputs as $input) {
};
fclose($fp);
?>
--EXPECT--
--EXPECTF--
*** Testing pow() : usage variations ***

-- Iteration 1 --
Expand Down Expand Up @@ -123,9 +123,13 @@ float(1.8816763717891545E-27)
float(0.125)

-- Iteration 11 --

Deprecated: pow(): Passing null to parameter #1 ($num) of type int|float is deprecated in %s on line %d
int(0)

-- Iteration 12 --

Deprecated: pow(): Passing null to parameter #1 ($num) of type int|float is deprecated in %s on line %d
int(0)

-- Iteration 13 --
Expand All @@ -141,31 +145,35 @@ int(1)
int(0)

-- Iteration 17 --
Unsupported operand types: string ** int
pow(): Argument #1 ($num) must be of type int|float, string given

-- Iteration 18 --
Unsupported operand types: string ** int
pow(): Argument #1 ($num) must be of type int|float, string given

-- Iteration 19 --
Unsupported operand types: array ** int
pow(): Argument #1 ($num) must be of type int|float, array given

-- Iteration 20 --
Unsupported operand types: string ** int
pow(): Argument #1 ($num) must be of type int|float, string given

-- Iteration 21 --
Unsupported operand types: string ** int
pow(): Argument #1 ($num) must be of type int|float, string given

-- Iteration 22 --
Unsupported operand types: string ** int
pow(): Argument #1 ($num) must be of type int|float, string given

-- Iteration 23 --
Unsupported operand types: classA ** int
pow(): Argument #1 ($num) must be of type int|float, classA given

-- Iteration 24 --

Deprecated: pow(): Passing null to parameter #1 ($num) of type int|float is deprecated in %s on line %d
int(0)

-- Iteration 25 --

Deprecated: pow(): Passing null to parameter #1 ($num) of type int|float is deprecated in %s on line %d
int(0)

-- Iteration 26 --
Unsupported operand types: resource ** int
pow(): Argument #1 ($num) must be of type int|float, resource given
26 changes: 17 additions & 9 deletions ext/standard/tests/math/pow_variation2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ foreach($inputs as $input) {
};
fclose($fp);
?>
--EXPECT--
--EXPECTF--
*** Testing pow() : usage variations ***

-- Iteration 1 --
Expand Down Expand Up @@ -119,9 +119,13 @@ float(1.0000000037168)
float(4.5055521304275)

-- Iteration 11 --

Deprecated: pow(): Passing null to parameter #2 ($exponent) of type int|float is deprecated in %s on line %d
float(1)

-- Iteration 12 --

Deprecated: pow(): Passing null to parameter #2 ($exponent) of type int|float is deprecated in %s on line %d
float(1)

-- Iteration 13 --
Expand All @@ -137,31 +141,35 @@ float(20.3)
float(1)

-- Iteration 17 --
Unsupported operand types: float ** string
pow(): Argument #2 ($exponent) must be of type int|float, string given

-- Iteration 18 --
Unsupported operand types: float ** string
pow(): Argument #2 ($exponent) must be of type int|float, string given

-- Iteration 19 --
Unsupported operand types: float ** array
pow(): Argument #2 ($exponent) must be of type int|float, array given

-- Iteration 20 --
Unsupported operand types: float ** string
pow(): Argument #2 ($exponent) must be of type int|float, string given

-- Iteration 21 --
Unsupported operand types: float ** string
pow(): Argument #2 ($exponent) must be of type int|float, string given

-- Iteration 22 --
Unsupported operand types: float ** string
pow(): Argument #2 ($exponent) must be of type int|float, string given

-- Iteration 23 --
Unsupported operand types: float ** classA
pow(): Argument #2 ($exponent) must be of type int|float, classA given

-- Iteration 24 --

Deprecated: pow(): Passing null to parameter #2 ($exponent) of type int|float is deprecated in %s on line %d
float(1)

-- Iteration 25 --

Deprecated: pow(): Passing null to parameter #2 ($exponent) of type int|float is deprecated in %s on line %d
float(1)

-- Iteration 26 --
Unsupported operand types: float ** resource
pow(): Argument #2 ($exponent) must be of type int|float, resource given