Functions

Checks a CSS style sheet (high level).

check_css(string $data) : \?map
package core_webstandards

Parameters

$data

string

The data of the style sheet

Returns

\?mapError information (null: no error)

Check some JS code for conformance.

check_js(string $data, boolean $raw_errors = false) : array
package core_webstandards

Parameters

$data

string

Code

$raw_errors

boolean

Whether to return raw-errors

Returns

arrayStandard checker report output

Checks the spelling of some text.

check_spelling(string $value) : \list
package core_webstandards

Parameters

$value

string

The text

Returns

\listArray of errors

Check the specified XHTML, and return the results.

check_xhtml(string $out, boolean $well_formed_only = false, boolean $is_fragment = false, boolean $webstandards_javascript = true, boolean $webstandards_css = true, boolean $webstandards_wcag = true, boolean $webstandards_compat = true, boolean $webstandards_ext_files = true, boolean $webstandards_manual = false) : \?map
package core_webstandards

Parameters

$out

string

The XHTML to check

$well_formed_only

boolean

Whether to avoid checking for relational errors (false implies just a quick structural check, aka a 'well formed' check)

$is_fragment

boolean

Whether what is being checked is an HTML fragment, rather than a whole document

$webstandards_javascript

boolean

Validate javascript

$webstandards_css

boolean

Validate CSS

$webstandards_wcag

boolean

Validate WCAG

$webstandards_compat

boolean

Validate for compatibility

$webstandards_ext_files

boolean

Validate external files

$webstandards_manual

boolean

Bring up messages about manual checks

Returns

\?mapError information (null: no error)

Fix any invalid entities in the text.

fix_entities(string $in) : string
package core_webstandards

Parameters

$in

string

Text to fix in

Returns

stringFixed result

Checks to see if a string holds a hexadecimal number.

is_hex(string $string) : boolean
package core_webstandards

Parameters

$string

string

The string to check

Returns

booleanWhether the string holds a hexadecimal number

Helper function for usort to sort a list by string length.

jlex__strlen_sort(string $a, string $b) : integer
package core_webstandards

Parameters

$a

string

The first string to compare

$b

string

The second string to compare

Returns

integerThe comparison result

Add a reference to a named variable.

