Skip to content
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

[3.x] Add template types #60

Open
wants to merge 1 commit into
base: 3.x
Choose a base branch
from
Open

[3.x] Add template types #60

wants to merge 1 commit into from

Conversation

WyriHaximus
Copy link
Contributor

No description provided.

@WyriHaximus WyriHaximus added this to the 3.0.0 milestone Jan 10, 2025
@boring-cyborg boring-cyborg bot added Dependencies 📦 Pull requests that update a dependency file JSON 👨‍💼 NEON 🦹‍♂️ PHP 🐘 Hypertext Pre Processor Source 🔮 Tests 🧪 labels Jan 10, 2025
Copy link

github-actions bot commented Jan 10, 2025

🏰 Composer Production Dependency changes 🏰

Prod Packages Operation Base Target Link
lcobucci/clock Upgraded 2.0.0 3.3.1 Compare
psr/clock New - 1.0.0 Compare
react-parallel/contracts Changed 2.x-dev 41d2fa3 dev-ensure-void-returntype-translates-to-null bed1924 Compare
react-parallel/event-loop Changed 2.x-dev d34a8cf dev-2.x-ensure-void-returntype-translates-to-null 1f721d7 Compare
react-parallel/runtime Changed 3.x-dev 6e438eb dev-3.x-use-stubs-from-stubs-package 7000e4d Compare
react/async Upgraded v4.2.0 v4.3.0 Compare
react/promise Upgraded v2.11.0 v3.2.0 Compare
wyrihaximus/metrics Upgraded 2.0.0 2.1.0 Compare
wyrihaximus/pool-info Upgraded 1.1.0 2.0.0 Compare
php Changed ^8.1 ^8.2
reactivex/rxphp Removed 2.0.12 - Compare
wyrihaximus/react-awaitable-observable Removed 1.0.0 - Compare
wyrihaximus/react-event-loop-rx-scheduler-hook-up Removed 0.1.1 - Compare

Copy link

github-actions bot commented Jan 10, 2025

🚧 Composer Development Dependency changes 🚧

