Is it a good practice to use stubs for custom variable types ?

I'd like to know if it's a good practice to use stubs for custom data types. We use date and time as strings in our framework (not DateTime objects, even if we'd like to), and we'd like to not use the "string" type for this kind of data, because they are more than simple strings.
Of course, the stubs are only "known" by PhpStorm, not the framework itself.

The stubs we use are like this, in a "stubs.php" file :

<?


/**

* ISO Date: "YYYY-MM-DD"

*/

class date {

  private function __construct(){}


  function __toString() {

    return "0000-00-00";

  }

}


/**

* ISO Time: "hh:mm:ss"

*/

class time {

  private function __construct(){}


  function __toString() {

    return "00:00:00";

  }

}



Do you see any issue with this kind of practice, or any improvement we could do ?

Please sign in to leave a comment.