PHP Specifies parameter types
Public Function Execute (pwthreaddatasource $ds) {
$this->_ds = $ds;
It is said that PHP does not specify the type when declaring the variable, then why does this parameter indicate the Pwthreaddatasource type? And this is an abstract class, isn't an abstract class not able to declare an object? Do not understand, it is polymorphic?
Abstract class Pwthreaddatasource {
Protected $urlArgs = Array ();
/**
* Get post statistics
*
* @return int
*/
Abstract public Function gettotal ();
/**
* Get posts
*
* @param int $limit Get entry
* @param int $offset post start offset
* @return Array
*/
Abstract public Function GetData ($limit, $offset);
------Solution--------------------
Execute (pwthreaddatasource $ds)
This $ds is a formal parameter that is only intended to be used by the caller to pass in an object of the Pwthreaddatasource class or its subclasses for the code within the function to invoke.
This is also to coordinate the coding, at least I do not have to look at the comments or code, I know what parameters to pass in.