1--TEST-- 2PDO Common: Bug #44159 (Crash: $pdo->setAttribute(PDO::STATEMENT_ATTR_CLASS, NULL)) 3--SKIPIF-- 4<?php 5if (!extension_loaded('pdo')) die('skip'); 6$dir = getenv('REDIR_TEST_DIR'); 7if (false == $dir) die('skip no driver'); 8require_once $dir . 'pdo_test.inc'; 9PDOTest::skip(); 10?> 11--FILE-- 12<?php 13if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.__DIR__ . '/../../pdo/tests/'); 14require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc'; 15$pdo = PDOTest::factory(); 16$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); 17 18$attrs = array(PDO::ATTR_STATEMENT_CLASS, PDO::ATTR_STRINGIFY_FETCHES); 19 20foreach ($attrs as $attr) { 21 try { 22 var_dump($pdo->setAttribute($attr, NULL)); 23 } catch (\Error $e) { 24 echo get_class($e), ': ', $e->getMessage(), \PHP_EOL; 25 } 26 try { 27 var_dump($pdo->setAttribute($attr, 1)); 28 } catch (\Error $e) { 29 echo get_class($e), ': ', $e->getMessage(), \PHP_EOL; 30 } 31 try { 32 var_dump($pdo->setAttribute($attr, 'nonsense')); 33 } catch (\Error $e) { 34 echo get_class($e), ': ', $e->getMessage(), \PHP_EOL; 35 } 36} 37 38@unlink(__DIR__."/foo.db"); 39 40?> 41--EXPECT-- 42TypeError: PDO::ATTR_STATEMENT_CLASS value must be of type array, null given 43TypeError: PDO::ATTR_STATEMENT_CLASS value must be of type array, int given 44TypeError: PDO::ATTR_STATEMENT_CLASS value must be of type array, string given 45TypeError: Attribute value must be of type int for selected attribute, null given 46bool(true) 47bool(true) 48