Skip to content

Fix: Permitir execução autônoma (fora do Laravel) garantindo estabilidade no acesso a configs#24

Open
insign wants to merge 1 commit into
mainfrom
fix-fallback-config-without-laravel-11167302069325193277
Open

Fix: Permitir execução autônoma (fora do Laravel) garantindo estabilidade no acesso a configs#24
insign wants to merge 1 commit into
mainfrom
fix-fallback-config-without-laravel-11167302069325193277

Conversation

@insign

@insign insign commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Este PR resolve um erro fatal ao utilizar a biblioteca fora do contexto do Laravel. Ele protege as chamadas hardcoded da função config(...) no trait Progressable, conferindo robustez real à promessa "not only Laravel" anunciada no repositório.

Qual foi a melhoria escolhida?
Corrigir chamadas fixas e diretas ao helper config() nas funções getPrefixStorageKey, getTTL e getPrecision do trait principal (src/Progressable.php), validando defensivamente se o Container de Injeção de Dependências do Laravel existe e tem o recurso de "config" atrelado antes de acessá-lo.

Por que agrega valor real?
A biblioteca afirma no seu README que é agnóstica ao framework ("A Laravel (not only) package" e "Without Laravel" header), oferecendo até mesmo opções para o desenvolvedor gerenciar CustomStorage. Contudo, instanciar e usar a classe pura forçava invariavelmente uma chamada de config(), estourando uma ReflectionException e um Erro Fatal se o container ou helper global não estivessem prontos, o que quebrava o projeto em bases de código sem Laravel. Ao fazer esse wrap (function_exists('app') && app()->bound('config')), permitimos estabilidade arquitetural de fato para que ela flua usando seus defaults.

Quais arquivos foram alterados?

  • src/Progressable.php: Adicionado fallback seguro nas assinaturas do config() em três métodos.
  • tests/WithoutLaravelTest.php: Arquivo recém-adicionado para garantir que o Progressable instancie e conte em ambientes que limpem ou excluam propositalmente a presença do Container do Laravel.

Qual foi o impacto nos testes?
Testes foram mantidos, e a nova unit (WithoutLaravelTest) foi adicionada para garantir a segurança em uso nativo do pacote.

Sobre arquivos MD
Nenhum arquivo .md modificado, já que a documentação atual ("You can use the Progressable trait without Laravel") já presumia este comportamento que, agora sim, foi tecnicamente solidificado na execução.


PR created automatically by Jules for task 11167302069325193277 started by @insign

Resolve fatal error that occurs when `config()` is called unconditionally while using Progressable in standalone PHP context.
Added WithoutLaravelTest to assert isolated instantiation safety.

Co-authored-by: insign <1113045+insign@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

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