@@ -426,10 +426,12 @@ static zval *pdo_stmt_instantiate(pdo_dbh_t *dbh, zval *object, zend_class_entry
426
426
{
427
427
if (!Z_ISUNDEF_P (ctor_args )) {
428
428
if (Z_TYPE_P (ctor_args ) != IS_ARRAY ) {
429
+ /* TODO Always TypeError */
429
430
pdo_raise_impl_error (dbh , NULL , "HY000" , "constructor arguments must be passed as an array" );
430
431
return NULL ;
431
432
}
432
433
if (!dbstmt_ce -> constructor ) {
434
+ /* TODO Error? */
433
435
pdo_raise_impl_error (dbh , NULL , "HY000" , "user-supplied statement does not accept constructor arguments" );
434
436
return NULL ;
435
437
}
@@ -506,6 +508,7 @@ PHP_METHOD(PDO, prepare)
506
508
|| Z_TYPE_P (item ) != IS_STRING
507
509
|| (pce = zend_lookup_class (Z_STR_P (item ))) == NULL
508
510
) {
511
+ /* TODO Always TypeError */
509
512
pdo_raise_impl_error (dbh , NULL , "HY000" ,
510
513
"PDO::ATTR_STATEMENT_CLASS requires format array(classname, array(ctor_args)); "
511
514
"the classname must be a string specifying an existing class"
@@ -515,19 +518,22 @@ PHP_METHOD(PDO, prepare)
515
518
}
516
519
dbstmt_ce = pce ;
517
520
if (!instanceof_function (dbstmt_ce , pdo_dbstmt_ce )) {
521
+ /* TODO Always TypeError */
518
522
pdo_raise_impl_error (dbh , NULL , "HY000" ,
519
523
"user-supplied statement class must be derived from PDOStatement" );
520
524
PDO_HANDLE_DBH_ERR ();
521
525
RETURN_FALSE ;
522
526
}
523
527
if (dbstmt_ce -> constructor && !(dbstmt_ce -> constructor -> common .fn_flags & (ZEND_ACC_PRIVATE |ZEND_ACC_PROTECTED ))) {
528
+ /* TODO Always TError */
524
529
pdo_raise_impl_error (dbh , NULL , "HY000" ,
525
530
"user-supplied statement class cannot have a public constructor" );
526
531
PDO_HANDLE_DBH_ERR ();
527
532
RETURN_FALSE ;
528
533
}
529
534
if ((item = zend_hash_index_find (Z_ARRVAL_P (opt ), 1 )) != NULL ) {
530
535
if (Z_TYPE_P (item ) != IS_ARRAY ) {
536
+ /* TODO Always TypeError */
531
537
pdo_raise_impl_error (dbh , NULL , "HY000" ,
532
538
"PDO::ATTR_STATEMENT_CLASS requires format array(classname, ctor_args); "
533
539
"ctor_args must be an array"
@@ -546,6 +552,7 @@ PHP_METHOD(PDO, prepare)
546
552
547
553
if (!pdo_stmt_instantiate (dbh , return_value , dbstmt_ce , & ctor_args )) {
548
554
if (EXPECTED (!EG (exception ))) {
555
+ /* TODO Error? */
549
556
pdo_raise_impl_error (dbh , NULL , "HY000" ,
550
557
"failed to instantiate user-supplied statement class"
551
558
);
@@ -679,6 +686,7 @@ static int pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value) /*
679
686
{
680
687
zend_long lval ;
681
688
689
+ /* TODO Always TypeError (also restrict to actual integer?) */
682
690
#define PDO_LONG_PARAM_CHECK \
683
691
if (Z_TYPE_P(value) != IS_LONG && Z_TYPE_P(value) != IS_STRING && Z_TYPE_P(value) != IS_FALSE && Z_TYPE_P(value) != IS_TRUE) { \
684
692
pdo_raise_impl_error(dbh, NULL, "HY000", "attribute value must be an integer"); \
@@ -697,6 +705,7 @@ static int pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value) /*
697
705
dbh -> error_mode = lval ;
698
706
return SUCCESS ;
699
707
default :
708
+ /* TODO Always ValueError */
700
709
pdo_raise_impl_error (dbh , NULL , "HY000" , "invalid error mode" );
701
710
PDO_HANDLE_DBH_ERR ();
702
711
return FAILURE ;
@@ -713,6 +722,7 @@ static int pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value) /*
713
722
dbh -> desired_case = lval ;
714
723
return SUCCESS ;
715
724
default :
725
+ /* TODO Always ValueError */
716
726
pdo_raise_impl_error (dbh , NULL , "HY000" , "invalid case folding mode" );
717
727
PDO_HANDLE_DBH_ERR ();
718
728
return FAILURE ;
@@ -729,6 +739,7 @@ static int pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value) /*
729
739
zval * tmp ;
730
740
if ((tmp = zend_hash_index_find (Z_ARRVAL_P (value ), 0 )) != NULL && Z_TYPE_P (tmp ) == IS_LONG ) {
731
741
if (Z_LVAL_P (tmp ) == PDO_FETCH_INTO || Z_LVAL_P (tmp ) == PDO_FETCH_CLASS ) {
742
+ /* TODO Always ValueError */
732
743
pdo_raise_impl_error (dbh , NULL , "HY000" , "FETCH_INTO and FETCH_CLASS are not yet supported as default fetch modes" );
733
744
return FAILURE ;
734
745
}
@@ -738,6 +749,7 @@ static int pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value) /*
738
749
}
739
750
lval = zval_get_long (value );
740
751
if (lval == PDO_FETCH_USE_DEFAULT ) {
752
+ /* TODO Always ValueError */
741
753
pdo_raise_impl_error (dbh , NULL , "HY000" , "invalid fetch mode type" );
742
754
return FAILURE ;
743
755
}
@@ -766,6 +778,7 @@ static int pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value) /*
766
778
|| Z_TYPE_P (item ) != IS_STRING
767
779
|| (pce = zend_lookup_class (Z_STR_P (item ))) == NULL
768
780
) {
781
+ /* TODO Always TypeError */
769
782
pdo_raise_impl_error (dbh , NULL , "HY000" ,
770
783
"PDO::ATTR_STATEMENT_CLASS requires format array(classname, array(ctor_args)); "
771
784
"the classname must be a string specifying an existing class"
@@ -774,12 +787,14 @@ static int pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value) /*
774
787
return FAILURE ;
775
788
}
776
789
if (!instanceof_function (pce , pdo_dbstmt_ce )) {
790
+ /* TODO Always TypeError */
777
791
pdo_raise_impl_error (dbh , NULL , "HY000" ,
778
792
"user-supplied statement class must be derived from PDOStatement" );
779
793
PDO_HANDLE_DBH_ERR ();
780
794
return FAILURE ;
781
795
}
782
796
if (pce -> constructor && !(pce -> constructor -> common .fn_flags & (ZEND_ACC_PRIVATE |ZEND_ACC_PROTECTED ))) {
797
+ /* TODO Always TypeError */
783
798
pdo_raise_impl_error (dbh , NULL , "HY000" ,
784
799
"user-supplied statement class cannot have a public constructor" );
785
800
PDO_HANDLE_DBH_ERR ();
@@ -792,6 +807,7 @@ static int pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value) /*
792
807
}
793
808
if ((item = zend_hash_index_find (Z_ARRVAL_P (value ), 1 )) != NULL ) {
794
809
if (Z_TYPE_P (item ) != IS_ARRAY ) {
810
+ /* TODO Always TypeError */
795
811
pdo_raise_impl_error (dbh , NULL , "HY000" ,
796
812
"PDO::ATTR_STATEMENT_CLASS requires format array(classname, array(ctor_args)); "
797
813
"ctor_args must be an array"
@@ -928,6 +944,7 @@ PHP_METHOD(PDO, exec)
928
944
ZEND_PARSE_PARAMETERS_END ();
929
945
930
946
if (!statement_len ) {
947
+ /* TODO ValueError */
931
948
pdo_raise_impl_error (dbh , NULL , "HY000" , "trying to execute an empty query" );
932
949
RETURN_FALSE ;
933
950
}
0 commit comments