-
Notifications
You must be signed in to change notification settings - Fork 5
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
Test issue #6
Comments
I found these snippets: https://psalm.dev/r/fa74710ae3<?php
/**
* @psalm-type Person = array{name: string, age: int}
*/
/**
* @psalm-return Person
*/
function getPerson_error(): array {
$json = '{"name": "John", "age": 44}';
/** @psalm-var Person */
return json_decode($json, true);
}
/**
* @psalm-return Person
*/
function getPerson_ok1(): array {
$json = '{"name": "John", "age": 44}';
/** @psalm-var array{name: string, age: int} */
return json_decode($json, true);
}
/**
* @psalm-return Person
*/
function getPerson_ok2(): array {
$json = '{"name": "John", "age": 44}';
/** @psalm-var Person */
$person = json_decode($json, true);
return $person;
}
|
Still there? https://psalm.dev/r/fa74710ae3 |
I found these snippets: https://psalm.dev/r/fa74710ae3<?php
/**
* @psalm-type Person = array{name: string, age: int}
*/
/**
* @psalm-return Person
*/
function getPerson_error(): array {
$json = '{"name": "John", "age": 44}';
/** @psalm-var Person */
return json_decode($json, true);
}
/**
* @psalm-return Person
*/
function getPerson_ok1(): array {
$json = '{"name": "John", "age": 44}';
/** @psalm-var array{name: string, age: int} */
return json_decode($json, true);
}
/**
* @psalm-return Person
*/
function getPerson_ok2(): array {
$json = '{"name": "John", "age": 44}';
/** @psalm-var Person */
$person = json_decode($json, true);
return $person;
}
|
Hey @psalm-github-bot, can you please fetch this for me: https://psalm.dev/r/fa74710ae3 |
I found these snippets: https://psalm.dev/r/fa74710ae3<?php
/**
* @psalm-type Person = array{name: string, age: int}
*/
/**
* @psalm-return Person
*/
function getPerson_error(): array {
$json = '{"name": "John", "age": 44}';
/** @psalm-var Person */
return json_decode($json, true);
}
/**
* @psalm-return Person
*/
function getPerson_ok1(): array {
$json = '{"name": "John", "age": 44}';
/** @psalm-var array{name: string, age: int} */
return json_decode($json, true);
}
/**
* @psalm-return Person
*/
function getPerson_ok2(): array {
$json = '{"name": "John", "age": 44}';
/** @psalm-var Person */
$person = json_decode($json, true);
return $person;
}
|
Still there? https://psalm.dev/r/fa74710ae3 |
I found these snippets: https://psalm.dev/r/fa74710ae3<?php
/**
* @psalm-type Person = array{name: string, age: int}
*/
/**
* @psalm-return Person
*/
function getPerson_error(): array {
$json = '{"name": "John", "age": 44}';
/** @psalm-var Person */
return json_decode($json, true);
}
/**
* @psalm-return Person
*/
function getPerson_ok1(): array {
$json = '{"name": "John", "age": 44}';
/** @psalm-var array{name: string, age: int} */
return json_decode($json, true);
}
/**
* @psalm-return Person
*/
function getPerson_ok2(): array {
$json = '{"name": "John", "age": 44}';
/** @psalm-var Person */
$person = json_decode($json, true);
return $person;
}
|
Resolve this: https://psalm.dev/r/6f8098b9ef |
I found these snippets: https://psalm.dev/r/6f8098b9ef<?php
class MyStreamFilter extends \php_user_filter
{
/** @var string */
private $append;
/**
* @see https://php.net/manual/en/php-user-filter.oncreate.php
*
* @return bool
*/
public function onCreate()
{
if (!isset($this->params['append'])) {
return false;
}
$this->append = (string) $this->params['append'];
return true;
}
/**
* @param resource $in
* @param resource $out
* @param int $consumed
* @param bool $closing
*
* @return int
*/
public function filter($in, $out, &$consumed, $closing)
{
while ($bucket = stream_bucket_make_writeable($in)) {
$bucket->data .= $this->append;
$consumed += $bucket->datalen;
stream_bucket_append($out, $bucket);
}
return \PSFS_PASS_ON;
}
}
https://psalm.dev/r/fa74710ae3<?php
/**
* @psalm-type Person = array{name: string, age: int}
*/
/**
* @psalm-return Person
*/
function getPerson_error(): array {
$json = '{"name": "John", "age": 44}';
/** @psalm-var Person */
return json_decode($json, true);
}
/**
* @psalm-return Person
*/
function getPerson_ok1(): array {
$json = '{"name": "John", "age": 44}';
/** @psalm-var array{name: string, age: int} */
return json_decode($json, true);
}
/**
* @psalm-return Person
*/
function getPerson_ok2(): array {
$json = '{"name": "John", "age": 44}';
/** @psalm-var Person */
$person = json_decode($json, true);
return $person;
}
|
I found these snippets: https://psalm.dev/r/fa74710ae3<?php
/**
* @psalm-type Person = array{name: string, age: int}
*/
/**
* @psalm-return Person
*/
function getPerson_error(): array {
$json = '{"name": "John", "age": 44}';
/** @psalm-var Person */
return json_decode($json, true);
}
/**
* @psalm-return Person
*/
function getPerson_ok1(): array {
$json = '{"name": "John", "age": 44}';
/** @psalm-var array{name: string, age: int} */
return json_decode($json, true);
}
/**
* @psalm-return Person
*/
function getPerson_ok2(): array {
$json = '{"name": "John", "age": 44}';
/** @psalm-var Person */
$person = json_decode($json, true);
return $person;
}
|
Without true && it works as expected. https://psalm.dev/r/9163d1b90e |
I found these snippets: https://psalm.dev/r/9163d1b90e<?php
$pointers = ['hi'];
while (true && 0 < ($parent = 0)) {
print $pointers[$parent];
}
https://psalm.dev/r/7005ba3a7a<?php
namespace Amp\Loop\Internal;
final class TimerQueue
{
/** @var int[] */
private $pointers = [];
public function foobar(): void
{
$node = 0;
while ($node !== 0 && 0 < $this->pointers[$parent = ($node - 1) >> 1]) {
print $this->pointers[$parent];
}
}
}
|
Without true && it works as expected. https://psalm.dev/r/9163d1b90e |
I found these snippets: https://psalm.dev/r/9163d1b90e<?php
$pointers = ['hi'];
while (true && 0 < ($parent = 0)) {
print $pointers[$parent];
}
https://psalm.dev/r/7005ba3a7a<?php
namespace Amp\Loop\Internal;
final class TimerQueue
{
/** @var int[] */
private $pointers = [];
public function foobar(): void
{
$node = 0;
while ($node !== 0 && 0 < $this->pointers[$parent = ($node - 1) >> 1]) {
print $this->pointers[$parent];
}
}
}
|
Without true && it works as expected. https://psalm.dev/r/9163d1b90e |
1 similar comment
Without true && it works as expected. https://psalm.dev/r/9163d1b90e |
I found these snippets: https://psalm.dev/r/9163d1b90e<?php
$pointers = ['hi'];
while (true && 0 < ($parent = 0)) {
print $pointers[$parent];
}
https://psalm.dev/r/7005ba3a7a<?php
namespace Amp\Loop\Internal;
final class TimerQueue
{
/** @var int[] */
private $pointers = [];
public function foobar(): void
{
$node = 0;
while ($node !== 0 && 0 < $this->pointers[$parent = ($node - 1) >> 1]) {
print $this->pointers[$parent];
}
}
}
|
Without true && it works as expected. https://psalm.dev/r/9163d1b90e |
I found these snippets: https://psalm.dev/r/9163d1b90e<?php
$pointers = ['hi'];
while (true && 0 < ($parent = 0)) {
print $pointers[$parent];
}
https://psalm.dev/r/7005ba3a7a<?php
namespace Amp\Loop\Internal;
final class TimerQueue
{
/** @var int[] */
private $pointers = [];
public function foobar(): void
{
$node = 0;
while ($node !== 0 && 0 < $this->pointers[$parent = ($node - 1) >> 1]) {
print $this->pointers[$parent];
}
}
}
|
Footnotes
is rendered as
|
and quoted (
which is rendered as
|
psalm.dev/r/fa74710ae3 |
I found these snippets: https://psalm.dev/r/fa74710ae3<?php
/**
* @psalm-type Person = array{name: string, age: int}
*/
/**
* @psalm-return Person
*/
function getPerson_error(): array {
$json = '{"name": "John", "age": 44}';
/** @psalm-var Person */
return json_decode($json, true);
}
/**
* @psalm-return Person
*/
function getPerson_ok1(): array {
$json = '{"name": "John", "age": 44}';
/** @psalm-var array{name: string, age: int} */
return json_decode($json, true);
}
/**
* @psalm-return Person
*/
function getPerson_ok2(): array {
$json = '{"name": "John", "age": 44}';
/** @psalm-var Person */
$person = json_decode($json, true);
return $person;
}
|
I found these snippets: https://psalm.dev/r/fb2fdbf173<?php
enum Method: string {
case HEAD = 'HEAD';
case GET = 'GET';
case POST = 'POST';
case PUT = 'PUT';
case PATCH = 'PATCH';
case DELETE = 'DELETE';
case PURGE = 'PURGE';
case OPTIONS = 'OPTIONS';
case TRACE = 'TRACE';
}
/**
* @psalm-consistent-constructor
*/
class Request {
private Method $method;
/**
* Request constructor.
* @param array $server
* @param array $query
* @param array $formData
* @param array $cookie
* @param array $files
*/
public function __construct(
array $server,
array $query,
array $formData,
array $cookie,
array $files
) {
$this->method = Method::from((string) $server['REQUEST_METHOD']);
}
/**
* @return Request
*/
public static function createFromGlobals(): self {
return new static($_SERVER, $_GET, $_POST, $_COOKIE, $_FILES);
}
}
|
I found these snippets: https://psalm.dev/r/48609634a5<?php
/**
* @return array<string>
*/
function takesAnInt(int $i) {
return [$i, "hello"];
}
$data = ["some text", 5];
takesAnInt($data[0]);
$condition = rand(0, 5);
if ($condition) {
} elseif ($condition) {} sdf
|
psalm.dev/r/48609634a5 |
I found these snippets: https://psalm.dev/r/fa74710ae3<?php
/**
* @psalm-type Person = array{name: string, age: int}
*/
/**
* @psalm-return Person
*/
function getPerson_error(): array {
$json = '{"name": "John", "age": 44}';
/** @psalm-var Person */
return json_decode($json, true);
}
/**
* @psalm-return Person
*/
function getPerson_ok1(): array {
$json = '{"name": "John", "age": 44}';
/** @psalm-var array{name: string, age: int} */
return json_decode($json, true);
}
/**
* @psalm-return Person
*/
function getPerson_ok2(): array {
$json = '{"name": "John", "age": 44}';
/** @psalm-var Person */
$person = json_decode($json, true);
return $person;
}
|
I found these snippets: https://psalm.dev/r/fa74710ae3<?php
/**
* @psalm-type Person = array{name: string, age: int}
*/
/**
* @psalm-return Person
*/
function getPerson_error(): array {
$json = '{"name": "John", "age": 44}';
/** @psalm-var Person */
return json_decode($json, true);
}
/**
* @psalm-return Person
*/
function getPerson_ok1(): array {
$json = '{"name": "John", "age": 44}';
/** @psalm-var array{name: string, age: int} */
return json_decode($json, true);
}
/**
* @psalm-return Person
*/
function getPerson_ok2(): array {
$json = '{"name": "John", "age": 44}';
/** @psalm-var Person */
$person = json_decode($json, true);
return $person;
}
|
1 similar comment
I found these snippets: https://psalm.dev/r/fa74710ae3<?php
/**
* @psalm-type Person = array{name: string, age: int}
*/
/**
* @psalm-return Person
*/
function getPerson_error(): array {
$json = '{"name": "John", "age": 44}';
/** @psalm-var Person */
return json_decode($json, true);
}
/**
* @psalm-return Person
*/
function getPerson_ok1(): array {
$json = '{"name": "John", "age": 44}';
/** @psalm-var array{name: string, age: int} */
return json_decode($json, true);
}
/**
* @psalm-return Person
*/
function getPerson_ok2(): array {
$json = '{"name": "John", "age": 44}';
/** @psalm-var Person */
$person = json_decode($json, true);
return $person;
}
|
I found these snippets: https://psalm.dev/r/f86eb62c76<?php
/**
* @template A
*/
class Config {
/**
* @param (callable(): A)|null $x
*/
public function __construct($x = null)
{}
/**
* @template NewA
* @param (callable(): NewA)|null $x
* @return Config<NewA>
*/
public static function create($x = null)
{
return new self($x);
}
}
// Named constructor Tests:
/** @return Config<never>*/
function namedEmptyConfig() {
return Config::create();
}
/**
* This somehow resolves to mixed instead of never - even though the value is also null here:
* @return Config<never>
*/
function namedNullConfig() {
return Config::create(null);
}
// Test config constructor:
/**
* @return Config<never>
* Why does this work differently than the named constructor?
* I would expect "never" to be the result here, but instead it is mixed.
*/
function emptyConfig() {
return new Config();
}
/**
* @return Config<never>
* Same issue as in named constructor test - I'dd expect never here.
*/
function nullConfig() {
return new Config(null);
}
/** @return Config<string> */
function configured() {
return new Config(fn () => 'hello');
}
|
1 similar comment
I found these snippets: https://psalm.dev/r/f86eb62c76<?php
/**
* @template A
*/
class Config {
/**
* @param (callable(): A)|null $x
*/
public function __construct($x = null)
{}
/**
* @template NewA
* @param (callable(): NewA)|null $x
* @return Config<NewA>
*/
public static function create($x = null)
{
return new self($x);
}
}
// Named constructor Tests:
/** @return Config<never>*/
function namedEmptyConfig() {
return Config::create();
}
/**
* This somehow resolves to mixed instead of never - even though the value is also null here:
* @return Config<never>
*/
function namedNullConfig() {
return Config::create(null);
}
// Test config constructor:
/**
* @return Config<never>
* Why does this work differently than the named constructor?
* I would expect "never" to be the result here, but instead it is mixed.
*/
function emptyConfig() {
return new Config();
}
/**
* @return Config<never>
* Same issue as in named constructor test - I'dd expect never here.
*/
function nullConfig() {
return new Config(null);
}
/** @return Config<string> */
function configured() {
return new Config(fn () => 'hello');
}
|
I found these snippets: https://psalm.dev/r/4121eceef8<?php
/**
* @return array<string>
*/
function takesAnInt(int $i) {
return [$i, "hello"];
}
$data = ["some text", 5];
takesAnInt($data[0]);
$condition = rand(0, 5);
if ($condition) {
} elseif ($condition) {}
|
1 similar comment
I found these snippets: https://psalm.dev/r/4121eceef8<?php
/**
* @return array<string>
*/
function takesAnInt(int $i) {
return [$i, "hello"];
}
$data = ["some text", 5];
takesAnInt($data[0]);
$condition = rand(0, 5);
if ($condition) {
} elseif ($condition) {}
|
I found these snippets: https://psalm.dev/r/4121eceef8<?php
/**
* @return array<string>
*/
function takesAnInt(int $i) {
return [$i, "hello"];
}
$data = ["some text", 5];
takesAnInt($data[0]);
$condition = rand(0, 5);
if ($condition) {
} elseif ($condition) {}
|
1 similar comment
I found these snippets: https://psalm.dev/r/4121eceef8<?php
/**
* @return array<string>
*/
function takesAnInt(int $i) {
return [$i, "hello"];
}
$data = ["some text", 5];
takesAnInt($data[0]);
$condition = rand(0, 5);
if ($condition) {
} elseif ($condition) {}
|
I found these snippets: https://psalm.dev/r/4121eceef8<?php
/**
* @return array<string>
*/
function takesAnInt(int $i) {
return [$i, "hello"];
}
$data = ["some text", 5];
takesAnInt($data[0]);
$condition = rand(0, 5);
if ($condition) {
} elseif ($condition) {}
|
1 similar comment
I found these snippets: https://psalm.dev/r/4121eceef8<?php
/**
* @return array<string>
*/
function takesAnInt(int $i) {
return [$i, "hello"];
}
$data = ["some text", 5];
takesAnInt($data[0]);
$condition = rand(0, 5);
if ($condition) {
} elseif ($condition) {}
|
Let's check it again: https://psalm.dev/r/dd01eef1e0 |
I found these snippets: https://psalm.dev/r/dd01eef1e0<?php
abstract class Arr0 {
/**
* @param iterable<mixed> $arr
* @param \Closure|int|string|string[] $map
* @psalm-suppress UnusedParam
*/
static function map(
iterable $arr,
int|string|array|\Closure $map = null,
mixed $where = null,
mixed $skip = null,
mixed $while = null,
mixed $reverse = false,
): void {
}
}
function v(): int|string|object|array|bool {
return true;
}
$a = Arr0::map([], 1, v(), v(), v());
|
1 similar comment
I found these snippets: https://psalm.dev/r/dd01eef1e0<?php
abstract class Arr0 {
/**
* @param iterable<mixed> $arr
* @param \Closure|int|string|string[] $map
* @psalm-suppress UnusedParam
*/
static function map(
iterable $arr,
int|string|array|\Closure $map = null,
mixed $where = null,
mixed $skip = null,
mixed $while = null,
mixed $reverse = false,
): void {
}
}
function v(): int|string|object|array|bool {
return true;
}
$a = Arr0::map([], 1, v(), v(), v());
|
And again: https://psalm.dev/r/dd01eef1e0 |
I found these snippets: https://psalm.dev/r/dd01eef1e0<?php
abstract class Arr0 {
/**
* @param iterable<mixed> $arr
* @param \Closure|int|string|string[] $map
* @psalm-suppress UnusedParam
*/
static function map(
iterable $arr,
int|string|array|\Closure $map = null,
mixed $where = null,
mixed $skip = null,
mixed $while = null,
mixed $reverse = false,
): void {
}
}
function v(): int|string|object|array|bool {
return true;
}
$a = Arr0::map([], 1, v(), v(), v());
|
1 similar comment
I found these snippets: https://psalm.dev/r/dd01eef1e0<?php
abstract class Arr0 {
/**
* @param iterable<mixed> $arr
* @param \Closure|int|string|string[] $map
* @psalm-suppress UnusedParam
*/
static function map(
iterable $arr,
int|string|array|\Closure $map = null,
mixed $where = null,
mixed $skip = null,
mixed $while = null,
mixed $reverse = false,
): void {
}
}
function v(): int|string|object|array|bool {
return true;
}
$a = Arr0::map([], 1, v(), v(), v());
|
How are we doing? |
I found these snippets: https://psalm.dev/r/034888a55f<?php
/**
* @param scalar $literal
*/
function quoteLiteral($literal): string
{
if (is_numeric($literal) && ! is_string($literal)) {
return (string) $literal;
} elseif (is_bool($literal)) {
return $literal ? 'true' : 'false';
}
/** @psalm-trace $literal */
return "'" . str_replace("'", "''", $literal) . "'";
}
|
Still there? psalm.dev/r/fa74710ae3 |
Still there? https://psalm.dev/r/fa74710ae3 |
I found these snippets: https://psalm.dev/r/fa74710ae3<?php
/**
* @psalm-type Person = array{name: string, age: int}
*/
/**
* @psalm-return Person
*/
function getPerson_error(): array {
$json = '{"name": "John", "age": 44}';
/** @psalm-var Person */
return json_decode($json, true);
}
/**
* @psalm-return Person
*/
function getPerson_ok1(): array {
$json = '{"name": "John", "age": 44}';
/** @psalm-var array{name: string, age: int} */
return json_decode($json, true);
}
/**
* @psalm-return Person
*/
function getPerson_ok2(): array {
$json = '{"name": "John", "age": 44}';
/** @psalm-var Person */
$person = json_decode($json, true);
return $person;
}
|
I found these snippets: https://psalm.dev/r/7a2cc47bec<?php
/** @property-read bool $val */
class Request {
function b(bool $_b): void {}
public function __get(string $key): mixed { return true; }
}
class C {
function f(Request $r): void {
/** @psalm-suppress UndefinedVariable */
$r->b(_b: filter_var($val, FILTER_VALIDATE_BOOL));
}
}
|
https://psalm.dev/r/fa74710ae3
The text was updated successfully, but these errors were encountered: