Fix and improve reflection

- use "p" for path (security check for nul byte)
- fix number of args for some methods
- add type hinting
- throw standard exception (simplify)
- fix test suite for PHP 7.0 to 8.0
This commit is contained in:
Remi Collet
2020-06-22 16:22:37 +02:00
parent d36a2de544
commit cf0ce5a01e
14 changed files with 48 additions and 50 deletions

View File

@@ -6,10 +6,9 @@ Args given to chinese_whispers functions is not correct
<?php
try {
dlib_chinese_whispers("foo");
} catch (Exception $e) {
} catch (Error $e) {
var_dump($e->getMessage());
}
?>
--EXPECTF--
Warning: dlib_chinese_whispers() expects parameter 1 to be array, string given in %s on line 3
string(46) "Unable to parse edges in dlib_chinese_whispers"
string(%d) "%s type array, string given"

View File

@@ -6,10 +6,10 @@ Testing CnnFaceDetection constructor without arguments
<?php
try {
new CnnFaceDetection();
} catch (Exception $e) {
} catch (Error $e) {
var_dump($e->getMessage());
}
?>
--EXPECTF--
Warning: CnnFaceDetection::__construct() expects exactly 1 parameter, 0 given in %s on line 3
string(41) "Unable to parse face_detection_model_path"
string(68) "CnnFaceDetection::__construct() expects exactly 1 parameter, 0 given"

View File

@@ -6,7 +6,7 @@ Testing FaceLandmarkDetection constructor without arguments
<?php
try {
new FaceLandmarkDetection();
} catch (Exception $e) {
} catch (Error $e) {
var_dump($e->getMessage());
}
try {
@@ -16,6 +16,5 @@ try {
}
?>
--EXPECTF--
Warning: FaceLandmarkDetection::__construct() expects exactly 1 parameter, 0 given in %s on line 3
string(41) "Unable to parse shape_predictor_file_path"
string(73) "FaceLandmarkDetection::__construct() expects exactly 1 parameter, 0 given"
string(45) "Unable to open non-existent file for reading."

View File

@@ -6,10 +6,9 @@ Testing FaceRecognition constructor without arguments
<?php
try {
new FaceRecognition();
} catch (Exception $e) {
} catch (Error $e) {
var_dump($e->getMessage());
}
?>
--EXPECTF--
Warning: FaceRecognition::__construct() expects exactly 1 parameter, 0 given in %s on line 3
string(43) "Unable to parse face_recognition_model_path"
string(67) "FaceRecognition::__construct() expects exactly 1 parameter, 0 given"