晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。 林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。 见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝) 既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。 南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。
|
Server : Apache System : Linux srv.rainic.com 4.18.0-553.47.1.el8_10.x86_64 #1 SMP Wed Apr 2 05:45:37 EDT 2025 x86_64 User : rainic ( 1014) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /opt/cpanel/ea-wappspector/vendor/slevomat/coding-standard/doc/ |
Upload File : |
## Namespaces
#### SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses 🔧
Sniff checks whether `use` declarations at the top of a file are alphabetically sorted. Follows natural sorting and takes edge cases with special symbols into consideration. The following code snippet is an example of correctly sorted uses:
```php
use LogableTrait;
use LogAware;
use LogFactory;
use LoggerInterface;
use LogLevel;
use LogStandard;
```
Sniff provides the following settings:
* `psr12Compatible` (default: `true`): sets the required order to `classes`, `functions` and `constants`. `false` sets the required order to `classes`, `constants` and `functions`.
* `caseSensitive`: compare namespaces case sensitively, which makes this order correct:
```php
use LogAware;
use LogFactory;
use LogLevel;
use LogStandard;
use LogableTrait;
use LoggerInterface;
```
#### SlevomatCodingStandard.Namespaces.DisallowGroupUse
[Group use declarations](https://wiki.php.net/rfc/group_use_declarations) are ugly, make diffs ugly and this sniff prohibits them.
#### SlevomatCodingStandard.Namespaces.FullyQualifiedExceptions 🔧
This sniff reduces confusion in the following code snippet:
```php
try {
$this->foo();
} catch (Exception $e) {
// Is this the general exception all exceptions must extend from? Or Exception from the current namespace?
}
```
All references to types named `Exception` or ending with `Exception` must be referenced via a fully qualified name:
```php
try {
$this->foo();
} catch (\FooCurrentNamespace\Exception $e) {
} catch (\Exception $e) {
}
```
Sniff provides the following settings:
* Exceptions with different names can be configured in `specialExceptionNames` property.
* If your codebase uses classes that look like exceptions (because they have `Exception` or `Error` suffixes) but aren't, you can add them to `ignoredNames` property and the sniff won't enforce them to be fully qualified. Classes with `Error` suffix have to be added to ignored only if they are in the root namespace (like `LibXMLError`).
#### SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalConstants 🔧
All references to global constants must be referenced via a fully qualified name.
Sniff provides the following settings:
* `include`: list of global constants that must be referenced via FQN. If not set all constants are considered.
* `exclude`: list of global constants that are allowed not to be referenced via FQN.
#### SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalFunctions 🔧
All references to global functions must be referenced via a fully qualified name.
Sniff provides the following settings:
* `include`: list of global functions that must be referenced via FQN. If not set all functions are considered.
* `includeSpecialFunctions`: include complete list of PHP internal functions that could be optimized when referenced via FQN.
* `exclude`: list of global functions that are allowed not to be referenced via FQN.
#### SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameInAnnotation 🔧
Enforces fully qualified names of classes and interfaces in phpDocs - in annotations. This results in unambiguous phpDocs.
Sniff provides the following settings:
* `ignoredAnnotationNames`: case-sensitive list of annotation names that the sniff should ignore. Useful for custom annotation names like `@apiParam`
#### SlevomatCodingStandard.Namespaces.MultipleUsesPerLine
Prohibits multiple uses separated by commas:
```php
use Foo, Bar;
```
#### SlevomatCodingStandard.Namespaces.NamespaceDeclaration 🔧
Enforces one space after `namespace`, disallows content between namespace name and semicolon and disallows use of bracketed syntax.
#### SlevomatCodingStandard.Namespaces.NamespaceSpacing 🔧
Enforces configurable number of lines before and after `namespace`.
Sniff provides the following settings:
* `linesCountBeforeNamespace`: allows to configure the number of lines before `namespace`.
* `linesCountAfterNamespace`: allows to configure the number of lines after `namespace`.
#### SlevomatCodingStandard.Namespaces.RequireOneNamespaceInFile
Requires only one namespace in a file.
#### SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly 🔧
Sniff provides the following settings:
* `searchAnnotations` (default: `false`): enables searching for mentions in annotations.
* `namespacesRequiredToUse`: if not set, all namespaces are required to be used. When set, only mentioned namespaces are required to be used. Useful in tandem with UseOnlyWhitelistedNamespaces sniff.
* `allowFullyQualifiedExceptions`, `specialExceptionNames` & `ignoredNames`: allows fully qualified exceptions. Useful in tandem with FullyQualifiedExceptions sniff.
* `allowFullyQualifiedNameForCollidingClasses`: allow fully qualified name for a class with a colliding use statement.
* `allowFullyQualifiedNameForCollidingFunctions`: allow fully qualified name for a function with a colliding use statement.
* `allowFullyQualifiedNameForCollidingConstants`: allow fully qualified name for a constant with a colliding use statement.
* `allowFullyQualifiedGlobalClasses`: allows using fully qualified classes from global space (i.e. `\DateTimeImmutable`).
* `allowFullyQualifiedGlobalFunctions`: allows using fully qualified functions from global space (i.e. `\phpversion()`).
* `allowFullyQualifiedGlobalConstants`: allows using fully qualified constants from global space (i.e. `\PHP_VERSION`).
* `allowFallbackGlobalFunctions`: allows using global functions via fallback name without `use` (i.e. `phpversion()`).
* `allowFallbackGlobalConstants`: allows using global constants via fallback name without `use` (i.e. `PHP_VERSION`).
* `allowPartialUses`: allows using and referencing whole namespaces.
* `allowWhenNoNamespace` (default: `true`): force even when there's no namespace in the file.
#### SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash 🔧
Disallows leading backslash in use statement:
```php
use \Foo\Bar;
```
#### SlevomatCodingStandard.Namespaces.UseFromSameNamespace 🔧
Sniff prohibits uses from the same namespace:
```php
namespace Foo;
use Foo\Bar;
```
#### SlevomatCodingStandard.Namespaces.UseSpacing 🔧
Enforces configurable number of lines before first `use`, after last `use` and between two different types of `use` (eg. between `use function` and `use const`). Also enforces zero number of lines between same types of `use`.
Sniff provides the following settings:
* `linesCountBeforeFirstUse`: allows to configure the number of lines before first `use`.
* `linesCountBetweenUseTypes`: allows to configure the number of lines between two different types of `use`.
* `linesCountAfterLastUse`: allows to configure the number of lines after last `use`.
#### SlevomatCodingStandard.Namespaces.UseOnlyWhitelistedNamespaces
Sniff disallows uses of other than configured namespaces.
Sniff provides the following settings:
* `namespacesRequiredToUse`: namespaces in this array are the only ones allowed to be used. E.g. root project namespace.
* `allowUseFromRootNamespace`: also allow using top-level namespace:
```php
use DateTimeImmutable;
```
#### SlevomatCodingStandard.Namespaces.UselessAlias 🔧
Looks for `use` alias that is same as unqualified name.
#### SlevomatCodingStandard.Namespaces.UnusedUses 🔧
Looks for unused imports from other namespaces.
Sniff provides the following settings:
* `searchAnnotations` (default: `false`): enables searching for class names in annotations.
* `ignoredAnnotationNames`: case-sensitive list of annotation names that the sniff should ignore (only the name is ignored, annotation content is still searched). Useful for name collisions like `@testCase` annotation and `TestCase` class.
* `ignoredAnnotations`: case-sensitive list of annotation names that the sniff ignore completely (both name and content are ignored). Useful for name collisions like `@group Cache` annotation and `Cache` class.