-
Notifications
You must be signed in to change notification settings - Fork 477
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Narrow type on setting offsets of properties
- Loading branch information
Showing
9 changed files
with
153 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace Bug6398; | ||
|
||
class AsyncTask{ | ||
/** | ||
* @phpstan-var \ArrayObject<int, array<string, mixed>>|null | ||
*/ | ||
private static $threadLocalStorage = null; | ||
|
||
/** | ||
* @param mixed $complexData the data to store | ||
*/ | ||
protected function storeLocal(string $key, $complexData) : void{ | ||
if(self::$threadLocalStorage === null){ | ||
self::$threadLocalStorage = new \ArrayObject(); | ||
} | ||
self::$threadLocalStorage[spl_object_id($this)][$key] = $complexData; | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
protected function fetchLocal(string $key){ | ||
$id = spl_object_id($this); | ||
if(self::$threadLocalStorage === null or !isset(self::$threadLocalStorage[$id][$key])){ | ||
throw new \InvalidArgumentException("No matching thread-local data found on this thread"); | ||
} | ||
|
||
return self::$threadLocalStorage[$id][$key]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php declare(strict_types = 1); // lint >= 7.4 | ||
|
||
namespace Bug6571; | ||
|
||
interface ClassLoader{} | ||
|
||
class HelloWorld | ||
{ | ||
/** @var \Threaded|\ClassLoader[]|null */ | ||
private ?\Threaded $classLoaders = null; | ||
|
||
/** | ||
* @param \ClassLoader[] $autoloaders | ||
*/ | ||
public function setClassLoaders(?array $autoloaders = null) : void{ | ||
if($autoloaders === null){ | ||
$autoloaders = []; | ||
} | ||
|
||
if($this->classLoaders === null){ | ||
$this->classLoaders = new \Threaded(); | ||
}else{ | ||
foreach($this->classLoaders as $k => $autoloader){ | ||
unset($this->classLoaders[$k]); | ||
} | ||
} | ||
foreach($autoloaders as $autoloader){ | ||
$this->classLoaders[] = $autoloader; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Bug7880; | ||
|
||
class C { | ||
/** @var array{a: string, b: string}|null */ | ||
private $a = null; | ||
|
||
public function foo(): void { | ||
if ($this->a !== null) { | ||
$this->a['b'] = "baz"; | ||
} | ||
} | ||
} |