[Bug]: bin/pest --drift does not take into account strict_types=1 during migration

Aperta
#1,901 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 5 giorni

@lazerg ci sta già lavorando.

Dal 9/9/2026.

  • #59 di @lazerg — chiusa senza merge

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
php
Ambito
testing

Direzione di ricerca

Start with the bin/pest --drift migration entry point and reproduce the issue using the shortened PHPUnit sample from the report. Trace the generated migrated file and add or update coverage so declare(strict_types=1) remains first and self::bootKernel() remains inside its class scope without either reported error.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug
What Happened

After installing Pest and Drift I ran the command ./vendor/bin/pest --drift and it migrated a lot of our PhpUnit files. However, two things were incomplete and caused tests to not run after the migration:

  • Error 'strict_types' declaration must be the very first statement in the script
  • Error Cannot use "self" when no class scope is active
How to Reproduce

This shortened sample code from one of our PhpUnit tests will trigger both above issues:

<?php

declare(strict_types=1);

namespace App\Tests\Functional\Command;

use Pimcore\Test\KernelTestCase;

class DocumentCronCommandTest extends KernelTestCase
{
    public function testExecute(): void
    {
        $kernel = self::bootKernel();
        // Rest of test removed for brevity
    }
}
Sample Repository

No response

Pest Version

4.7.8

PHP Version

8.4.20

Operation System

Linux, macOS

Notes

No response

Lingua principale
PHP
Stelle
11.8k
Fork
559
Merge medio
5g 23h
PR unite (30g)
24

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di pestphp/pest

Tutte le issue di pestphp/pest

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.