* If set to true, missing classes will be ignored and
* exceptions will be inhibited
*
* @param int $expected_type_categories
* If set to CLASS_LIST_ACCEPT_ANY, this will not warn.
* If set to CLASS_LIST_ACCEPT_OBJECT, this will warn if the inferred type is exclusively non-object types. This will not add classes based on LiteralStringType
* If set to CLASS_LIST_ACCEPT_OBJECT_OR_CLASS_NAME, this will warn if the inferred type is exclusively non-object and non-string types.
*
* @param ?string $custom_issue_type
* If this exists, emit the given issue type (passing in the class's union type as format arg) instead of the default issue type.
* The issue type passed in must have exactly one template string parameter (e.g. {CLASS}, {TYPE})
*
* @return list<Clazz>
* A list of classes representing the non-native types
* associated with the given node
*
* @throws CodeBaseException
* An exception is thrown if a non-native type does not have
* an associated class
*
* @throws IssueException
* An exception is thrown if fetching the requested class name
* would trigger an issue (e.g. Issue::ContextNotObject)
// If this is a variable that is both read and written,
// then set the previously undefined variable type to null instead so we can type check it
// (e.g. arguments to array_shift())
//
// Also, if this has a real type signature that would make PHP throw a TypeError when passed null, then set this to null so the type checker will emit a warning (#1344)
//
// (TODO: read/writeable is currently only possible to annotate for internal functions in FunctionSignatureMap.php),
// TODO: How should this handle variadic references?
$variable->setUnionType($null_type);
}
$this->context->addScopeVariable($variable);
return$variable;
}
/**
* @param bool $is_static
* True if we're looking for a static property,
* false if we're looking for an instance property.
*
* @return Property
* Phan's representation of a property declaration.
*
* @throws NodeException
* An exception is thrown if we can't understand the node
*
* @throws IssueException
* An exception is thrown if we can't find the given
* class or if we don't have access to the property (its
* private or protected)
* or if the property is static and missing.
*
* @throws UnanalyzableException
* An exception is thrown if we hit a construct in which
* we can't determine if the property exists or not
*/
publicfunctiongetProperty(
bool$is_static,
bool$is_known_assignment=false
):Property{
$node=$this->node;
if(!($nodeinstanceofNode)){
thrownewAssertionError('$this->node must be a node');