Skip to content

Commit

Permalink
Fix typehints to php-native types
Browse files Browse the repository at this point in the history
  • Loading branch information
JayBraker committed Jan 13, 2025
1 parent b35c47a commit c6cf702
Showing 1 changed file with 49 additions and 49 deletions.
98 changes: 49 additions & 49 deletions classes/text_filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,71 +57,71 @@ class text_filter extends \filter_jsxgraph_base_text_filter {
/**
* Path to jsxgraphcores
*
* @var String
* @var \string
*/
public const PATH_FOR_CORES = '/filter/jsxgraph/amd/src/';

/**
* Path to library folders
*
* @var String
* @var \string
*/
public const PATH_FOR_LIBS = '/filter/jsxgraph/libs/';

/**
* Const for tag name (<jsxgraph></jsxgraph>).
*
* @var String
* @var \string
*/
private const TAG = "jsxgraph";

/**
* Name for JavaScript constant for board ids.
* This is supplemented by a counter (BOARDID0, BOARDID1, ...).
*
* @var String
* @var \string
*/
private const BOARDID_CONST = "BOARDID";

/**
* Name for JavaScript constant array of board ids.
*
* @var String
* @var \string
*/
private const BOARDIDS_CONST = "BOARDIDS";

/**
* HTML encoding.
*
* @var String
* @var \string
*/
private const ENCODING = "UTF-8";

/**
* Allowed dimension attributes.
*
* @var String
* @var \array
*/
private const ALLOWED_DIMS = ["aspect-ratio", "width", "height", "max-width", "max-height"];

/**
* Attribute for aspect ratio.
*
* @var String
* @var \string
*/
private const AR = "aspect-ratio";

/**
* Allowed dimension attributes without aspect ratio.
*
* @var String
* @var \array
*/
private const ALLOWED_DIMS_EXCEPT_AR = ["width", "height", "max-width", "max-height"];

/**
* Attributes for width.
*
* @var String
* @var \array
*/
private const WIDTHS = ["width", "max-width"];

Expand All @@ -135,45 +135,45 @@ class text_filter extends \filter_jsxgraph_base_text_filter {
/**
* List of <jsxgraph> tags.
*
* @var domNode[]
* @var \array
*/
private $taglist = null;

/**
* Global admin settings.
*
* @var object
* @var \object
*/
private $settings = null;

/**
* List of used unique board ids. Length >= length of $taglist.
*
* @var string[]
* @var \array
*/
private $ids = [];

/**
* Used version of JSXGraph.
*
* @var null|object
* @var \null|\object
*/
private $versionjsx = null;

/**
* Used version of Moodle.
*
* @var null|object
* @var \null|\object
*/
private $versionmoodle = null;

/**
* Main filter function.
*
* @param String $text Moodle standard.
* @param Array $options Moodle standard.
* @param \string $text Moodle standard.
* @param \array $options Moodle standard.
*
* @return String
* @return \string
*/
public function filter($text, $options = []) {
// To optimize speed, search for a <jsxgraph> tag (avoiding to parse everything on every text).
Expand Down Expand Up @@ -252,10 +252,10 @@ public function filter($text, $options = []) {
/**
* Create a new div node for a given JSXGraph node.
*
* @param domNode $node JSXGraph node.
* @param Integer $index Index in taglist.
* @param \domNode $node JSXGraph node.
* @param \int $index Index in taglist.
*
* @return domNode
* @return \domNode
*/
private function get_replaced_node($node, $index) {
$attributes = $this->get_tagattributes($node);
Expand Down Expand Up @@ -314,7 +314,7 @@ private function get_replaced_node($node, $index) {
/**
* Combine global code and code contained in $node. Define some JavaScript constants. Apply this code to the dom.
*
* @param domNode $node JSXGraph node.
* @param \domNode $node JSXGraph node.
*
* @return void
*/
Expand Down Expand Up @@ -391,7 +391,7 @@ private function apply_js($node) {
/**
* Helper Function for apply_js(...). Returns the pre and post part of JavaScript code.
*
* @return String[]
* @return string[]
*/
private function get_code_surroundings() {
$result = [
Expand Down Expand Up @@ -654,24 +654,24 @@ static function css_norm($var, $default = '') {
* (c) If only width is given, the height will be 0 like in css. You have to define an aspect-ratio or height to display the
* board!
*
* @param String $id
* @param Object $dimensions with possible attributes
* @param \string $id
* @param \object $dimensions with possible attributes
* aspect-ratio (the ratio of width / height)
* width (px, rem, vw, ...; if only a number is given, its interpreted as px)
* height (px, rem, vh, ...; if only a number is given, its interpreted as px)
* max-width (px, rem, vw, ...; if only a number is given, its interpreted as px)
* min-width (px, rem, vw, ...; if only a number is given, its interpreted as px)
* max-height (px, rem, vh, ...; if only a number is given, its interpreted as px)
* min-height (px, rem, vh, ...; if only a number is given, its interpreted as px)
* @param String $classes Additional css classes for the board.
* @param String $wrapperclasses Additional css classes for the boards container.
* @param \string $classes Additional css classes for the board.
* @param \string $wrapperclasses Additional css classes for the boards container.
* (If it is needed. In the other case this is merged with $classes.)
* @param Boolean $forcewrapper Default: false.
* @param String $defaultaspectratio Default: "1 / 1".
* @param String $defaultwidth Default: "100%".
* @param Boolean $perventjsdimreg Default: false.
* @param \bool $forcewrapper Default: false.
* @param \string $defaultaspectratio Default: "1 / 1".
* @param \string $defaultwidth Default: "100%".
* @param \bool $perventjsdimreg Default: false.
*
* @return String The <div> for the board.
* @return string The <div> for the board.
*/
private function get_board_html(
$id, $dimensions = [], $classes = "", $wrapperclasses = "", $forcewrapper = false,
Expand Down Expand Up @@ -778,7 +778,7 @@ private function get_board_html(
/**
* Load additional library
*
* @param String $libname
* @param \string $libname
*
*/
private function load_library($libname) {
Expand Down Expand Up @@ -815,9 +815,9 @@ private function load_library($libname) {
/**
* Determine the attributes
*
* @param domNode $node
* @param \domNode $node
*
* @return String[]
* @return \array
*/
private function get_tagattributes($node) {
$numberofboardsattr = 'numberOfBoards';
Expand Down Expand Up @@ -893,7 +893,7 @@ private function get_tagattributes($node) {
/**
* Get settings made by administrator
*
* @return Array settings from administration
* @return \array settings from administration
*/
private function get_adminsettings() {
// Set defaults.
Expand Down Expand Up @@ -944,9 +944,9 @@ private function get_adminsettings() {
/**
* Converts a version string like 1.2.3 to an integer.
*
* @param String $versionstring
* @param \string $versionstring
*
* @return Integer
* @return \int
*/
private function jxg_to_version_number($versionstring) {
$arr = explode('.', $versionstring);
Expand All @@ -960,12 +960,12 @@ private function jxg_to_version_number($versionstring) {
/**
* Gives the value of $attribute in $node as bool. If the attribute does not exist, $stdval is returned.
*
* @param domNode $node
* @param String $attribute
* @param String $givenval
* @param bool|String $stdval
* @param \domNode $node
* @param \string $attribute
* @param \string $givenval
* @param \bool|\string $stdval
*
* @return bool
* @return \bool
*/
private function get_bool_value($node, $attribute, $givenval, $stdval) {
if ($node->hasAttribute($attribute)) {
Expand All @@ -982,10 +982,10 @@ private function get_bool_value($node, $attribute, $givenval, $stdval) {
/**
* Convert string to bool
*
* @param String $string
* @param bool $default
* @param \string $string
* @param \bool $default
*
* @return bool
* @return \bool
*/
private function convert_bool($string, $default = false) {
if ($string === false || $string === "false" || $string === 0 || $string === "0") {
Expand All @@ -1000,10 +1000,10 @@ private function convert_bool($string, $default = false) {
/**
* Decide between two strings
*
* @param String $choice1
* @param String $choice2
* @param \string $choice1
* @param \string $choice2
*
* @return String
* @return \string
*/
private function string_or($choice1, $choice2) {
if (!empty($choice1)) {
Expand Down

0 comments on commit c6cf702

Please sign in to comment.