Earlier quoted context omitted.
Is there some browser flag that disables custom scrollbars? Surely its a problem for accessibility.
In Firefox's about:config you can set layout.css.scrollbar-width.enabled to false.
Modern PHP Cheat Sheet
51–60 of 127 posts
Re: Modern PHP Cheat Sheet
#52Earlier quoted context omitted.
We do indeed create full blown classes for data objects. However, it is made easier with PHP 8.0 and 8.1 (released today). Typed properties, constructor properties, and Read-only properties can significantly reduce the code bloat. - https://php.watch/versions/8.0/constructor-property-promotio... - https://php.watch/versions/8.1/readonly
Can you directly cast an object / assoc array to an instance of such a class? If I have a function that receives eg a Message , it means an instance of the class right? So somehow my assoc.array/object still needs to be instanced, and if I do just $message = new Message($theData) … it doesn’t auto assign properties right? That would be handy though still very much boilerplate. I guessthe language is just designed for…
Re: Modern PHP Cheat Sheet
#53As a JS dev it’s nice to see php imitate some newer js syntax like nullish coalescing, arrow function, … helps me to switch between the languages. It really needs a way to declare type of small data structures though, in a very concise way (no class boilerplate, for performance eg. going through 10000’s of entities). PS : on the other hand I’m starting to dislike how languages become "designed by committee", and lose…
Re: Modern PHP Cheat Sheet
#54I've never understood why some programmers like to use ligatures, especially on a cheat sheet like this, which will be used primarily by people who aren't familiar with the syntax. It's not 'a' ⇒ 1, it's 'a' => 1, just write it out the correct way. Why are you trying to be fancy?
Re: Modern PHP Cheat Sheet
#55As a JS dev it’s nice to see php imitate some newer js syntax like nullish coalescing, arrow function, … helps me to switch between the languages. It really needs a way to declare type of small data structures though, in a very concise way (no class boilerplate, for performance eg. going through 10000’s of entities). PS : on the other hand I’m starting to dislike how languages become "designed by committee", and lose…
JavaScripts nullish coalescing operator landed in chrome 80 (feb 2020) over 5 years later… more like it’s PHP syntax landing in JS land.
Re: Modern PHP Cheat Sheet
#56And I've been loving all the new additions to PHP over the last few years as well. Version 5 was rather limited but since 7 it has grown into an actual programming language for which I feel I don't have to apologize for.
Re: Modern PHP Cheat Sheet
#57Earlier quoted context omitted.
Can you directly cast an object / assoc array to an instance of such a class? If I have a function that receives eg a Message , it means an instance of the class right? So somehow my assoc.array/object still needs to be instanced, and if I do just $message = new Message($theData) … it doesn’t auto assign properties right? That would be handy though still very much boilerplate. I guessthe language is just designed for…
It's not clear to me what you're looking for. But you can cast arrays to objects. And you can use type declarations as arguments for functions.
class Foo {
public function __construct(string $name, array $options)
{
$this->name = $name;
if ($options->enableFlag) { ...
I want to declare what $options are, in TS I could do:type TFooOptions = { enableFlag: boolean; userIds: number[]; }
Then
function __construct(string $name, TFooOptions $options) ...
Otherwise how do I get proper typechecking if the IDE doesn't know what $options are?Re: Modern PHP Cheat Sheet
#58I'm using Laravel/PHP for a new project and it's been a joy . A true joy. After spending the last 6+ years writing backend services in Node, PHP feels like a breath of fresh air. No restarting the server, no compiling errors from babel/typescript wackiness, no blocking threads, server-side templates out-of-the-box, and so much more. PHP has come a really long way, I really hope to see it's resurgence some day after e…
It's so nice to see a comment giving PHP the praise it deserves. Honestly, PHP is a good, if not great, language to use for building solid web apps fast. People seem to love to hate it because it's the "cool" thing to do. Yet PHP developers continue to ship things faster, while JS devs are probably still fiddling with their Node environment setup...
While I agree with this, I think the tone is slightly dismissive. From what I have seen, older people in our trade seem to recommend against PHP due to it having a terrible relationship with consistency, functionality, performance, etc. in its history. Though I have (thankfully) seen that the language and its standard library has undergone several large improvements, which is great to hear.
> Yet PHP developers continue to ship things faster, while JS devs are probably still fiddling with their Node environment setup...
On your point of JavaScript, the build environment nonsense can definitely get hairy. It's why we get things like Deno, which attempt to throw all this cruft away and start again. And sometimes that's a good idea. If you're dedicated to Node, replacing Webpack with Rollup seems to be what is generally recommended. The only obvious disadvantage there is compatibility with Webpack plugins.
It would be nice to have a type-checked JavaScript variant with a practically non-existent build environment (no Webpack, Rollup, etc.) As much as I adore TypeScript, the compiler itself is massive and takes quite a long time to even start.
Re: Modern PHP Cheat Sheet
#59PHP should have chosen to undergo a rebranding a few years ago, if you ask me. The stigma it has to deal with is probably unsurmountable and will be forever. If you think PHP, you think WordPress and Joomla, and that means "hacks and vulnerabilities"...
It's a good language nowadays, with quirks like any other language, but I still have one big problem with it: There are too many "PHP developers" out there, and most of them are very bad, and many of the good ones are from poor regions in the world and you can find them on Fiverr doing kick-ass work for a grand total of $50.
Re: Modern PHP Cheat Sheet
#60A Reddit post from a few years ago explains pretty well why PHP has such a terrible reputation: https://www.reddit.com/r/webdev/comments/5tqoqa/web_devs_wha... PHP should have chosen to undergo a rebranding a few years ago, if you ask me. The stigma it has to deal with is probably unsurmountable and will be forever. If you think PHP, you think WordPress and Joomla, and that means "hacks and vulnerabilities"... It's a…