Skip to content

Modernise for Behat ^3.31 and PHP ^8.3, drop Behat 3 / Symfony <7.4#44

Open
pamil wants to merge 4 commits into
masterfrom
modernise/drop-behat3-split
Open

Modernise for Behat ^3.31 and PHP ^8.3, drop Behat 3 / Symfony <7.4#44
pamil wants to merge 4 commits into
masterfrom
modernise/drop-behat3-split

Conversation

@pamil

@pamil pamil commented Jun 12, 2026

Copy link
Copy Markdown
Member

Summary

  • Drop the Behat 3 split: delete src/Behat3/ (docblock annotation version) and src/autoload.php version detector; src/Behat310/ becomes src/ — single code path going forward
  • Unify behat config writing: thereIsConfiguration now writes behat.dist.php via ArrayConfig + var_export instead of a YAML file (behat 3) or an inline anonymous ConfigInterface class (behat 4) — works on both behat 3.31 and behat 4.x
  • Add replaceAnnotationsWithAttributes(): thereIsFile transparently converts /** @Given */ docblocks in PHP context files to #[Given] attributes, so existing feature file scenarios using old-style context snippets keep working without duplication issues on behat 3.31+
  • Add src/Config/ArrayConfig.php implementing ConfigInterface
  • Add symfony/yaml ^7.4 to require (needed to parse YAML config strings from feature files); bump PHP to ^8.3, behat to ^3.31, symfony/* to ^7.4; switch autoload from files[] to PSR-4
  • Collapse features/annotations/ and features/attributes/features/ (scenarios were identical; context snippets now use attributes only); delete behat.yml.dist
  • CI: modern PHP/Symfony matrix (8.3–8.5 × 7.4/8.0/8.1), restrict push trigger to master, behat 4.x step for SF 8+, add validate-composer job
  • PHPStan: add phpstan-bootstrap.php to declare BEHAT_BIN_PATH; fix all level-max errors; drop excludePaths for the now-deleted src/Behat3/

Test plan

  • CI passes (all 7 matrix jobs green)
  • 12 scenarios / 45 steps pass locally

🤖 Generated with Claude Code

pamil and others added 4 commits June 12, 2026 14:39
- Delete src/Behat3/ (docblock annotation version) and src/autoload.php
  version detector; move src/Behat310/ → src/ as the single code path
- Add src/Config/ArrayConfig.php; thereIsConfiguration now writes
  behat.dist.php via ArrayConfig+var_export instead of YAML file or
  inline anonymous ConfigInterface class
- Add replaceAnnotationsWithAttributes() to thereIsFile so old-style
  context files in feature scenarios are transparently upgraded
- Drop md5() wrapper in thereIsFeatureFile, simplify Process constructor,
  collapse dead assertOutputMatches branch, fix getProcess() nullability
- Add symfony/yaml ^7.4 to require; bump PHP to ^8.3, behat to ^3.31,
  symfony/* to ^7.4; switch autoload from files[] to PSR-4
- Collapse features/annotations/ and features/attributes/ → features/
  (scenarios were identical, context snippets now use attributes only)
- Remove behat.yml.dist; update behat.dist.php to point at features/
- Update CI: modern PHP/Symfony matrix (8.3-8.5 × 7.4/8.0/8.1),
  restrict push trigger to master, add behat 4.x step for SF 8+,
  add validate-composer job, drop old lowest/highest matrix
- Add phpstan-bootstrap.php to declare BEHAT_BIN_PATH; fix phpstan errors

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…pers

- thereIsConfiguration now writes content directly to behat.dist.php —
  callers supply valid PHP; no YAML parsing, no implicit conversion
- Drop symfony/yaml from require and from CI lock step
- Make $workingDir and $filesystem instance properties (set in
  beforeScenario); only $phpBin stays static — fixes scenario isolation
  and removes the remove-then-mkdir dance from beforeScenario
- Reset $process to null in beforeScenario to prevent stale state
- Collapse the four canned helpers to a single shared FeatureContext
  (writeSharedFeatureContext) that contains all steps — previously each
  helper wrote the same path, silently clobbering the previous one
- Change getProcessExitCode fallback from -1 to 1 (treat not-yet-exited
  as failure rather than an invalid POSIX code)

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
- Replace ArrayConfig with Behat\Config\Config — same ConfigInterface
  contract (constructor takes array, toArray() returns it), already
  a dependency; delete src/Config/ entirely
- Replace PhpExecutableFinder with PHP_BINARY constant — always points
  to the running PHP binary, no filesystem search, reliable under version
  managers (phpenv, asdf); removes the BeforeFeature static hook and the
  static $phpBin property
- Replace start()+wait() with run() — Process::run() is exactly that pair
- Remove trailing slash from $workingDir to avoid double-slash in paths

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant