<?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: RVxLab</title>
    <description>The latest articles on DEV Community by RVxLab (@rvxlab).</description>
    <link>https://dev.to/rvxlab</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%2F523358%2Fed23b5c6-81b1-4ca9-b699-3ae3dc0d0377.png</url>
      <title>DEV Community: RVxLab</title>
      <link>https://dev.to/rvxlab</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rvxlab"/>
    <language>en</language>
    <item>
      <title>My opinion on the PHP 8.1 Enum RFC</title>
      <dc:creator>RVxLab</dc:creator>
      <pubDate>Sat, 30 Jan 2021 13:16:09 +0000</pubDate>
      <link>https://dev.to/rvxlab/my-opinion-on-the-php-8-1-enum-rfc-1dkf</link>
      <guid>https://dev.to/rvxlab/my-opinion-on-the-php-8-1-enum-rfc-1dkf</guid>
      <description>&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;p&gt;The basic and backed enums of this RFC are a nice implementation of enums in PHP, but in its current form it simply does too much.&lt;/p&gt;

&lt;h2&gt;
  
  
  Foreword
&lt;/h2&gt;

&lt;p&gt;Yesterday Brendt from Spatie posted &lt;a href="https://stitcher.io/blog/new-in-php-81"&gt;a blog post about new things in PHP 8.1&lt;/a&gt;. The one things that caught my eye was enums and since I've been wanting them in PHP for quite a while now I got a bit excited to say the least.&lt;/p&gt;

&lt;p&gt;Reading &lt;a href="https://wiki.php.net/rfc/enumerations"&gt;the RFC&lt;/a&gt; started good and well but the further I went, the more I disliked it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Basic enums
&lt;/h2&gt;

&lt;p&gt;The basic enum implementation of this RFC looks like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="n"&gt;enum&lt;/span&gt; &lt;span class="nc"&gt;Suit&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nc"&gt;Hearts&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nc"&gt;Diamonds&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nc"&gt;Clubs&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nc"&gt;Spades&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using &lt;code&gt;case&lt;/code&gt; to denote an enum value is slightly odd, but I'll take it. If it would be possible I believe it'd be better to omit this all together:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="n"&gt;enum&lt;/span&gt; &lt;span class="nc"&gt;Suit&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nc"&gt;Hearts&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nc"&gt;Diamonds&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nc"&gt;Clubs&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nc"&gt;Spades&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Backed enums
&lt;/h2&gt;

&lt;p&gt;Backed enums very much remind me of enums in TypeScript which are incredibly useful. Having this in PHP is very nice indeed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="n"&gt;enum&lt;/span&gt; &lt;span class="nc"&gt;Suit&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nc"&gt;Hearts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'H'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nc"&gt;Diamonds&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'D'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nc"&gt;Clubs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'C'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nc"&gt;Spades&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'S'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This feature alone would likely cause me to drop &lt;a href="https://github.com/myclabs/php-enum"&gt;myclabs/php-enum&lt;/a&gt; as my enum implementation.&lt;/p&gt;

&lt;h3&gt;
  
  
  No mixing
&lt;/h3&gt;

&lt;p&gt;Backed enums and Basic (or Pure) enums cannot be mixed together, so something like this is not allowed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="n"&gt;enum&lt;/span&gt; &lt;span class="nc"&gt;Suit&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nc"&gt;Hearts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'H'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nc"&gt;Diamonds&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'D'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nc"&gt;Clubs&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nc"&gt;Spades&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I completely agree, otherwise it would just turn into a giant mess.&lt;/p&gt;

&lt;h2&gt;
  
  
  Enum methods
&lt;/h2&gt;

&lt;p&gt;This is the point where the RFC lost me. I understand that having methods in an enum. Hell, in some cases I add a &lt;code&gt;random()&lt;/code&gt; method in enum classes made with &lt;code&gt;myclabs/php-enum&lt;/code&gt;. But that's usually as far as I'm willing to go.&lt;/p&gt;

&lt;p&gt;If you need to add an interface or trait to an enum, why not just use a class instead?&lt;/p&gt;

&lt;p&gt;The examples list extra information you can list with an enum, but doesn't that just beat the whole point of making enums to begin with?&lt;/p&gt;

&lt;h2&gt;
  
  
  Closing thoughts
&lt;/h2&gt;

&lt;p&gt;I'd be incredibly happy if this RFC got accepted, enums are something that PHP can really use. Unfortunately, this implementation just does too much and it wouldn't surprise me if it got rejected on that basis.&lt;/p&gt;

&lt;p&gt;However, should it be accepted, I'll be unlikely to use those enum methods.&lt;/p&gt;




&lt;p&gt;Thanks for reading. This was my first proper post on this site and I'd like to improve my writing skills.&lt;/p&gt;

&lt;p&gt;Any feedback on this post is greatly appreciated.&lt;/p&gt;

</description>
      <category>php</category>
      <category>rfc</category>
      <category>php81</category>
    </item>
    <item>
      <title>Dealing with 100vh on iOS Safari in TailwindCSS</title>
      <dc:creator>RVxLab</dc:creator>
      <pubDate>Fri, 22 Jan 2021 11:32:33 +0000</pubDate>
      <link>https://dev.to/rvxlab/dealing-with-100vh-on-ios-safari-in-tailwindcss-49la</link>
      <guid>https://dev.to/rvxlab/dealing-with-100vh-on-ios-safari-in-tailwindcss-49la</guid>
      <description>&lt;p&gt;Recently I've been needing to develop for iOS Safari, in which I found out that &lt;a href="https://stackoverflow.com/a/37113430"&gt;100vh is not quite 100vh on there&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Now, there are fixes for this. Namely by using &lt;code&gt;height: -webkit-fill-available&lt;/code&gt;, &lt;a href="https://allthingssmitty.com/2020/05/11/css-fix-for-100vh-in-mobile-webkit/"&gt;as demonstrated here&lt;/a&gt;. This however has the unfortunate side effect of also targetting Chromium-based browsers.&lt;/p&gt;

&lt;p&gt;To fix that you can check for the support of &lt;code&gt;-webkit-touch-callout: none&lt;/code&gt;. With that, only iOS and iPadOS Safari are targetted.&lt;/p&gt;

&lt;p&gt;In order to make this much easier to use in Tailwind I created a plugin for it.&lt;/p&gt;

&lt;p&gt;You can find the plugin here: &lt;a href="https://www.npmjs.com/package/@rvxlab/tailwind-plugin-ios-full-height"&gt;https://www.npmjs.com/package/@rvxlab/tailwind-plugin-ios-full-height&lt;/a&gt;&lt;/p&gt;

</description>
      <category>showdev</category>
      <category>css</category>
      <category>node</category>
    </item>
  </channel>
</rss>
