Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Php Cs Fixer Enforce Double Quotes Laravel Package

gd-75/php-cs-fixer-enforce-double-quotes

A PHP CS Fixer rule from gd-75 that enforces double-quoted strings. Add it to your fixer config to automatically convert single quotes to double quotes, keeping string style consistent across your PHP or Laravel codebase and CI checks.

View on GitHub
Deep Wiki
Context7

Getting Started

This package handles string interpolation/templating — the 1.1.0 notes ("advanced strings", "$ escaping") point at a $-placeholder syntax with a configurable/escapable literal $. Since there's no published README excerpt in the assessment data, treat the release's test suite as the primary documentation: it is now explicitly "backed by unit tests", which makes the tests the authoritative spec for the new escaping rules and the "advanced string" syntax.

Minimal path:

  1. composer require the package (1.1.0 is a minor bump — a safe in-place upgrade from any 1.0.x, no breaking changes signalled).
  2. If the package ships a config file, publish it first (php artisan vendor:publish) before you start templating, so escaping behaviour and delimiter settings are visible and version-controlled.
  3. Read tests/ in the vendor directory — specifically anything named around escaping or advanced/nested strings. That is where 1.1.0's behaviour is defined.
  4. First use case: take a stored string containing $ placeholders (mail body, notification copy, CMS field, generated filename), pass it plus a data array to the package's render/interpolate entry point, and assert the output. Add a second assertion with a literal $ in the template to confirm the new escaping path.

Do not start with dynamic/user-supplied templates. Start with one hardcoded template so you can tell a parsing problem from a data problem.

Implementation Patterns

Wrap it in a single application-level helper. Do not call the package facade/class directly from controllers, mailables, and jobs. One TemplateRenderer service (or a Str::macro) with a render(string $template, array $data): string signature gives you one place to change when 1.2.0 shifts syntax again, and one place to add logging and try/catch.

Bind it, don't new it. Register the package's renderer in a service provider (or let its own provider do it) and resolve from the container. This matters if the package exposes config for delimiters/escaping — a manually constructed instance will silently ignore your published config.

Treat templates as data, not code. The natural integration is a templates table (key, body, updated_at) with the package rendering body against a payload. Cache the raw body per key (Cache::remember) — parsing is the cost, not the row fetch. Invalidate on save via a model observer.

Blade directive / helper for views. Where templates live in Blade files, a @template('invoice.paid', $payload) directive or {{ template(...) }} helper keeps the call site readable. Escape the result with {{ }} as normal — this package interpolates, it does not sanitise.

Pair with validation, not instead of it. Since templates are strings, validate that required keys exist in the payload before rendering (a TemplateData data-transfer object with rules is a good fit) rather than letting a missing key surface as a half-rendered string in a production email.

Test the escaping contract explicitly. Write your own tests for: literal $, \$-style escaping if that's the syntax, a $ adjacent to punctuation, and a placeholder at the very end of the string. These are exactly the cases 1.1.0 fixed, so pin them now — a future patch could regress one and your suite catches it before your users do.

Snapshot/assert full output, not substrings. Escaping bugs hide in the characters around a replacement. assertSame($expected, $rendered) across a handful of realistic templates (invoice line, password-reset copy, filename) beats assertStringContainsString.

Gotchas and Tips

  • The $ escaping fix is the thing to re-verify on upgrade. 1.1.0 changed how $ is escaped. Any template where you previously worked around the old behaviour — double dollars, concatenation hacks, a placeholder that only rendered because of the bug — is a candidate for silently changing output. Search your template store for $ before you deploy, and diff rendered output for your top ten templates between versions.
  • "Advanced strings" is undefined from the release notes alone. Determine from the tests whether this means nested access ($user.name), method-ish calls, default/fallback syntax, or multi-line handling. Do not document syntax to your team from the changelog — copy it from the test cases.
  • Escaping is order-sensitive. If the package unescapes after rendering, a value in your data array that itself contains $ may get re-interpreted on a second pass. Only render once; never render an already-rendered string. If you must, re-escape the intermediate output.
  • Data values are not escaped for you. Interpolation ≠ escaping. If templates are user-editable and output goes into HTML, you have an injection surface. Escape at the output boundary (Blade, e()) and treat the renderer as a pure string transform.
  • Debug by isolating the string, not the app. When a template misbehaves, reduce to the smallest failing string in php artisan tinker before touching the call site. Most "package bug" reports turn out to be a payload key with a trailing space or a null being cast.
  • Extension points: if the package exposes a custom-resolver/replacer interface, use it for app-specific syntax (e.g. %total%) instead of pre-string-replacing the template before handing it over. Pre-replacement breaks escaping because you're mutating the string the parser is about to tokenise.
  • Pin the minor version if rendering is customer-facing. "^1.1" is reasonable now that the package is unit-tested, but the escaping area is clearly still active. "~1.1.0" buys you a manual review of 1.2.0 before invoices go out wrong.
  • Config quirk to check: if delimiters or the escape character are configurable, cached config (php artisan config:cache) is a common cause of "works locally, wrong in staging". Clear config cache after any publish or key change.
  • Upgrade checklist: run your own render tests against 1.1.0, grep templates for literal $, render one representative real template in staging and eyeball it, then deploy. No migration or breaking-change steps are implied by these notes.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
uni-method/symfony-lib
tacticmedia/scim-server-bundle
neika-ai/symfony-bundle
mattleads/agent-publishing-bundle
glavweb/framework-bundle
glavweb/extra-bundle
glavweb/api-bundle
glavweb/admin-bundle
adachsoft/api-version-bundle
elsayed85/laravel-api-exceptions
ouhssini/laravel-demo-mode
daworks/ncloud-outbound-mailer-driver
gp247/cms
ignibyte/aic-gates
nexa-merchant/blog
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
cgv/localized-resource