Declare strict_types in the global helper files
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 68/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- PHP
- Estrellas
- 44
- Forks
- 22
- Merge medio
- 2 h 57 min
- PR fusionados (30 d)
- 52
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de quantum-php/framework
-
tech debt testing
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
quantum-php/framework#696 ·
Los mantenedores suelen responder en 1 día
-
routing testing
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
quantum-php/framework#547 ·
Los mantenedores suelen responder en 1 día
-
breaking change enhancement
Dificultad 3/5 1-2 días Aptitud para principiantes 72/100
quantum-php/framework#715 ·
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
quantum-php/framework#714 ·
Los mantenedores suelen responder en 1 día
-
Raise PHPStan to level 9Abiertorefactoring tech debt
Dificultad 5/5 Más de una semana Aptitud para principiantes 20/100
quantum-php/framework#693 ·
Los mantenedores suelen responder en 1 día
Todos los issues de quantum-php/framework
Issues similares
-
OCM: shares using the `embedded` protocol are rejected with "Missing sharedSecret in protocol"Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
ExpressionEngine/ExpressionEngine#5493 ·
Los mantenedores suelen responder en 5 días
-
"Attempt to read property 'username' on null" error after a user is deletedPosiblemente ocupada @dicksonlaw583 la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
omeka/plugin-SimplePages#49 ·
-
Copy button does not workAbiertonot confirmed
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día
-
enhancement good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
Los mantenedores suelen responder en 1 día