Declare strict_types in the global helper files
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 68/100
Rechercherichtung
Start with the 26 helper files listed in the issue and the helper tests that cover coercion-dependent inputs; for each affected helper, pin its current return value before making conversions explicit. Add strict_types declarations throughout src/*/Helpers and remove that directory's skip in rector.php. Run the helper tests and composer rector:check; done when all checks pass and the helpers retain their existing results.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Summary
Every class file in src declares declare(strict_types=1);, but most of the global helper files in src/*/Helpers do not: 26 of 30 lack it. Only db.php, debugger.php, transformer.php and view.php declare it. Add it to all of them, so the whole of src runs with the same type rules, and let Rector guard it.
Problem
- Inconsistent type rules. A call made inside a helper file without
strict_typessilently converts scalars: a helper that passes'587'to anintparameter, or1to astringparameter, works there and throws aTypeErrorin a class file. The same code behaves differently depending on which file it is in. - Rector skips the helpers. Since Rector 2.9 removed
DeclareStrictTypesRector(#710),rector.phpusesSafeDeclareStrictTypesRectorwith a skip forsrc/*/Helpers/*, so nothing checks the helper files.
strict_types only affects calls made inside the file that declares it. An application calling config(), cache() or env() from its own code behaves the same either way.
Proposed change
- 13 helper files Rector finds type-safe (no scalar coercion inside): add
declare(strict_types=1);as Rector would.
App/Helpers/app.php,App/Helpers/uuid.php,Auth/Helpers/auth.php,Cache/Helpers/cache.php,Captcha/Helpers/captcha.php,Cron/Helpers/cron.php,HttpClient/Helpers/http_client.php,Lang/Helpers/lang.php,Logger/Helpers/logger.php,Mailer/Helpers/mailer.php,Router/Helpers/router.php,Session/Helpers/session.php,Storage/Helpers/fs.php - 13 helper files Rector does not add it to: find each call that relies on a coercion, make the conversion explicit so the helper returns what it returns today, then add
declare(strict_types=1);.
App/Helpers/dir.php,App/Helpers/misc.php,Asset/Helpers/asset.php,Config/Helpers/config.php,Cookie/Helpers/cookie.php,Csrf/Helpers/csrf.php,Encryption/Helpers/encryption.php,Environment/Helpers/env.php,Environment/Helpers/server.php,Event/Helpers/event.php,Http/Helpers/http.php,Model/Helpers/model.php,Service/Helpers/service.php rector.php: remove thesrc/*/Helpers/*skip, soSafeDeclareStrictTypesRectorcovers the helpers too.
No public function changes its signature or result, so nothing breaks for applications.
Tests
- Before each change in step 2, a test pins what the helper returns for the input that relied on the coercion, and passes before and after.
- The existing helper tests pass unchanged.
composer rector:checkpasses without the skip.
Acceptance criteria
- every file in
src/*/Helpersdeclaresdeclare(strict_types=1); rector.phphas no skip for the helpers- no helper changes what it returns for the inputs it accepts today
- all checks and tests pass
- Vorherrschende Sprache
- PHP
- Sterne
- 44
- Forks
- 22
- Ø Merge
- 2 Std. 57 Min.
- Gemergte PRs (30 T.)
- 52
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus quantum-php/framework
-
tech debt testing
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
quantum-php/framework#696 ·
Maintainer antworten meist innerhalb von 1 Tag
-
routing testing
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
quantum-php/framework#547 ·
Maintainer antworten meist innerhalb von 1 Tag
-
breaking change enhancement
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 72/100
quantum-php/framework#715 ·
Maintainer antworten meist innerhalb von 1 Tag
-
enhancement
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 45/100
quantum-php/framework#714 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Raise PHPStan to level 9Offenrefactoring tech debt
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 20/100
quantum-php/framework#693 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in quantum-php/framework
Ähnliche Issues
-
OCM: shares using the `embedded` protocol are rejected with "Missing sharedSecret in protocol"Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
ExpressionEngine/ExpressionEngine#5493 ·
Maintainer antworten meist innerhalb von 5 Tagen
-
"Attempt to read property 'username' on null" error after a user is deletedEvtl. vergeben @dicksonlaw583 hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
omeka/plugin-SimplePages#49 ·
-
not confirmed
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
Maintainer antworten meist innerhalb von 1 Tag
-
enhancement good first issue
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 86/100
Maintainer antworten meist innerhalb von 1 Tag