Warning inheritance links to PDO
I have a problem with phpstorm 7.1 version when im trying to inherit my DB class and use PDO functions.
PDO class looks like that:
namespace engine; use PDO; use PDOException; class database extends PDO{ protected static $link = null; protected static $query_count = 0; public static function init() { if(self::$link == null) { try { self::$link = @new \PDO("mysql:host=".property::get('db_host').";dbname=".property::get('db_name')."", property::get('db_user'), property::get('db_pass'), array(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true, PDO::ATTR_EMULATE_PREPARES => false, PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8", PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_PERSISTENT => false)); } catch(\PDOException $e) { logger::log(logger::LEVEL_ERR, "Database is down! Check configuration and database server uplink!"); } } } public static function con() { self::$query_count++; return self::$link; } public static function totalQueryCount() { return self::$query_count; } function __destruct() { self::$link = null; } public static function isDown() { return self::$link == null ? true : false; } }
And when im try to use it, like:
use engine\database;
$stmt = database::con()->prepare("SELECT something FROM table WHERE a = ?");
$stmt->bindParam(1, $someparam, PDO::PARAM_STR);
$stmt->execute();
i get phpstorm warning.
How can i fix this warning notify?
Attachment(s):
pdoissue.jpg
请先登录再写评论。
Hi there,
Witness the power of PHPDoc!
Bare minimum (for your specific case):
Alternative (minimum) / additional (preferred/recommended):
In the end:
Conclusion:
Use PHPDoc and make your code self-documented: it will help you in long run (when you or somebody else come back to this code months/years later) as well as help your IDE right now.
Thanks, forgot phpdoc info for this.