CodeSampleX

Ejemplo

symfony/console 7.2.1: Declare Symfony Console commands using the AsCommand attribute rather than the removed static defaultName property

Muestra verificada para composer symfony/console 7.2.1: Declare Symfony Console commands using the AsCommand attribute rather than the removed static…

sha256:6863aebd729c8113a15dec27179d3f8d80a5d9f6256ca354ba3f1a56e807c128

Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido. Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas. MIT-0

Evidencia de ejecución

El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.

Base de evidencia
Contrato firmado aprobado
Recibos de verificación
2
Claves de firma que lo compilaron
2
Entorno declarado php linux x64 php php composer

Entornos de las ejecuciones de verificación

Entorno Contrato Etapas Ejecución
php 8 · linux alpine/x64 · docker ed25519:d91480838ac982c9 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · composer@1
2026-08-16
php 8 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · composer@1
2026-08-18

Caso

HOW
Objetivo
Declare Symfony Console commands using the AsCommand attribute rather than the removed static defaultName property
Paquetes
Símbolos
  • Symfony\Component\Console\Command\Command
  • Symfony\Component\Console\Attribute\AsCommand
  • Symfony\Component\Console\Application
  • Symfony\Component\Console\Input\InputInterface
Entorno
php
Creado
2026-08-16T14:01:15Z

Contrato

  1. In Symfony Console 7, Command::getDefaultName() returns null for classes defining static $defaultName, leaving the command name null and causing Application::add() to throw LogicException unless configured via the #[AsCommand] attribute.
  2. The #[AsCommand] attribute encodes name, description, aliases, and hidden status into Command::getDefaultName() with leading pipe syntax
  3. Command instances configured with #[AsCommand] populate getName, getDescription, getAliases, and isHidden without calling setName in configure
  4. Application::add successfully registers commands and aliases defined via #[AsCommand] and rejects commands lacking a name
  5. InputInterface implements Stringable and converts bound arguments and options to a command-line string representation
  6. Command::setApplication requires an explicit parameter and throws ArgumentCountError when invoked with zero arguments

Archivos

  • NOTES.md
  • composer.json
  • composer.lock
  • csx.json
  • test/contract.php

Descargar el artefacto de código fuente (tar.gz)

Seeder de origen

csx-seed