Dev Packages Operation Base Target Link
amphp/amp Upgraded v2.4.2 v2.6.4 Compare
amphp/byte-stream Upgraded v1.5.0 v1.8.2 Compare
azjezz/psl Upgraded 2.0.4 2.9.1 Compare
beberlei/assert Upgraded v3.3.0 v3.3.3 Compare
colinodell/json5 New - v2.3.0 Compare
composer-unused/contracts Upgraded 0.2.0 0.3.0 Compare
composer-unused/symbol-parser Upgraded 0.1.8 0.2.5 Compare
composer/ca-bundle Upgraded 1.2.0 1.5.5 Compare
composer/class-map-generator Upgraded 1.0.0 1.5.0 Compare
composer/composer Upgraded 2.4.2 2.8.4 Compare
composer/pcre Upgraded 2.0.0 3.3.2 Compare
composer/semver Upgraded 3.0.0 3.4.3 Compare
composer/spdx-licenses Upgraded 1.5.7 1.5.8 Compare
composer/xdebug-handler Upgraded 2.0.2 3.0.5 Compare
dealerdirect/phpcodesniffer-composer-installer Upgraded v0.7.1 v1.0.0 Compare
doctrine/coding-standard Upgraded 9.0.0 12.0.0 Compare
doctrine/deprecations New - 1.1.4 Compare
doctrine/instantiator Upgraded 1.3.1 2.0.0 Compare
ergebnis/composer-normalize Upgraded 2.28.3 2.45.0 Compare
ergebnis/json New - 1.4.0 Compare
ergebnis/json-normalizer Upgraded 2.1.0 4.8.0 Compare
ergebnis/json-pointer New - 3.6.0 Compare
ergebnis/json-printer Upgraded 3.2.0 3.7.0 Compare
ergebnis/json-schema-validator Upgraded 2.0.0 4.4.0 Compare
ergebnis/phpstan-rules Upgraded 1.0.0 2.5.2 Compare
felixfbecker/advanced-json-rpc Upgraded v3.1.0 v3.2.1 Compare
felixfbecker/language-server-protocol Upgraded v1.5.0 v1.5.3 Compare
fidry/cpu-core-counter New - 1.2.0 Compare
filp/whoops Upgraded 2.14.5 2.16.0 Compare
guzzlehttp/guzzle Upgraded 6.0.0 7.9.2 Compare
guzzlehttp/promises Upgraded 1.0.0 2.0.4 Compare
guzzlehttp/psr7 Upgraded 1.0.0 2.7.0 Compare
icanhazstring/composer-unused Upgraded 0.8.2 0.8.11 Compare
infection/extension-installer Upgraded 0.1.1 0.1.2 Compare
infection/infection Upgraded 0.26.10 0.27.10 Compare
jangregor/phpstan-prophecy Upgraded 1.0.0 1.0.2 Compare
jetbrains/phpstorm-stubs Upgraded v2022.2 v2023.3 Compare
justinrainbow/json-schema Upgraded 5.2.12 5.3.0 Compare
localheinz/diff Upgraded 1.1.1 1.2.0 Compare
maglnet/composer-require-checker Upgraded 4.0.0 4.14.0 Compare
moneyphp/money Upgraded v3.2.1 v3.3.3 Compare
myclabs/deep-copy Upgraded 1.10.1 1.12.1 Compare
netresearch/jsonmapper Upgraded v1.0.0 v4.5.0 Compare
nikic/php-parser Upgraded v4.15.1 v4.19.4 Compare
nikolaposa/version Upgraded 4.1.0 4.2.0 Compare
nunomaduro/collision Upgraded v6.0.0 v7.11.0 Compare
nunomaduro/termwind New - v1.17.0 Compare
ocramius/package-versions Upgraded 2.5.1 2.9.0 Compare
ondram/ci-detector Upgraded 4.1.0 4.2.0 Compare
orklah/psalm-insane-comparison Upgraded v2.0.0 v2.3.0 Compare
phar-io/manifest Upgraded 2.0.3 2.0.4 Compare
phar-io/version Upgraded 3.0.2 3.2.1 Compare
php-coveralls/php-coveralls Upgraded v2.5.2 v2.7.0 Compare
php-parallel-lint/php-parallel-lint Upgraded v1.3.2 v1.4.0 Compare
php-standard-library/psalm-plugin Upgraded 1.1.0 2.3.0 Compare
phpdocumentor/reflection-docblock Upgraded 5.2.0 5.6.1 Compare
phpdocumentor/type-resolver Upgraded 1.3.0 1.10.0 Compare
phpspec/prophecy Upgraded v1.15.0 v1.20.0 Compare
phpspec/prophecy-phpunit Upgraded v2.0.1 v2.3.0 Compare
phpstan/phpdoc-parser Upgraded 0.5.1 1.33.0 Compare
phpstan/phpstan Upgraded 1.8.2 1.12.15 Compare
phpstan/phpstan-deprecation-rules Upgraded 1.0.0 1.2.1 Compare
phpstan/phpstan-mockery New - 1.1.3 Compare
phpstan/phpstan-php-parser Upgraded 1.0.0 1.1.0 Compare
phpstan/phpstan-phpunit Upgraded 1.0.0 1.4.2 Compare
phpstan/phpstan-strict-rules Upgraded 1.1.0 1.6.1 Compare
phpunit/php-code-coverage Upgraded 9.2.13 9.2.32 Compare
phpunit/php-file-iterator Upgraded 3.0.5 3.0.6 Compare
phpunit/php-text-template Upgraded 2.0.3 2.0.4 Compare
phpunit/php-timer Upgraded 5.0.2 5.0.3 Compare
phpunit/phpunit Upgraded 9.5.21 9.6.22 Compare
psalm/plugin-phpunit Upgraded 0.17.0 0.18.4 Compare
psr/container Upgraded 1.1.0 2.0.2 Compare
psr/http-client New - 1.0.3 Compare
psr/http-factory New - 1.1.0 Compare
psr/http-message Upgraded 1.0 2.0 Compare
psr/log Upgraded 1.1.0 2.0.0 Compare
ralouphie/getallheaders New - 3.0.3 Compare
react-parallel/pool-tests Changed 4.x-dev c63cc86 dev-4.x-ensure-void-returntype-translates-to-null 613f657 Compare
react-parallel/stubs New - 1.2.0 Compare
revolt/event-loop Upgraded v0.2.5 v1.0.6 Compare
roave/backward-compatibility-check Upgraded 7.2.0 8.6.0 Compare
roave/better-reflection Upgraded 6.2.0 6.26.0 Compare
roave/infection-static-analysis-plugin Upgraded 1.19.0 1.35.0 Compare
roave/signature Upgraded 1.6.0 1.8.0 Compare
sanmai/later Upgraded 0.1.2 0.1.4 Compare
sanmai/pipeline Upgraded v5.1.0 6.12 Compare
sebastian/cli-parser Upgraded 1.0.1 1.0.2 Compare
sebastian/code-unit Upgraded 1.0.6 1.0.8 Compare
sebastian/code-unit-reverse-lookup Upgraded 2.0.2 2.0.3 Compare
sebastian/comparator Upgraded 4.0.5 4.0.8 Compare
sebastian/complexity Upgraded 2.0.0 2.0.3 Compare
sebastian/diff Upgraded 4.0.3 4.0.6 Compare
sebastian/environment Upgraded 5.1.3 5.1.5 Compare
sebastian/exporter Upgraded 4.0.3 4.0.6 Compare
sebastian/global-state Upgraded 5.0.1 5.0.7 Compare
sebastian/lines-of-code Upgraded 1.0.3 1.0.4 Compare
sebastian/object-enumerator Upgraded 4.0.3 4.0.4 Compare
sebastian/object-reflector Upgraded 2.0.2 2.0.4 Compare
sebastian/recursion-context Upgraded 4.0.2 4.0.5 Compare
sebastian/resource-operations Upgraded 3.0.3 3.0.4 Compare
sebastian/type Upgraded 3.0.0 3.2.1 Compare
seld/jsonlint Upgraded 1.8.0 1.11.0 Compare
seld/phar-utils Upgraded 1.2.0 1.2.1 Compare
seld/signal-handler Upgraded 2.0.0 2.0.2 Compare
slevomat/coding-standard Upgraded 7.0.14 8.15.0 Compare
spatie/array-to-xml New - 3.4.0 Compare
squizlabs/php_codesniffer Upgraded 3.7.1 3.11.2 Compare
symfony/config Upgraded v5.4.0 v7.2.0 Compare
symfony/console Upgraded v6.0.13 v6.4.17 Compare
symfony/dependency-injection Upgraded v6.0.0 v7.2.0 Compare
symfony/deprecation-contracts Upgraded v2.1.2 v3.5.1 Compare
symfony/filesystem Upgraded v5.4.0 v7.2.0 Compare
symfony/finder Upgraded v5.4.0 v7.2.2 Compare
symfony/polyfill-ctype Upgraded v1.8.0 v1.31.0 Compare
symfony/polyfill-intl-grapheme Upgraded v1.0.0 v1.31.0 Compare
symfony/polyfill-intl-normalizer Upgraded v1.0.0 v1.31.0 Compare
symfony/polyfill-mbstring Upgraded v1.8.0 v1.31.0 Compare
symfony/polyfill-php73 Upgraded v1.24.0 v1.31.0 Compare
symfony/polyfill-php80 Upgraded v1.25.0 v1.31.0 Compare
symfony/polyfill-php81 Upgraded v1.22.0 v1.31.0 Compare
symfony/polyfill-php83 New - v1.31.0 Compare
symfony/process Upgraded v5.4.0 v7.2.0 Compare
symfony/property-access New - v7.2.0 Compare
symfony/property-info New - v7.2.2 Compare
symfony/serializer Upgraded v4.4.9 v7.2.0 Compare
symfony/service-contracts Upgraded v1.1.9 v3.5.1 Compare
symfony/stopwatch Upgraded v2.2.0 v7.2.2 Compare
symfony/string Upgraded v5.4.0 v7.2.0 Compare
symfony/translation-contracts New - v3.5.1 Compare
symfony/type-info New - v7.2.2 Compare
symfony/validator New - v7.2.2 Compare
symfony/var-exporter New - v7.2.0 Compare
symfony/yaml Upgraded v5.4.0 v7.2.0 Compare
theseer/tokenizer Upgraded 1.2.0 1.2.3 Compare
vimeo/psalm Upgraded 4.26.0 5.26.1 Compare
webmozart/assert Upgraded 1.10.0 1.11.0 Compare
webmozart/glob Upgraded 4.4.0 4.7.0 Compare
wyrihaximus/async-test-utilities Upgraded 5.0.0 7.3.0 Compare
wyrihaximus/coding-standard Upgraded 2.11.0 2.15.0 Compare
wyrihaximus/phpstan-react New - 1.0.0 Compare
wyrihaximus/phpstan-rules-wrapper Upgraded 2.0.0 3.5.0 Compare
wyrihaximus/test-utilities Upgraded 5.0.21 5.6.0 Compare
clue/block-react Removed v1.5.0 - Compare
facade/ignition-contracts Removed 1.0.2 - Compare
openlss/lib-array2xml Removed 1.0.0 - Compare
react/promise-timer Removed v1.5.0 - Compare
webmozart/path-util Removed 2.3.0 - Compare

