Skip to content

Commit

Permalink
Merge pull request #7060 from rarila/codingstyle-convert-fqn
Browse files Browse the repository at this point in the history
  • Loading branch information
weirdan committed Dec 5, 2021
2 parents b359847 + 9902898 commit e9d9481
Show file tree
Hide file tree
Showing 546 changed files with 5,087 additions and 3,177 deletions.
7 changes: 5 additions & 2 deletions bin/generate_levels_doc.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
<?php

use Psalm\Config\IssueHandler;
use Psalm\Issue\CodeIssue;

require_once(dirname(__DIR__) . '/vendor/autoload.php');

$issue_types = \Psalm\Config\IssueHandler::getAllIssueTypes();
$issue_types = IssueHandler::getAllIssueTypes();

$grouped_issues = [];

foreach ($issue_types as $issue_type) {
$issue_class = 'Psalm\\Issue\\' . $issue_type;

if (!class_exists($issue_class) || !is_a($issue_class, \Psalm\Issue\CodeIssue::class, true)) {
if (!class_exists($issue_class) || !is_a($issue_class, CodeIssue::class, true)) {
throw new Exception($issue_class . ' is not a Codeissue');
}

Expand Down
4 changes: 3 additions & 1 deletion bin/max_used_shortcode.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/usr/bin/env php
<?php

use Psalm\Config\IssueHandler;

require_once(dirname(__DIR__) . '/vendor/autoload.php');

$issue_types = \Psalm\Config\IssueHandler::getAllIssueTypes();
$issue_types = IssueHandler::getAllIssueTypes();

$shortcodes = array_map(
function ($issue_type): int {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?php
namespace Psalm\Example\Plugin\ComposerBased;

use Psalm\Plugin;
use Psalm\Plugin\PluginEntryPointInterface;
use Psalm\Plugin\RegistrationInterface;
use SimpleXMLElement;

class PluginEntryPoint implements Plugin\PluginEntryPointInterface
class PluginEntryPoint implements PluginEntryPointInterface
{
public function __invoke(Plugin\RegistrationInterface $registration, ?SimpleXMLElement $config = null): void
public function __invoke(RegistrationInterface $registration, ?SimpleXMLElement $config = null): void
{
require_once __DIR__ . '/EchoChecker.php';
$registration->registerHooksFromClass(EchoChecker::class);
Expand Down
22 changes: 15 additions & 7 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,22 @@
-->
<rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly">
<properties>
<property name="allowFallbackGlobalConstants" value="false"/>
<property name="allowFallbackGlobalFunctions" value="false"/>
<property name="allowFullyQualifiedGlobalConstants" value="true"/>
<property name="allowFullyQualifiedGlobalFunctions" value="true"/>
<property name="allowFullyQualifiedGlobalClasses" value="true"/>
</properties>
<property name="allowFullyQualifiedExceptions" type="bool" value="false"/>
<property name="allowFullyQualifiedGlobalFunctions" type="bool" value="false"/>
<property name="allowFullyQualifiedGlobalConstants" type="bool" value="false"/>
<property name="allowFullyQualifiedGlobalClasses" type="bool" value="false"/>

<property name="allowFullyQualifiedNameForCollidingClasses" type="bool" value="false"/>
<property name="allowFullyQualifiedNameForCollidingFunctions" type="bool" value="false"/>
<property name="allowFullyQualifiedNameForCollidingConstants" type="bool" value="false"/>

<property name="allowFallbackGlobalFunctions" type="bool" value="false"/>
<property name="allowFallbackGlobalConstants" type="bool" value="false"/>

<exclude name="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.ReferenceViaFullyQualifiedName"/>
<property name="allowPartialUses" type="bool" value="true"/>

<property name="searchAnnotations" type="bool" value="true"/>
</properties>
</rule>

<!--
Expand Down
4 changes: 2 additions & 2 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="dev-master@6941ebfc5318e3782e59bfb85876e5edc1f7cca6">
<files psalm-version="dev-master@ac230dac5c64b1b4c7f4bd2d067fb7ae6176b6e8">
<file src="examples/TemplateChecker.php">
<PossiblyUndefinedIntArrayOffset occurrences="2">
<code>$comment_block-&gt;tags['variablesfrom'][0]</code>
Expand Down Expand Up @@ -255,7 +255,7 @@
</file>
<file src="src/Psalm/Internal/Analyzer/Statements/ThrowAnalyzer.php">
<DeprecatedMethod occurrences="1">
<code>\Psalm\Type::getEmpty()</code>
<code>Type::getEmpty()</code>
</DeprecatedMethod>
</file>
<file src="src/Psalm/Internal/Analyzer/Statements/UnsetAnalyzer.php">
Expand Down
9 changes: 6 additions & 3 deletions src/Psalm/CodeLocation.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<?php
namespace Psalm;

use Exception;
use LogicException;
use PhpParser;
use Psalm\Internal\Analyzer\CommentAnalyzer;
use UnexpectedValueException;

use function explode;
use function max;
Expand Down Expand Up @@ -197,7 +200,7 @@ private function calculateRealLocation(): void
}

if (!isset($preview_lines[$i])) {
throw new \Exception('Should have offset');
throw new Exception('Should have offset');
}

$key_line = $preview_lines[$i];
Expand Down Expand Up @@ -245,7 +248,7 @@ private function calculateRealLocation(): void
break;

default:
throw new \UnexpectedValueException('Unrecognised regex type ' . $this->regex_type);
throw new UnexpectedValueException('Unrecognised regex type ' . $this->regex_type);
}

$preview_snippet = mb_strcut(
Expand All @@ -260,7 +263,7 @@ private function calculateRealLocation(): void

if (preg_match($regex, $preview_snippet, $matches, PREG_OFFSET_CAPTURE)) {
if (!isset($matches[1]) || $matches[1][1] === -1) {
throw new \LogicException(
throw new LogicException(
"Failed to match anything to 1st capturing group, "
. "or regex doesn't contain 1st capturing group, regex type " . $this->regex_type
);
Expand Down
7 changes: 5 additions & 2 deletions src/Psalm/CodeLocation/DocblockTypeLocation.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<?php
namespace Psalm\CodeLocation;

class DocblockTypeLocation extends \Psalm\CodeLocation
use Psalm\CodeLocation;
use Psalm\FileSource;

class DocblockTypeLocation extends CodeLocation
{
public function __construct(
\Psalm\FileSource $file_source,
FileSource $file_source,
int $file_start,
int $file_end,
int $line_number
Expand Down
3 changes: 2 additions & 1 deletion src/Psalm/CodeLocation/ParseErrorLocation.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
namespace Psalm\CodeLocation;

use PhpParser;
use Psalm\CodeLocation;

use function substr;
use function substr_count;

class ParseErrorLocation extends \Psalm\CodeLocation
class ParseErrorLocation extends CodeLocation
{
public function __construct(
PhpParser\Error $error,
Expand Down
4 changes: 3 additions & 1 deletion src/Psalm/CodeLocation/Raw.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?php
namespace Psalm\CodeLocation;

use Psalm\CodeLocation;

use function substr;
use function substr_count;

class Raw extends \Psalm\CodeLocation
class Raw extends CodeLocation
{
public function __construct(
string $file_contents,
Expand Down

0 comments on commit e9d9481

Please sign in to comment.