Fix: Permitir execução autônoma (fora do Laravel) garantindo estabilidade no acesso a configs#24
Conversation
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>
|
👋 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 New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
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 traitProgressable, 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çõesgetPrefixStorageKey,getTTLegetPrecisiondo 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 deconfig(), 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 doconfig()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
.mdmodificado, 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