Skip to content

Commit

Permalink
Add phpDoc for objects using phpwaver
Browse files Browse the repository at this point in the history
This add phpDoc to some of the code in pts-core/objects, the types where
determined by running debug-self-test through phpweaver for a few
secounds and then manually verityfing the result.
  • Loading branch information
AJenbo committed Mar 7, 2020
1 parent eb863e5 commit 99e026f
Show file tree
Hide file tree
Showing 18 changed files with 345 additions and 1 deletion.
Expand Up @@ -522,6 +522,12 @@ public function generic_prompt($prompt_string)
{
echo $this->tab . $prompt_string;
}
/**
* @param string $string
* @param bool $ending_line_break
*
* @return void
*/
public function generic_heading($string, $ending_line_break = true)
{
static $shown_pts = false;
Expand Down
13 changes: 12 additions & 1 deletion pts-core/objects/client/pts_argument_check.php
Expand Up @@ -26,16 +26,27 @@ class pts_argument_check
private $function_check;
private $function_return_key;

/**
* @param int $index
* @param string[] $function
* @param $return_key set to null when you don't want it to be set
*/
public function __construct($index, $function, $return_key = null)
{
$this->argument_index = $index;
$this->function_check = $function;
$this->function_return_key = $return_key; // set to null when you don't want it to be set
$this->function_return_key = $return_key;
}
/**
* @return int
*/
public function get_argument_index()
{
return $this->argument_index;
}
/**
* @return string[]
*/
public function get_function_check()
{
return $this->function_check;
Expand Down
11 changes: 11 additions & 0 deletions pts-core/objects/client/pts_test_install_request.php
Expand Up @@ -29,6 +29,9 @@ class pts_test_install_request
public $install_error = null;
public $special_environment_vars;

/**
* @param string $test
*/
public function __construct($test)
{
if($test instanceof pts_test_profile)
Expand All @@ -55,6 +58,9 @@ public function __toString()
{
return $this->test_profile->get_identifier();
}
/**
* @return pts_test_file_download[]
*/
public function get_download_objects()
{
return $this->test_files;
Expand All @@ -63,6 +69,11 @@ public function get_download_object_count()
{
return count($this->test_files);
}
/**
* @param bool $do_file_checks
*
* @return void
*/
public function generate_download_object_list($do_file_checks = true)
{
foreach($this->test_profile->get_downloads() as $download)
Expand Down
15 changes: 15 additions & 0 deletions pts-core/objects/nye_Xml/nye_XmlWriter.php
Expand Up @@ -31,6 +31,9 @@ class nye_XmlWriter
public $dom;
protected $times_fallback = 0;

/**
* @param string $xsl_binding
*/
public function __construct($xsl_binding = null, $force_nice_formatting = false)
{
$this->dom = new DOMDocument('1.0');
Expand All @@ -56,6 +59,12 @@ public function addXmlNodeWNE($xml_location, $xml_value = null)
// When Not Empty, add the XML node
return $xml_value === null || $xml_value === false ? false : $this->addXmlNode($xml_location, $xml_value);
}
/**
* @param string $xml_location
* @param string|null $xml_value
*
* @return void
*/
public function addXmlNode($xml_location, $xml_value = null)
{
$nodes = explode('/', $xml_location);
Expand Down Expand Up @@ -101,6 +110,12 @@ public function addXmlNodeFromXG($xml_location, &$test_profile, $default_value =

$this->addXmlNode($xml_location, $value);
}
/**
* @param string $xml_location
* @param pts_config_nye_XmlReader $xml
*
* @return void
*/
public function addXmlNodeFromReader($xml_location, &$xml, $default_value = null)
{
$value = $xml->getXmlValue($xml_location);
Expand Down
10 changes: 10 additions & 0 deletions pts-core/objects/nye_Xml/pts_config_nye_XmlReader.php
Expand Up @@ -24,6 +24,10 @@ class pts_config_nye_XmlReader extends nye_XmlReader
{
protected $override_values;

/**
* @param string|null $new_values
* @param bool $override_file
*/
public function __construct($new_values = null, $override_file = false)
{
if($override_file && is_file($override_file))
Expand Down Expand Up @@ -86,6 +90,12 @@ public function handleXmlZeroTagFallback($xml_tag, $fallback_value)

return $fallback_value;
}
/**
* @param string $xml_tag
* @param bool $fallback_value
*
* @return string
*/
public function getXMLValue($xml_tag, $fallback_value = false)
{
if($this->override_values != false)
Expand Down
6 changes: 6 additions & 0 deletions pts-core/objects/phodevi/phodevi_cache.php
Expand Up @@ -37,6 +37,12 @@ public function __construct($phodevi_cache, $storage_dir = null, $client_version
$this->storage_dir = $storage_dir;
$this->client_version = $client_version;
}
/**
* @param string $storage_dir
* @param int $client_version
*
* @return array[]
*/
public function restore_cache($storage_dir = null, $client_version = null)
{
$restore_cache = null;
Expand Down
6 changes: 6 additions & 0 deletions pts-core/objects/phodevi/phodevi_device_property.php
Expand Up @@ -26,6 +26,9 @@ class phodevi_device_property
private $object_function;
private $cache_code;

/**
* @param bool $cache_code
*/
public function __construct($function, $cache_code = false)
{
$this->object_function = $function;
Expand All @@ -35,6 +38,9 @@ public function get_device_function()
{
return $this->object_function;
}
/**
* @return bool
*/
public function cache_code()
{
return $this->cache_code;
Expand Down
18 changes: 18 additions & 0 deletions pts-core/objects/phodevi/phodevi_vfs.php
Expand Up @@ -119,6 +119,9 @@ public static function cleanse_file(&$file, $name = false)
break;
}
}
/**
* @return void
*/
public function clear_cache()
{
$this->cache = array();
Expand All @@ -127,6 +130,11 @@ public function cache_index()
{
return array_keys($this->cache);
}
/**
* @param string $name
*
* @return string
*/
public function __get($name)
{
// This assumes that isset() has been called on $name prior to actually trying to get it...
Expand Down Expand Up @@ -198,6 +206,11 @@ public function __get($name)

return false;
}
/**
* @param string $name
*
* @return bool
*/
public function __isset($name)
{
return isset($this->cache[$name]) || (PTS_IS_CLIENT && $this->cache_isset_names($name));
Expand All @@ -206,6 +219,11 @@ public function set_cache_item($name, $cache)
{
$this->cache[$name] = $cache;
}
/**
* @param string $name
*
* @return bool
*/
public function cache_isset_names($name)
{
// Cache the isset call names with their values when checking files/commands since Phodevi will likely hit each one potentially multiple times and little overhead to caching them
Expand Down
17 changes: 17 additions & 0 deletions pts-core/objects/pts_exdep_generic_parser.php
Expand Up @@ -50,6 +50,13 @@ public static function get_external_dependency_path()
{
return PTS_CORE_PATH . 'external-test-dependencies/';
}
/**
* @param string $title
* @param string|null $file_check
* @param string|null $possible_packages
*
* @return (null|string)[]
*/
public function get_package_format($title = null, $file_check = null, $possible_packages = null)
{
return array(
Expand All @@ -62,10 +69,20 @@ public function get_available_packages()
{
return array_keys($this->struct['external-dependencies']['generic-packages']);
}
/**
* @param string $package
*
* @return bool
*/
public function is_package($package)
{
return isset($this->struct['external-dependencies']['generic-packages'][$package]);
}
/**
* @param string $package
*
* @return string[]
*/
public function get_package_data($package)
{
return $this->is_package($package) ? $this->struct['external-dependencies']['generic-packages'][$package] : $this->get_package_format();
Expand Down
25 changes: 25 additions & 0 deletions pts-core/objects/pts_storage_object.php
Expand Up @@ -38,10 +38,18 @@ public function __construct($span_reboots = true, $span_versions = true)
$this->pts_version = PTS_CORE_VERSION;
$this->object_cache = array();
}
/**
* @param string identifier
*
* @return void
*/
public function add_object($identifier, $object)
{
$this->object_cache[$identifier] = $object;
}
/**
* @param string $identifier
*/
public function read_object($identifier)
{
return isset($this->object_cache[$identifier]) ? $this->object_cache[$identifier] : false;
Expand All @@ -50,10 +58,18 @@ public function remove_object($identifier)
{
unset($this->object_cache[$identifier]);
}
/**
* @return array
*/
public function get_objects()
{
return $this->object_cache;
}
/**
* @param string $destination
*
* @return void
*/
public function save_to_file($destination)
{
$this->object_cs = md5(serialize($this->get_objects())); // Checksum
Expand All @@ -65,14 +81,23 @@ public function get_pts_version()
{
return $this->pts_version;
}
/**
* @return string
*/
public function get_object_checksum()
{
return $this->object_cs;
}
/**
* @return bool
*/
public function get_span_reboots()
{
return $this->span_reboots;
}
/**
* @return bool
*/
public function get_span_versions()
{
return $this->span_versions !== false;
Expand Down
19 changes: 19 additions & 0 deletions pts-core/objects/pts_test_file_download.php
Expand Up @@ -37,6 +37,16 @@ class pts_test_file_download
private $download_location_type = null;
private $download_location_path = null;

/**
* @param string|null $url
* @param string|null $filename
* @param int $filesize
* @param string|null $md5
* @param string|null $sha256
* @param string|null $platform
* @param string|null $architecture
* @param string|null $is_optional
*/
public function __construct($url = null, $filename = null, $filesize = 0, $md5 = null, $sha256 = null, $platform = null, $architecture = null, $is_optional = false)
{
$this->filename = empty($filename) ? basename($url) : $filename;
Expand Down Expand Up @@ -72,6 +82,9 @@ public function get_download_url_string()
{
return $this->url;
}
/**
* @return string[]
*/
public function get_platform_array()
{
return pts_strings::comma_explode($this->platform);
Expand All @@ -80,6 +93,9 @@ public function get_platform_string()
{
return $this->platform;
}
/**
* @return string[]
*/
public function get_architecture_array()
{
return pts_strings::comma_explode($this->architecture);
Expand All @@ -92,6 +108,9 @@ public function get_filename()
{
return $this->filename;
}
/**
* @return string
*/
public function get_filesize()
{
return $this->filesize;
Expand Down

0 comments on commit 99e026f

Please sign in to comment.