Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix formatting #8689

Merged
merged 2 commits into from Nov 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
96 changes: 48 additions & 48 deletions docs/annotating_code/type_syntax/atomic_types.md
Expand Up @@ -5,58 +5,58 @@ Atomic types are the basic building block of all type information used in Psalm.
_Click on the » next to each type to view detailed documentation and examples._

* [Scalar types »](scalar_types.md)
* [bool »](scalar_types.md#scalar)
* [int »](scalar_types.md#scalar)
* [float »](scalar_types.md#scalar)
* [string »](scalar_types.md#scalar)
* [`int-range<x, y>` &raquo;](scalar_types.md#int-range)
* [`int-mask<1, 2, 4>` &raquo;](scalar_types.md#int-mask1-2-4)
* [`int-mask-of<MyClass::CLASS_CONSTANT_*>` &raquo;](scalar_types.md#int-mask-ofmyclassclass_constant_)
* [class-string and class-string&lt;Foo&gt; &raquo;](scalar_types.md#class-string-interface-string)
* [trait-string &raquo;](scalar_types.md#trait-string)
* [enum-string &raquo;](scalar_types.md#enum-string)
* [callable-string &raquo;](scalar_types.md#callable-string)
* [numeric-string &raquo;](scalar_types.md#numeric-string)
* [literal-string &raquo;](scalar_types.md#literal-string)
* [literal-int &raquo;](scalar_types.md#literal-int)
* [array-key &raquo;](scalar_types.md#array-key)
* [numeric &raquo;](scalar_types.md#numeric)
* [scalar &raquo;](scalar_types.md#scalar)
* [bool &raquo;](scalar_types.md#scalar)
* [int &raquo;](scalar_types.md#scalar)
* [float &raquo;](scalar_types.md#scalar)
* [string &raquo;](scalar_types.md#scalar)
* [`int-range<x, y>` &raquo;](scalar_types.md#int-range)
* [`int-mask<1, 2, 4>` &raquo;](scalar_types.md#int-mask1-2-4)
* [`int-mask-of<MyClass::CLASS_CONSTANT_*>` &raquo;](scalar_types.md#int-mask-ofmyclassclass_constant_)
* [class-string and class-string&lt;Foo&gt; &raquo;](scalar_types.md#class-string-interface-string)
* [trait-string &raquo;](scalar_types.md#trait-string)
* [enum-string &raquo;](scalar_types.md#enum-string)
* [callable-string &raquo;](scalar_types.md#callable-string)
* [numeric-string &raquo;](scalar_types.md#numeric-string)
* [literal-string &raquo;](scalar_types.md#literal-string)
* [literal-int &raquo;](scalar_types.md#literal-int)
* [array-key &raquo;](scalar_types.md#array-key)
* [numeric &raquo;](scalar_types.md#numeric)
* [scalar &raquo;](scalar_types.md#scalar)
* [Object types &raquo;](object_types.md)
* [object &raquo;](object_types.md#unnamed-objects)
* [object{foo: string} &raquo;](object_types.md#object-properties)
* [Exception, Foo\MyClass and `Foo\MyClass<Bar>` &raquo;](object_types.md#named-objectsmd)
* [Generator](object_types.md#generators)
* [object &raquo;](object_types.md#unnamed-objects)
* [object{foo: string} &raquo;](object_types.md#object-properties)
* [Exception, Foo\MyClass and `Foo\MyClass<Bar>` &raquo;](object_types.md#named-objectsmd)
* [Generator](object_types.md#generators)
* [Array types &raquo;](array_types.md)
* [array&lt;int, string&gt; &raquo;](array_types.md#generic-arrays)
* [non-empty-array &raquo;](array_types.md#non-empty-array)
* [string\[\] &raquo;](array_types.md#phpdoc-syntax)
* [list & non-empty-list &raquo;](array_types.md#lists)
* [list&lt;string&gt; &raquo;](array_types.md#lists)
* [array{foo: int, bar: string} and list{int, string} &raquo;](array_types.md#object-like-arrays)
* [Sealed arrays &raquo;](array_types.md#sealed-object-like-arrays)
* [Unsealed arrays &raquo;](array_types.md#unsealed-object-like-arrays)
* [callable-array &raquo;](array_types.md#callable-arrays)
* [array&lt;int, string&gt; &raquo;](array_types.md#generic-arrays)
* [non-empty-array &raquo;](array_types.md#non-empty-array)
* [string\[\] &raquo;](array_types.md#phpdoc-syntax)
* [list & non-empty-list &raquo;](array_types.md#lists)
* [list&lt;string&gt; &raquo;](array_types.md#lists)
* [array{foo: int, bar: string} and list{int, string} &raquo;](array_types.md#object-like-arrays)
* [Sealed arrays &raquo;](array_types.md#sealed-object-like-arrays)
* [Unsealed arrays &raquo;](array_types.md#unsealed-object-like-arrays)
* [callable-array &raquo;](array_types.md#callable-arrays)
* [Callable types &raquo;](callable_types.md)
* [Value types &raquo;](value_types.md)
* [null &raquo;](value_types.md#null)
* [true, false &raquo;](value_types.md#true-false)
* [6, 7.0, "forty-two" and 'forty two' &raquo;](value_types.md#some_string-4-314)
* [Foo\Bar::MY_SCALAR_CONST &raquo;](value_types.md#regular-class-constants)
* [null &raquo;](value_types.md#null)
* [true, false &raquo;](value_types.md#true-false)
* [6, 7.0, "forty-two" and 'forty two' &raquo;](value_types.md#some_string-4-314)
* [Foo\Bar::MY_SCALAR_CONST &raquo;](value_types.md#regular-class-constants)
* [Utility types &raquo;](utility_types.md)
* [(T is true ? string : bool) &raquo;](conditional_types.md)
* [`key-of<T>` &raquo;](utility_types.md#key-oft)
* [`value-of<T>` &raquo;](utility_types.md#value-oft)
* [`properties-of<T>` &raquo;](utility_types.md#properties-oft)
* [`class-string-map<T as Foo, T>` &raquo;](utility_types.md#class-string-mapt-as-foo-t)
* [`T[K]` &raquo;](utility_types.md#tk)
* [Type aliases &raquo;](utility_types.md#type-aliases)
* [Variable templates &raquo;](utility_types.md#variable-templates)
* [(T is true ? string : bool) &raquo;](conditional_types.md)
* [`key-of<T>` &raquo;](utility_types.md#key-oft)
* [`value-of<T>` &raquo;](utility_types.md#value-oft)
* [`properties-of<T>` &raquo;](utility_types.md#properties-oft)
* [`class-string-map<T as Foo, T>` &raquo;](utility_types.md#class-string-mapt-as-foo-t)
* [`T[K]` &raquo;](utility_types.md#tk)
* [Type aliases &raquo;](utility_types.md#type-aliases)
* [Variable templates &raquo;](utility_types.md#variable-templates)
* [Other types &raquo;](other_types.md)
* [`iterable<TKey, TValue>` &raquo;](other_types.md)
* [void &raquo;](other_types.md)
* [resource &raquo;](other_types.md)
* [closed-resource &raquo;](other_types.md)
* [`iterable<TKey, TValue>` &raquo;](other_types.md)
* [void &raquo;](other_types.md)
* [resource &raquo;](other_types.md)
* [closed-resource &raquo;](other_types.md)
* [Top and bottom types &raquo;](top_bottom_types.md)
* [mixed &raquo;](top_bottom_types.md#mixed)
* [never &raquo;](top_bottom_types.md#never)
* [mixed &raquo;](top_bottom_types.md#mixed)
* [never &raquo;](top_bottom_types.md#never)
10 changes: 5 additions & 5 deletions docs/annotating_code/type_syntax/object_types.md
Expand Up @@ -7,15 +7,15 @@ _Click on the &raquo; next to each type to view detailed documentation and examp
- [Exception, Foo\MyClass and Foo\MyClass&lt;Bar&gt; &raquo;](#named-objects)
- [Generator](#generators)

### Unnamed objects
## Unnamed objects

`object` are examples of unnamed object types. This type is also a valid type in PHP.

### Named objects
## Named objects

`stdClass`, `Foo`, `Bar\Baz` etc. are examples of named object types. These types are also valid types in PHP.

### Object properties
## Object properties

Psalm supports specifying the properties of an object and their expected types, e.g.:

Expand All @@ -34,11 +34,11 @@ Optional properties can be denoted by a trailing `?`, e.g.:
/** @param object{optional?: string} */
```

### Generic object types
## Generic object types

Psalm supports using generic object types like `ArrayObject<int, string>`. Any generic object should be typehinted with appropriate [`@template` tags](../templated_annotations.md).

### Generators
## Generators

Generator types support up to four parameters, e.g. `Generator<int, string, mixed, void>`:

Expand Down
24 changes: 12 additions & 12 deletions docs/annotating_code/type_syntax/scalar_types.md
Expand Up @@ -20,12 +20,12 @@ _Click on the &raquo; next to each type to view detailed documentation and examp
* [numeric &raquo;](scalar_types.md#numeric)
* [scalar &raquo;](scalar_types.md#scalar)

### scalar
## scalar

`int`, `bool`, `float`, `string` are examples of scalar types. Scalar types represent scalar values in PHP. These types are also valid types in PHP 7.
The type `scalar` is the supertype of all scalar types.

### int-range
## int-range

Integer ranges indicate an integer within a range, specified using generic syntax: `int<x, y>`.
`x` and `y` must be integer numbers.
Expand All @@ -51,15 +51,15 @@ Represents the type that is the result of a bitmask combination of its parameter
Represents the type that is the result of a bitmask combination of its parameters.
This is the same concept as [`int-mask`](#int-mask1-2-4) but this type is used with a reference to constants in code: `int-mask-of<MyClass::CLASS_CONSTANT_*>` will correspond to `0|1|2|3|4|5|6|7` if there are three constants called `CLASS_CONSTANT_{A,B,C}` with values 1, 2 and 4.

### array-key
## array-key

`array-key` is the supertype (but not a union) of `int` and `string`.

### numeric
## numeric

`numeric` is a supertype of `int` or `float` and [`numeric-string`](#numeric-string).

### class-string, interface-string
## class-string, interface-string

Psalm supports a special meta-type for `MyClass::class` constants, `class-string`, which can be used everywhere `string` can.

Expand All @@ -79,23 +79,23 @@ function takesClassName(string $s) : void {}

You can also parameterize `class-string` with an object name e.g. [`class-string<Foo>`](value_types.md#regular-class-constants). This tells Psalm that any matching type must either be a class string of `Foo` or one of its descendants.

### trait-string
## trait-string

Psalm also supports a `trait-string` annotation denoting a trait that exists.

### enum-string
## enum-string

Psalm also supports a `enum-string` annotation denote an enum that exists.

### callable-string
## callable-string

`callable-string` denotes a string value that has passed an `is_callable` check.

### numeric-string
## numeric-string

`numeric-string` denotes a string value that has passed an `is_numeric` check.

### literal-string
## literal-string

`literal-string` denotes a string value that is entirely composed of strings in your application.

Expand All @@ -113,7 +113,7 @@ Strings that don't pass this type check:
- `$_GET["foo"]`
- `"hello " . $_GET["foo"]`

### literal-int
## literal-int

`literal-int` denotes an int value that is entirely composed of literal integers in your application.

Expand All @@ -128,7 +128,7 @@ Integers that don't pass this type check:
- `(int) $_GET["foo"]`
- `((int)$_GET["foo"]) + 2`

### lowercase-string, non-empty-string, non-empty-lowercase-string
## lowercase-string, non-empty-string, non-empty-lowercase-string

A non empty string, lowercased or both at once.

Expand Down
1 change: 1 addition & 0 deletions docs/annotating_code/type_syntax/top_bottom_types.md
Expand Up @@ -6,6 +6,7 @@
This is the _top type_ in PHP's type system, and represents a lack of type information. Psalm warns about `mixed` types when the `reportMixedIssues` flag is turned on, or when you're on level 1.

## `never`

It can be aliased to `no-return` or `never-return` in docblocks. Note: it replaced the old `empty` type that used to exist in Psalm

This is the _bottom type_ in PHP's type system. It's used to describe a type that has no possible value. It can happen in multiple cases:
Expand Down
2 changes: 1 addition & 1 deletion docs/annotating_code/type_syntax/utility_types.md
Expand Up @@ -119,7 +119,7 @@ properties with a certain visibility:
- `private-properties-of<T>`


### Limited template support
### Sealed array support

Use final classes if you want to properties-of and get_object_vars to return [sealed arrays](array_types.md#sealed-object-like-arrays):

Expand Down
8 changes: 4 additions & 4 deletions docs/annotating_code/type_syntax/value_types.md
Expand Up @@ -9,19 +9,19 @@ _Click on the &raquo; next to each type to view detailed documentation and examp
- [6, 7.0, "forty-two" and 'forty two' &raquo;](#some_string-4-314)
- [Foo\Bar::MY_SCALAR_CONST &raquo;](#regular-class-constants)

### null
## null

This is the `null` value, destroyer of worlds. Use it sparingly. Psalm supports you writing `?Foo` to mean `null|Foo`.

### true, false
## true, false

Use of `true` and `false` is also PHPDoc-compatible

### "some_string", 4, 3.14
## "some_string", 4, 3.14

Psalm also allows you specify literal values in types, e.g. `@return "good"|"bad"`

### Regular class constants
## Regular class constants

Psalm allows you to include class constants in types, e.g. `@return Foo::GOOD|Foo::BAD`. You can also specify explicit class strings e.g. `Foo::class|Bar::class`

Expand Down