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 grammar #11154

Merged
merged 3 commits into from
Nov 10, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/annotating_code/type_syntax/top_bottom_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ It can be aliased to `no-return` or `never-return` in docblocks. Note: it replac
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:

- the actual `never` type from PHP 8.1 (can be used in docblocks for older versions). This type can be used as a return type for functions that will never return, either because they always throw exceptions or always exit()
- an union type that have been stripped for all its possible types. (For example, if a variable is `string|int` and we perform a is_bool() check in a condition, the type of the variable in the condition will be `never` as the condition will never be entered)
- a union type that has been stripped of all its possible types. (For example, if a variable is `string|int` and we perform an is_bool() check in a condition, the type of the variable in the condition will be `never` as the condition will never be entered)
- it can represent a placeholder for types yet to come — a good example is the type of the empty array `[]`, which Psalm types as `array<never, never>`, the content of the array is void so it can accept any content
- it can also happen in the same context as the line above for templates that have yet to be defined
20 changes: 10 additions & 10 deletions docs/running_psalm/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -444,21 +444,21 @@ Allows you to hard-code the number of threads Psalm will use (similar to `--thre
maxStringLength="1000"
>
```
This setting controls the maximum length of literal strings that will be transformed into a literal string type during Psalm analysis.
Strings longer than this value (by default 1000 bytes) will be transformed in a generic `non-empty-string` type, instead.
This setting controls the maximum length of literal strings that will be transformed into a literal string type during Psalm analysis.
Strings longer than this value (by default 1000 bytes) will be transformed in a generic `non-empty-string` type, instead.

Please note that changing this setting might introduce unwanted side effects and those side effects won't be considered as bugs.
Please note that changing this setting might introduce unwanted side effects and those side effects won't be considered as bugs.

#### maxShapedArraySize
```xml
<psalm
maxShapedArraySize="100"
>
```
This setting controls the maximum size of shaped arrays that will be transformed into a shaped `array{key1: "value", key2: T}` type during Psalm analysis.
Arrays bigger than this value (100 by default) will be transformed in a generic `non-empty-array` type, instead.
This setting controls the maximum size of shaped arrays that will be transformed into a shaped `array{key1: "value", key2: T}` type during Psalm analysis.
Arrays bigger than this value (100 by default) will be transformed in a generic `non-empty-array` type, instead.

Please note that changing this setting might introduce unwanted side effects and those side effects won't be considered as bugs.
Please note that changing this setting might introduce unwanted side effects and those side effects won't be considered as bugs.

#### restrictReturnTypes

Expand All @@ -474,20 +474,20 @@ the inferred return type.
This code:
```php
function getOne(): int // declared type: int
{
{
return 1; // inferred type: 1 (int literal)
}
```
Will give this error: `LessSpecificReturnType - The inferred return type '1' for
a is more specific than the declared return type 'int'`
getOne is more specific than the declared return type 'int'`

To fix the error, you should specify the more specific type in the doc-block:
```php
/**
* @return 1
*/
function getOne(): int
{
function getOne(): int
{
return 1;
}
```
Expand Down
2 changes: 1 addition & 1 deletion docs/running_psalm/issues/TaintedHeader.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# TaintedHeader

Potential header injection. This rule is emitted when user-controlled input can be passed into a HTTP header.
Potential header injection. This rule is emitted when user-controlled input can be passed into an HTTP header.

## Risk

Expand Down
2 changes: 1 addition & 1 deletion docs/running_psalm/issues/TaintedHtml.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Emitted when user-controlled input that can contain HTML can be passed into to a

## Risk

This could lead to a potential Cross Site Scripting (XSS) vulnerability. Using a XSS vulnerability, an attacker could inject malicious JavaScript and execute any action JavaScript could do. Examples include:
This could lead to a potential Cross Site Scripting (XSS) vulnerability. Using an XSS vulnerability, an attacker could inject malicious JavaScript and execute any action JavaScript could do. Examples include:

- Stealing authentication material (e.g. cookies, JWT tokens)
- Exfiltrate sensitive information by reading the DOM
Expand Down
4 changes: 2 additions & 2 deletions docs/running_psalm/issues/TaintedSSRF.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ Potential Server-Side Request Forgery vulnerability. This rule is emitted when u

## Risk

Passing untrusted user input to network requests could be dangerous.
Passing untrusted user input to network requests could be dangerous.

If an attacker can fully control a HTTP request they could connect to internal services. Depending on the nature of these, this can pose a security risk. (e.g. backend services, admin interfaces, AWS metadata, ...)
If an attacker can fully control an HTTP request they could connect to internal services. Depending on the nature of these, this can pose a security risk. (e.g. backend services, admin interfaces, AWS metadata, ...)

## Example

Expand Down
2 changes: 1 addition & 1 deletion docs/running_psalm/issues/TaintedSql.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# TaintedSql

Emitted when user-controlled input can be passed into to a SQL command.
Emitted when user-controlled input can be passed into to an SQL command.

```php
<?php
Expand Down
2 changes: 1 addition & 1 deletion docs/running_psalm/issues/TaintedTextWithQuotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Emitted when user-controlled input that can contain quotation marks can be passe

## Risk

This could lead to a potential Cross Site Scripting (XSS) vulnerability. Using a XSS vulnerability, an attacker could inject malicious JavaScript and execute any action JavaScript could do. Examples include:
This could lead to a potential Cross Site Scripting (XSS) vulnerability. Using an XSS vulnerability, an attacker could inject malicious JavaScript and execute any action JavaScript could do. Examples include:

- Stealing authentication material (e.g. cookies, JWT tokens)
- Exfiltrate sensitive information by reading the DOM
Expand Down
4 changes: 2 additions & 2 deletions docs/running_psalm/plugins/authoring_plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ class SomePlugin implements \Psalm\Plugin\EventHandler\AfterStatementAnalysisInt
- `AfterFunctionCallAnalysisInterface` - called after Psalm evaluates a function call to any function defined within the project itself. Can alter the return type or perform modifications of the call.
- `AfterFunctionLikeAnalysisInterface` - called after Psalm has completed its analysis of a given function-like.
- `AfterMethodCallAnalysisInterface` - called after Psalm analyzes a method call.
- `BeforeStatementAnalysisInterface` - called before Psalm evaluates an statement.
- `AfterStatementAnalysisInterface` - called after Psalm evaluates an statement.
- `BeforeStatementAnalysisInterface` - called before Psalm evaluates a statement.
- `AfterStatementAnalysisInterface` - called after Psalm evaluates a statement.
- `BeforeAddIssueInterface` - called before Psalm adds an item to it's internal `IssueBuffer`, allows handling code issues individually
- `BeforeFileAnalysisInterface` - called before Psalm analyzes a file.
- `FunctionExistenceProviderInterface` - can be used to override Psalm's builtin function existence checks for one or more functions.
Expand Down
2 changes: 1 addition & 1 deletion phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@
</rule>

<!--
Requires using a underscore separator for long numbers.
Requires using an underscore separator for long numbers.
https://github.com/slevomat/coding-standard/#slevomatcodingstandardnumbersrequirenumericliteralseparator
-->
<rule ref="SlevomatCodingStandard.Numbers.RequireNumericLiteralSeparator">
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ final class Context
public $inside_unset = false;

/**
* Whether or not we're inside an class_exists call, where
* Whether or not we're inside a class_exists call, where
* we don't care about possibly undefined classes
*
* @var bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ private static function analyzeNamedConstructor(
if ($storage->abstract && !$can_extend) {
if (IssueBuffer::accepts(
new AbstractInstantiation(
'Unable to instantiate a abstract class ' . $fq_class_name,
'Unable to instantiate an abstract class ' . $fq_class_name,
new CodeLocation($statements_analyzer->getSource(), $stmt),
),
$statements_analyzer->getSuppressedIssues(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1151,7 +1151,7 @@ private static function handleArrayAccessOnArray(
$single_atomic = $key_values[0];
$from_mixed_array = $type->type_params[1]->isMixed();

// ok, type becomes an TKeyedArray
// ok, type becomes a TKeyedArray
$type = new TKeyedArray(
[
$single_atomic->value => $from_mixed_array ? Type::getMixed() : Type::getNever(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,7 @@ public static function getOptionsArgValueOrError(
// silently ignored by the function, but this usually indicates a bug
IssueBuffer::maybeAdd(
new InvalidArgument(
'The "options" key in ' . $function_id
. ' must be a an array',
'The "options" key in ' . $function_id . ' must be an array',
$code_location,
$function_id,
),
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Type/Atomic.php
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ private static function createInner(

/**
* This is the string that will be used to represent the type in Union::$types. This means that two types sharing
* the same getKey value will override themselves in an Union
* the same getKey value will override themselves in a Union
*/
abstract public function getKey(bool $include_extra = true): string;

Expand Down
4 changes: 2 additions & 2 deletions src/Psalm/Type/UnionTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
trait UnionTrait
{
/**
* Constructs an Union instance
* Constructs a Union instance
*
* @psalm-external-mutation-free
* @param non-empty-array<Atomic> $types
Expand Down Expand Up @@ -1247,7 +1247,7 @@ public function hasLiteralInt(): bool

/**
* @psalm-mutation-free
* @return bool true if this is a int literal with only one possible value
* @return bool true if this is an int literal with only one possible value
*/
public function isSingleIntLiteral(): bool
{
Expand Down
2 changes: 1 addition & 1 deletion stubs/CoreGenericClasses.phpstub
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class Generator implements Traversable {
interface ArrayAccess {

/**
* Whether a offset exists
* Whether an offset exists
* @link http://php.net/manual/en/arrayaccess.offsetexists.php
*
* @param TKey $offset An offset to check for.
Expand Down
Loading