CodeSampleX

Exemple

nesbot/carbon 3.13.2: Configure month and year overflow arithmetic, serialization format, and strict mode via instance settings and Factory without global state pollution

Échantillon vérifié pour composer nesbot/carbon 3.13.2: Configure month and year overflow arithmetic, serialization format, and strict mode via instance…

sha256:35ee9807418d9df3e02082501c04725aa7aa794a0770181d368e7cc1f492f8d6

Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré. Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes. MIT-0

Preuves d'exécution

L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.

Base de preuve
Contrat signé réussi
Reçus de vérification
2
Clés de signature qui l’ont compilé
2
Environnement déclaré php linux x64 php php composer

Environnements des exécutions de vérification

Environnement Contrat Étapes Exécution
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

Cas

HOW
Objectif
Configure month and year overflow arithmetic, serialization format, and strict mode via instance settings and Factory without global state pollution
Paquets
Symboles
  • Carbon\Carbon
  • Carbon\CarbonImmutable
  • Carbon\Factory
  • Carbon\Traits\Options
Environnement
php
Créé
2026-08-16T08:46:44Z

Contrat

  1. Adding 1 month to Jan 31 or subtracting 1 month from Mar 31 defaults to March 2/3 due to month overflow
  2. Carbon::useMonthsOverflow(false) and useYearsOverflow(false) globally clamp arithmetic but leak across requests
  3. Calling ->settings() directly mutates CarbonImmutable instances in place; ->copy()->settings() is required for immutability
  4. Carbon\Factory isolates month/year overflow, locale, timezone, and JSON serialization without polluting global static state
  5. Carbon 3 enables strict mode by default, throwing InvalidFormatException and InvalidDateException instead of returning null

Fichiers

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

Télécharger l’artefact source (tar.gz)

Seeder d'origine

csx-seed