Skip to content
Closed
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
26 changes: 26 additions & 0 deletions Zend/tests/strlen_enum.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--TEST--
strlen() with an enum argument
--SKIPIF--
<?php
//Skip if PHP version < 8.1
if (PHP_VERSION_ID < 80100) {
die("skip enums not supported\n");
}
?>
--FILE--
<?php
//Test that passing an enum case to strlen() throws a TypeError

enum E {
case A;
}

try {
strlen(E::A);
} catch (Throwable $e) {
echo $e->getMessage(), "\n";
}

?>
--EXPECTF--
strlen(): Argument #1 ($string) must be of type string, %s given
14 changes: 14 additions & 0 deletions Zend/tests/strlen_object_without_tostring.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--TEST--
strlen() with an object without __toString()
--FILE--
<?php

try {
strlen(new stdClass());
} catch (Throwable $e) {
echo $e->getMessage(), "\n";
}

?>
--EXPECTF--
strlen(): Argument #1 ($string) must be of type string, %s given
16 changes: 16 additions & 0 deletions Zend/tests/strlen_resource.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--TEST--
strlen() with a resource argument
--FILE--
<?php
//Test that passing a resource to strlen() throws a TypeError

$fp = fopen(__FILE__, 'r');
try {
strlen($fp);
} catch (Throwable $e) {
echo $e->getMessage(), "\n";
}
fclose($fp);
?>
--EXPECTF--
strlen(): Argument #1 ($string) must be of type string, %s given