Comment on lines +12 to +18
assertType('null', $pool->run(static function (): void {
sleep(1);
}));

assertType('null', $pool->run(static function (int $time): void {
sleep($time);
}, [1]));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned on Discord, a void method does not produce a result, therefore you must test this by verifying the expression before it is executed:

-assertType('null', $pool->run(static function (): void {
+assertType('Closure(): void', (fn () => $pool->run(static function (): void {
    sleep(1);
-}));
+})));

See https://phpstan.org/r/6d97e370-676c-4ce0-b27a-c4eabe6ed4cd

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ocramius Correct, and normally that's what it is. In this case, if I pass function (): void {} to https://www.php.net/manual/en/parallel.run.php#refsect1-parallel.run-returnvalues I get a null back because it's a fire and forget thread. In the other situation when I do return something from a callable I get a https://www.php.net/manual/en/class.parallel-future.php back. Now the return type hinting for that part is all sorted and works as expected. But the void to null "translation" would have been nice. I'll put in your suggestions as I don't care too much about this specific test. There is another one I do care about and I think/thought it might have the same root cause, was hoping to point it out but just found out PHPStan didn't run this run for some weird reason. Will let you know once I've fixed that 🤦 .

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A void future can still be retrieved, I suppose: it's just that its value can never be assigned to a LHS expression :-)

Comment on lines +83 to +86
return $runtime->run(
$callable,
$args,
);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ocramius So this line has the actual interesting/problematic error on it and this is also why having it confirmed in the type testing would have been sweet.

Method ReactParallel\Pool\Infinite\Infinite::run() should return T|null but returns T|void|null.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is the assertion to check, if that's a test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I... already commented with my recommendations there? D:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, and those recommendations there are good, but trying to solve this part of the void issue here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants