<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Rajmund</title>
    <description>The latest articles on DEV Community by Rajmund (@rajmundtoth0).</description>
    <link>https://dev.to/rajmundtoth0</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3863295%2F2adf5b82-e1f2-4df5-afbe-66958d984569.png</url>
      <title>DEV Community: Rajmund</title>
      <link>https://dev.to/rajmundtoth0</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rajmundtoth0"/>
    <language>en</language>
    <item>
      <title>Stop shipping var_dump() to production — enforce it with PHPStan</title>
      <dc:creator>Rajmund</dc:creator>
      <pubDate>Mon, 06 Apr 2026 06:43:40 +0000</pubDate>
      <link>https://dev.to/rajmundtoth0/stop-shipping-vardump-to-production-enforce-it-with-phpstan-kpa</link>
      <guid>https://dev.to/rajmundtoth0/stop-shipping-vardump-to-production-enforce-it-with-phpstan-kpa</guid>
      <description>&lt;h1&gt;
  
  
  Stop shipping &lt;code&gt;var_dump()&lt;/code&gt; to production — enforce it with PHPStan
&lt;/h1&gt;

&lt;p&gt;We’ve all done it.&lt;/p&gt;

&lt;p&gt;You add a quick &lt;code&gt;var_dump()&lt;/code&gt; or &lt;code&gt;dd()&lt;/code&gt; while debugging…&lt;br&gt;
and somehow it survives code review 😅&lt;/p&gt;

&lt;p&gt;Or worse:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;someone uses &lt;code&gt;DB::raw()&lt;/code&gt; where it shouldn’t be used&lt;/li&gt;
&lt;li&gt;a controller starts calling repositories directly&lt;/li&gt;
&lt;li&gt;architecture rules slowly fall apart&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;PHPStan is great — but enforcing &lt;em&gt;custom rules like this&lt;/em&gt; is not trivial.&lt;/p&gt;

&lt;p&gt;You either:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;write a custom PHPStan rule (time-consuming)&lt;/li&gt;
&lt;li&gt;or use something limited like banned functions&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  What I wanted
&lt;/h2&gt;

&lt;p&gt;I needed something that could:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;ban specific functions (&lt;code&gt;var_dump&lt;/code&gt;, &lt;code&gt;dd&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;restrict certain method calls&lt;/li&gt;
&lt;li&gt;enforce architecture boundaries&lt;/li&gt;
&lt;li&gt;be configurable without writing PHP code&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  The solution
&lt;/h2&gt;

&lt;p&gt;I built a small PHPStan extension that lets you define forbidden patterns:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;parameters:
  forbidden_node:
    nodes:
      - type: Expr_FuncCall
        functions: [var_dump, dd]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now PHPStan reports:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Forbidden function var_dump() used in App\Service\UserService.php:42
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Why this is useful
&lt;/h2&gt;

&lt;p&gt;You can enforce rules like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;❌ no debug functions in production&lt;/li&gt;
&lt;li&gt;❌ no direct DB calls in controllers&lt;/li&gt;
&lt;li&gt;❌ no cross-layer violations&lt;/li&gt;
&lt;li&gt;❌ no unsafe patterns&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Repo
&lt;/h2&gt;

&lt;p&gt;👉 &lt;a href="https://github.com/rajmundtoth0/phpstan-forbidden-nodes" rel="noopener noreferrer"&gt;https://github.com/rajmundtoth0/phpstan-forbidden-nodes&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Curious how others handle this — do you enforce rules like this in your projects?&lt;/p&gt;

</description>
      <category>php</category>
      <category>laravel</category>
      <category>phpstan</category>
      <category>ast</category>
    </item>
  </channel>
</rss>
