Skip to content

Commit

Permalink
Merge branch '5.x' into upstream-master
Browse files Browse the repository at this point in the history
  • Loading branch information
weirdan committed Sep 11, 2023
2 parents 37cc4fd + 13ea0c2 commit 7428e49
Show file tree
Hide file tree
Showing 15 changed files with 57 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bcc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
env:
fail-fast: true

- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-phar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
env:
fail-fast: true

- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0 # required for composer to automatically detect root package version

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
env:
fail-fast: true

- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Get Composer Cache Directories
id: composer-cache
Expand Down Expand Up @@ -63,7 +63,7 @@ jobs:
env:
fail-fast: true

- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Get Composer Cache Directories
id: composer-cache
Expand Down Expand Up @@ -148,7 +148,7 @@ jobs:
env:
fail-fast: true

- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Get Composer Cache Directories
id: composer-cache
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/shepherd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
php -v
php -r 'var_dump(PHP_VERSION_ID);'
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Get Composer Cache Directories
id: composer-cache
Expand Down
8 changes: 4 additions & 4 deletions dictionaries/CallMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -1307,8 +1307,8 @@
'date_create_immutable' => ['DateTimeImmutable|false', 'datetime='=>'string', 'timezone='=>'?DateTimeZone'],
'date_create_immutable_from_format' => ['DateTimeImmutable|false', 'format'=>'string', 'datetime'=>'string', 'timezone='=>'?DateTimeZone'],
'date_date_set' => ['DateTime', 'object'=>'DateTime', 'year'=>'int', 'month'=>'int', 'day'=>'int'],
'date_default_timezone_get' => ['string'],
'date_default_timezone_set' => ['bool', 'timezoneId'=>'string'],
'date_default_timezone_get' => ['non-empty-string'],
'date_default_timezone_set' => ['bool', 'timezoneId'=>'non-empty-string'],
'date_diff' => ['DateInterval', 'baseObject'=>'DateTimeInterface', 'targetObject'=>'DateTimeInterface', 'absolute='=>'bool'],
'date_format' => ['string', 'object'=>'DateTimeInterface', 'format'=>'string'],
'date_get_last_errors' => ['array{warning_count:int,warnings:array<int,string>,error_count:int,errors:array<int,string>}|false'],
Expand Down Expand Up @@ -1390,11 +1390,11 @@
'DateTimeInterface::getTimezone' => ['DateTimeZone|false'],
'DateTimeInterface::__serialize' => ['array'],
'DateTimeInterface::__unserialize' => ['void', 'data'=>'array'],
'DateTimeZone::__construct' => ['void', 'timezone'=>'string'],
'DateTimeZone::__construct' => ['void', 'timezone'=>'non-empty-string'],
'DateTimeZone::__set_state' => ['DateTimeZone', 'array'=>'array'],
'DateTimeZone::__wakeup' => ['void'],
'DateTimeZone::getLocation' => ['array|false'],
'DateTimeZone::getName' => ['string'],
'DateTimeZone::getName' => ['non-empty-string'],
'DateTimeZone::getOffset' => ['int', 'datetime'=>'DateTimeInterface'],
'DateTimeZone::getTransitions' => ['list<array{ts: int, time: string, offset: int, isdst: bool, abbr: string}>|false', 'timestampBegin='=>'int', 'timestampEnd='=>'int'],
'DateTimeZone::listAbbreviations' => ['array<string, list<array{dst: bool, offset: int, timezone_id: string|null}>>'],
Expand Down
8 changes: 4 additions & 4 deletions dictionaries/CallMap_historical.php
Original file line number Diff line number Diff line change
Expand Up @@ -847,11 +847,11 @@
'DateTimeInterface::getOffset' => ['int'],
'DateTimeInterface::getTimestamp' => ['int|false'],
'DateTimeInterface::getTimezone' => ['DateTimeZone|false'],
'DateTimeZone::__construct' => ['void', 'timezone'=>'string'],
'DateTimeZone::__construct' => ['void', 'timezone'=>'non-empty-string'],
'DateTimeZone::__set_state' => ['DateTimeZone', 'array'=>'array'],
'DateTimeZone::__wakeup' => ['void'],
'DateTimeZone::getLocation' => ['array|false'],
'DateTimeZone::getName' => ['string'],
'DateTimeZone::getName' => ['non-empty-string'],
'DateTimeZone::getOffset' => ['int|false', 'datetime'=>'DateTimeInterface'],
'DateTimeZone::getTransitions' => ['list<array{ts: int, time: string, offset: int, isdst: bool, abbr: string}>|false', 'timestampBegin='=>'int', 'timestampEnd='=>'int'],
'DateTimeZone::listAbbreviations' => ['array<string, list<array{dst: bool, offset: int, timezone_id: string|null}>>'],
Expand Down Expand Up @@ -9820,8 +9820,8 @@
'date_create_immutable' => ['DateTimeImmutable|false', 'datetime='=>'string', 'timezone='=>'?DateTimeZone'],
'date_create_immutable_from_format' => ['DateTimeImmutable|false', 'format'=>'string', 'datetime'=>'string', 'timezone='=>'?DateTimeZone'],
'date_date_set' => ['DateTime|false', 'object'=>'DateTime', 'year'=>'int', 'month'=>'int', 'day'=>'int'],
'date_default_timezone_get' => ['string'],
'date_default_timezone_set' => ['bool', 'timezoneId'=>'string'],
'date_default_timezone_get' => ['non-empty-string'],
'date_default_timezone_set' => ['bool', 'timezoneId'=>'non-empty-string'],
'date_diff' => ['DateInterval|false', 'baseObject'=>'DateTimeInterface', 'targetObject'=>'DateTimeInterface', 'absolute='=>'bool'],
'date_format' => ['string|false', 'object'=>'DateTimeInterface', 'format'=>'string'],
'date_get_last_errors' => ['array{warning_count:int,warnings:array<int,string>,error_count:int,errors:array<int,string>}|false'],
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Config/FileFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ public static function loadFromArray(
foreach ($config['referencedFunction'] as $referenced_function) {
$function_id = $referenced_function['name'] ?? '';
if (!is_string($function_id)
|| (!preg_match('/^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*$/', $function_id)
|| (!preg_match('/^[a-zA-Z_\x80-\xff](?:[\\\\]?[a-zA-Z0-9_\x80-\xff]+)*$/', $function_id)
&& !preg_match('/^[^:]+::[^:]+$/', $function_id) // methods are also allowed
&& !static::isRegularExpression($function_id))) {
throw new ConfigException(
Expand Down
2 changes: 1 addition & 1 deletion stubs/CoreGenericClasses.phpstub
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ interface ArrayAccess {
* This class allows objects to work as arrays.
* @link http://php.net/manual/en/class.arrayobject.php
*
* @template TKey
* @template TKey of array-key
* @template TValue
* @template-implements IteratorAggregate<TKey, TValue>
* @template-implements ArrayAccess<TKey, TValue>
Expand Down
1 change: 1 addition & 0 deletions stubs/CoreImmutableClasses.phpstub
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class DateTimeImmutable implements DateTimeInterface
*/
class DateTimeZone
{
/** @param non-empty-string $timezone */
public function __construct(string $timezone) {}
}

Expand Down
1 change: 0 additions & 1 deletion tests/ArrayAssignmentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1297,7 +1297,6 @@ function foo(ArrayObject $a) : array {
/**
* @psalm-suppress MixedAssignment
* @psalm-suppress MixedArrayOffset
*/
foreach ($a as $k => $v) {
$arr[$k] = $v;
Expand Down
6 changes: 3 additions & 3 deletions tests/ClassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ function intersect(A $a) {
'code' => '<?php
/**
* @template TTKey
* @template TTKey of array-key
* @template TTValue
*
* @extends ArrayObject<TTKey, TTValue>
Expand Down Expand Up @@ -675,7 +675,7 @@ class b extends a {
'preventDoubleStaticResolution2' => [
'code' => '<?php
/**
* @template TTKey
* @template TTKey of array-key
* @template TTValue
*
* @extends ArrayObject<TTKey, TTValue>
Expand Down Expand Up @@ -712,7 +712,7 @@ public function ret(): iter {
'preventDoubleStaticResolution3' => [
'code' => '<?php
/**
* @template TTKey
* @template TTKey of array-key
* @template TTValue
*
* @extends ArrayObject<TTKey, TTValue>
Expand Down
31 changes: 31 additions & 0 deletions tests/Config/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Psalm\Internal\RuntimeCaches;
use Psalm\Internal\Scanner\FileScanner;
use Psalm\Issue\TooManyArguments;
use Psalm\Issue\UndefinedFunction;
use Psalm\Tests\Config\Plugin\FileTypeSelfRegisteringPlugin;
use Psalm\Tests\Internal\Provider\FakeParserCacheProvider;
use Psalm\Tests\TestCase;
Expand Down Expand Up @@ -1856,4 +1857,34 @@ public function testReferencedFunctionAllowsMethods(): void
),
);
}

public function testReferencedFunctionAllowsNamespacedFunctions(): void
{
$config_xml = Config::loadFromXML(
(string) getcwd(),
<<<XML
<?xml version="1.0"?>
<psalm>
<issueHandlers>
<UndefinedFunction>
<errorLevel type="suppress">
<referencedFunction name="Foo\Bar\baz" />
</errorLevel>
</UndefinedFunction>
</issueHandlers>
</psalm>
XML,
);

$this->assertSame(
Config::REPORT_SUPPRESS,
$config_xml->getReportingLevelForIssue(
new UndefinedFunction(
'Function Foo\Bar\baz does not exist',
new Raw('aaa', 'aaa.php', 'aaa.php', 1, 2),
'foo\bar\baz',
),
),
);
}
}
5 changes: 4 additions & 1 deletion tests/PureAnnotationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,10 @@ function foo(array $arr) : array {
'code' => '<?php
final class Date
{
/** @psalm-pure */
/**
* @param non-empty-string $tzString
* @psalm-pure
*/
public static function timeZone(string $tzString) : DateTimeZone
{
return new \DateTimeZone($tzString);
Expand Down
2 changes: 1 addition & 1 deletion tests/Template/ClassTemplateExtendsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1390,7 +1390,7 @@ class A {}',
'extendArrayObjectWithTemplateParams' => [
'code' => '<?php
/**
* @template TKey
* @template TKey of array-key
* @template TValue
* @template-extends \ArrayObject<TKey,TValue>
*/
Expand Down

0 comments on commit 7428e49

Please sign in to comment.