js_add_variable_reference(string $identifier, integer $first_mention, boolean $instantiation = true, boolean $reference = false, \?string $function_return = null, boolean $is_call = false
package core_webstandards

Parameters

$identifier

string

The variable name

$first_mention

integer

Where the first mention of the variable is

$instantiation

boolean

Whether this is an instantiation reference

$reference

boolean

Whether this is a reference (as opposed to instantiation/setting)

$function_return

\?string

The result-type (null: not a function)

$is_call

boolean

Whether this is a function call

Check an assignment statement.

js_check_assignment(\list $c, integer $c_pos) : string
package core_webstandards

Parameters

$c

\list

The complex assignment details

$c_pos

integer

The position this is at in the parse

Returns

stringThe assigned type

Check a function call.

js_check_call(\list $c, integer $c_pos, \?string $class = null) : \?string
package core_webstandards

Parameters

$c

\list

The (possibly complex) variable that is the function identifier

$c_pos

integer

The position this is at in the parse

$class

\?string

The class the given variable is in (null: global/as-specified-internally-in-c)

Returns

\?stringThe return type (null: nothing returned)

Check a parsed command.

js_check_command(\list $command, integer $depth) 
package core_webstandards

Parameters

$command

\list

The command

$depth

integer

The block depth we are searching at

Check an expression.

js_check_expression(\list $e, boolean $secondary = false, boolean $is_guarded = false) : string
package core_webstandards

Parameters

$e

\list

The complex expression

$secondary

boolean

Whether the expression is being used as a command (i.e. whether the expression is not used for the result, but rather, the secondary consequences of calculating it)

$is_guarded

boolean

Whether the expression is being guarded and hence is not a proper reference

Returns

stringThe type

Check a function declaration.

js_check_function(\map $function) 
package core_webstandards

Parameters

$function

\map

The function details

Check a variable.

js_check_variable(\list $variable, boolean $reference = false, boolean $function_duality = false, \?string $class = null, boolean $allow_static = false, boolean $is_call = false) : mixed
package core_webstandards

Parameters

$variable

\list

The (possibly complex) variable

$reference

boolean

Whether the variable is being used referentially (i.e. not being set)

$function_duality

boolean

Whether to return the type and function-return-type pair, rather than just the type

$class

\?string

The class the variable is referencing within (null: global)

$allow_static

boolean

Whether the given class is being referenced directly in static form

$is_call

boolean

Whether this is for a function call

Returns

mixedThe return type and possibly function return type (if requested)

Check a variable list for consistency.

js_check_variable_list(\list $JS_LOCAL_VARIABLES) 
package core_webstandards

Parameters

$JS_LOCAL_VARIABLES

\list

The variable list

Make a JS error (critically).

js_die_error(string $system, integer $pos, string $line, string $message, integer $i) : \?boolean
package core_webstandards

Parameters

$system

string

The system causing the error

$pos

integer

The position

$line

string

The line

$message

string

The error

$i

integer

The global position

Returns

\?booleanAlways NULL (null: exit)

Do type checking for something specific.

js_ensure_type(\list $_allowed_types, string $actual_type, integer $pos, \?string $alt_error = null) : boolean
package core_webstandards

Parameters

$_allowed_types

\list

List of allowed types

$actual_type

string

Actual type involved

$pos

integer

Current parse position

$alt_error

\?string

Specific error message to give (null: use default)

Returns

booleanWhether it type-checks

Get the type of a variable.

js_get_variable_type(\list $variable) : string
package core_webstandards

Parameters

$variable

\list

The variable

Returns

stringThe type

If the given expression is a direct variable expression, this function will infer the type as the given type. This therefore allows type inferring on usage as well as on assignment.

js_infer_expression_type_to_variable_type(string $type, \list $expr) 
package core_webstandards

Parameters

$type

string

The type

$expr

\list

The expression

Log a warning when lexing/parsing/checking.

js_log_warning(string $system, string $warning, integer $i = -1, boolean $absolute = false
package core_webstandards

Parameters

$system

string

The system causing the error

$warning

string

The warning

$i

integer

The global position

$absolute

boolean

Whether the position is a string offset (as opposed to a token position)

Convert a position to a triplet of details about the line it is on.

js_pos_to_line_details(integer $i, boolean $absolute = false) : \list
package core_webstandards

Parameters

$i

integer

The position

$absolute

boolean

Whether the position is a string offset (as opposed to a token position)

Returns

\listThe quartet of details (line offset, line number, the line, the absolute position)

Scan through a complex variable, checking any expressions embedded in it.

js_scan_extractive_expressions(\list $variable) 
package core_webstandards

Parameters

$variable

\list

The complex variable

Add a type to the list of used types for a variable.

js_set_composr_type(string $identifier, string $type) 
package core_webstandards

Parameters

$identifier

string

The variable name

$type

string

The type

Get the next character whilst lexing

lex__get_next_char(integer $i) : \list
package core_webstandards

Parameters

$i

integer

Get character at this position

Returns

\listGet triplet about the next character (whether end reached, new position, character)

Get the next characters whilst lexing

lex__get_next_chars(integer $i, integer $num) : \list
package core_webstandards

Parameters

$i

integer

Get character at this position

$num

integer

How many to get

Returns

\listGet triplet about the next character (whether end reached, new position, characters)

Expect a token during parsing. Give error if not found. Else give token parameters.

parser_expect(string $token) : \?mixed
package core_webstandards

Parameters

$token

string

The token we want

Returns

\?mixedThe token parameters (null: error)

Find the next token and move on.

parser_next(boolean $all = false) : \?mixed
package core_webstandards

Parameters

$all

boolean

Whether we want all the token parameters (as opposed to just the first)

Returns

\?mixedAll the token parameters, or just the first (null: error)

Peek to find the next token.

parser_peek(boolean $all = false) : \?mixed
package core_webstandards

Parameters

$all

boolean

Whether we want all the token parameters (as opposed to just the first)

Returns

\?mixedAll the token parameters, or just the first (null: error)

Peek to find the next token after a distance.

parser_peek_dist(integer $d, \?integer $p = null) : \?mixed
package core_webstandards

Parameters

$d

integer

The distance

$p

\?integer

Whether to start looking from (null: current position in parse)

Returns

\?mixedThe first token parameter (null: error)

Sort an unordered structure of operations into a precedence tree.

precedence_sort(\list $op_list) : \list
package core_webstandards

Parameters

$op_list

\list

Ops in

Returns

\listOps out

Return the global variable array to the defaults.

reset_js_global_variables() 

Test the next entity in the output stream.

test_entity(integer $offset = 0) : \?mixed
package core_webstandards

Parameters

$offset

integer

Checking offset

Returns

\?mixedAn array of error details (null: no errors)

Lex some JavaScript code.

webstandards_js_lex(string $text) : \list
package core_webstandards

Parameters

$text

string

The code

Returns

\listList of lexed tokens

Return parse info for parse type.

webstandards_js_parse() : \?map
package core_webstandards

Returns

\?mapParse info (null: error)

Give a parse error.

webstandards_js_parser_error(string $message) : \?boolean
package core_webstandards

Parameters

$message

string

The error

Returns

\?booleanAlways NULL (null: exit)

Constants

 

CSS_AT_RULE

CSS_AT_RULE = -3 
 

CSS_AT_RULE_BLOCK

CSS_AT_RULE_BLOCK = -4 
 

CSS_EXPECTING_IDENTIFIER

CSS_EXPECTING_IDENTIFIER = -1 
 

CSS_EXPECTING_SEP_OR_IDENTIFIER_OR_CLASS

CSS_EXPECTING_SEP_OR_IDENTIFIER_OR_CLASS = 2 
 

CSS_IN_CLASS

CSS_IN_CLASS = 1 
 

CSS_IN_COMMENT

CSS_IN_COMMENT = 0 
 

CSS_IN_IDENTIFIER

CSS_IN_IDENTIFIER = 3 
 

CSS_IN_PSEUDOCLASS_EXPRESSION

CSS_IN_PSEUDOCLASS_EXPRESSION = 6 
 

CSS_NO_MANS_LAND

CSS_NO_MANS_LAND = -2 
 

DOCTYPE_HTML

DOCTYPE_HTML = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">' 
 

DOCTYPE_HTML_STRICT

DOCTYPE_HTML_STRICT = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">' 
 

DOCTYPE_XHTML

DOCTYPE_XHTML = '<!DOCTYPE html>' 
 

DOCTYPE_XHTML5

DOCTYPE_XHTML5 = '<!DOCTYPE html>' 
 

DOCTYPE_XHTML_11

DOCTYPE_XHTML_11 = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">' 
 

DOCTYPE_XHTML_STRICT

DOCTYPE_XHTML_STRICT = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' 
 

IN_CDATA

IN_CDATA = 11 
 

IN_COMMENT

IN_COMMENT = 0 
 

IN_DTD_TAG

IN_DTD_TAG = -2 
 

IN_TAG_ATTRIBUTE_NAME

IN_TAG_ATTRIBUTE_NAME = 4 
 

IN_TAG_ATTRIBUTE_VALUE_BIG_QUOTES

IN_TAG_ATTRIBUTE_VALUE_BIG_QUOTES = 10 
 

IN_TAG_ATTRIBUTE_VALUE_LITTLE_QUOTES

IN_TAG_ATTRIBUTE_VALUE_LITTLE_QUOTES = 8 
 

IN_TAG_ATTRIBUTE_VALUE_NO_QUOTES

IN_TAG_ATTRIBUTE_VALUE_NO_QUOTES = 12 
 

IN_TAG_BETWEEN_ATTRIBUTES

IN_TAG_BETWEEN_ATTRIBUTES = 3 
 

IN_TAG_BETWEEN_ATTRIBUTE_NAME_VALUE_LEFT

IN_TAG_BETWEEN_ATTRIBUTE_NAME_VALUE_LEFT = 5 
 

IN_TAG_BETWEEN_ATTRIBUTE_NAME_VALUE_RIGHT

IN_TAG_BETWEEN_ATTRIBUTE_NAME_VALUE_RIGHT = 7 
 

IN_TAG_EMBEDDED_COMMENT

IN_TAG_EMBEDDED_COMMENT = 9 
 

IN_TAG_NAME

IN_TAG_NAME = 1 
 

IN_XML_TAG

IN_XML_TAG = -3 
 

LEXER_COMMENT

LEXER_COMMENT = 5 
 

LEXER_DOUBLE_QUOTE_STRING_LITERAL

LEXER_DOUBLE_QUOTE_STRING_LITERAL = 6 
 

LEXER_FREE

LEXER_FREE = 1 
 

LEXER_ML_COMMENT

LEXER_ML_COMMENT = 4 
 

LEXER_NUMERIC_LITERAL

LEXER_NUMERIC_LITERAL = 8 
 

LEXER_REGEXP

LEXER_REGEXP = 2 
 

LEXER_SINGLE_QUOTE_STRING_LITERAL

LEXER_SINGLE_QUOTE_STRING_LITERAL = 7 
 

NO_MANS_LAND

NO_MANS_LAND = -1 
 

STARTING_TAG

STARTING_TAG = 2 
 

_CSS_EXPECTING_END

_CSS_EXPECTING_END = 5 
 

_CSS_IN_COMMENT

_CSS_IN_COMMENT = 4 
 

_CSS_IN_PROPERTY_BETWEEN

_CSS_IN_PROPERTY_BETWEEN = 2 
 

_CSS_IN_PROPERTY_KEY

_CSS_IN_PROPERTY_KEY = 1 
 

_CSS_IN_PROPERTY_VALUE

_CSS_IN_PROPERTY_VALUE = 3 
 

_CSS_NO_MANS_LAND

_CSS_NO_MANS_LAND = 0