@cabbey@phpc.social avatar

cabbey

@cabbey@phpc.social

sourcerer @ SmugMug, photo geek, dad, licensed rocket scientist (L2 w/ NAR and Tripoli).

This is MY stream of consciousness. I don’t speak for my employer, club, or hobby.

Fiscally conservative, socially liberal; he/him

This profile is from a federated server and may be incomplete. Browse more on the original instance.

ramsey, to php
@ramsey@phpc.social avatar

I’m about to do something that could either be very controversial or not controversial at all and result in a bunch of shrugs and nods.

cabbey,
@cabbey@phpc.social avatar

@ramsey gunna use a goto in production code?

ian, to random
@ian@phpc.social avatar

I hear RISC is good

cabbey,
@cabbey@phpc.social avatar

@kboyd @ian Power (PC) to the people!

cabbey, to php
@cabbey@phpc.social avatar

ok folks, you were right Rector is pretty cool. The learning curve is steep AF, and the docs are, well, let's just say they're written by engineers for engineers. But given the target audience for this tool, that's OK. I've not yet done the changes I was originally asking about with it, because the config for it is going to be a PITA to build. I've been starting small. But what I've done so far has been pretty cool! I've done some wild things with RenameClassConstFetchRector for example. 🧵

cabbey,
@cabbey@phpc.social avatar

BUT... this brings me to two questions that don't seem obvious from the docs and sources. 1. as a result of moving some consts from one class to another, I now have a lot of files that went from 1 long use SomePackage\Name\Space\Here\To\AClass; and a ton of AClass::SomeConst to a lot of files with an unused import and a ton of very long fully qualified consts sprinkled through the code. Has anyone seen a rector to collapse frequently used namespaces into a use statement?

cabbey,
@cabbey@phpc.social avatar

AAHHHH... because it's not a Rector it's just a config option... ->withImportNames()

but that changes everything not just the things it touches... which ... omg ..... just no. (2000 files touched just by changing that setting.)

cabbey,
@cabbey@phpc.social avatar

@shudder no… 2000+ files that it touched to change “class Yada implements \NameSpace\Foo\Bar\SoupInterface” to “use \NameSpace\Foo\Bar\SoupInterface;
class Yada implements SoupInterface”

The vast majority of our codebase only imports the class if it’s used more than once in the file… this just undid that globally for two big classes of use cases: implementing interfaces and trait usage.

The actual changes I had been making in rector.php only impacted a couple dozen files.

cabbey,
@cabbey@phpc.social avatar

@alessandrolai @shudder yeah, played with them to not much improvement. Currently thinking I’ll do a two pass approach. First use the renaming rectors I’ve configured against the whole codebase, then got diff to get the list of changes files and run a separate rector on just those files with this option. Will experiment with that in the morning.

cabbey, to ubuntu
@cabbey@phpc.social avatar

Anyone know how long it usually is between a release going GA and do-release-upgrade seeing it? Seems odd that I could download and burn the iso and do an upgrade with that, but can't do it from within the system yet.

cabbey,
@cabbey@phpc.social avatar

@Crell yeah, just trying to get a feel for how long the stagger is. But also meh… it’s not a lot of data, and it’s CDN’d pretty hard.

cabbey, to php
@cabbey@phpc.social avatar

ok brain trust.... say you wanted to automate some code changes. Simple stuff like "find all the instance methods that call self::staticFoo() and change them to call $this->foo() instead"... what static analysis tool would be the first one you would reach for to do that? Before anyone says "a grep and perl pies pipeline" note that static methods that call self::staticFoo() must remain as is. Next up would be "find all the places ->info['foo'] is read and replace it with ->getInfoFoo()."

afilina, to random
@afilina@phpc.social avatar

Shout out to league/csv for continuing to be an awesome library. It's intuitive, a breath of fresh air after a long week of fighting every single tool. This one doesn't fight you. It just helps you without getting in the way.

cabbey,
@cabbey@phpc.social avatar

@afilina oooh! I didn't know this package existed. I think pretty much every package from The League I've used has fit this description though, so that's a good sign. Sadly, after looking at it's docs, it doesn't even attempt to solve the biggest problem I think @kboyd and I see with writing csv files... managing the column positions when you have variable data. :(

cabbey,
@cabbey@phpc.social avatar

@afilina @kboyd say you have 50 columns... say 40 of them are populated in every row, but the other 10 you get some random subset (depending on what the other values maybe, you may have 10 of them or you may have 3 of them or somewhere between.) Then say you have another 6 or so columns that get added for certain customers but not for others.
It would be awesome if you could give it a header array and then pass in a hash for the row and have it populate just the ones that are set.

cabbey,
@cabbey@phpc.social avatar

@kboyd @afilina or a patch to add it if they're open to it.

cabbey,
@cabbey@phpc.social avatar

@afilina @kboyd ahh... I must have misunderstood what formatters could do... I thought they were processed cell by cell. If they get the whole record then yeah, that would probably work.

andrewfeeney, to php
@andrewfeeney@phpc.social avatar

and folks, what do you make of this?

https://youtu.be/kQdRT2odUIk

cabbey,
@cabbey@phpc.social avatar

@valorin @bobmagicii @j3j5 eh, I dunno... this was my first exposure to him as well and frankly the fact that he called utf-8 "the encoding for English" basically put me into "lol, no." mode and closed the tab,. Thank you @andrewfeeney for the direct CVE link.

cabbey,
@cabbey@phpc.social avatar

@valorin @mergy @bobmagicii @andrewfeeney distros should be able to just land a new, patched, module. The only reason there are manual steps here is the attempt to work around the fixed binary not being available. for example seems to have already dropped a fix: https://ubuntu.com/security/notices/USN-6737-1

cabbey,
@cabbey@phpc.social avatar

@bobmagicii oh yeah, there's certainly something to be said for being able to just ssh into a box, boot the encoding out of the support list and rebuild the iconv catalogs. :)

cabbey,
@cabbey@phpc.social avatar

@andrewfeeney @arnan @valorin @mergy we don’t know yet.

But assumed worst case: there is some magic string that if they can get your web server to spit it out, in that encoding, can be used to dump anything php has access to… or run any arbitrary assembly… as your php user.

There are probably a dozen lesser degrees too.

Disclaimer: I’m not a security researcher either… it’s been 20+ years since I sat down and crawled through any code looking for malicious ways to abuse it.

grmpyprogrammer, to random
@grmpyprogrammer@phpc.social avatar

Making my traditional stop at Cracker Barrell

cabbey,
@cabbey@phpc.social avatar

@grmpyprogrammer ooh, they still exist? All the ones out here closed last year.

cabbey, to php
@cabbey@phpc.social avatar

Does anyone have a better way to write the conditional calls to foo at lines 5-9 of this code? https://3v4l.org/fqCvv The goal is to have the default argument for bar trigger the default argument for foo, but they're different defaults (since one is nullable and the other isn't), and bar should not need to know what foo's default is. (obviously in my real code it's a much more complex signature, and separate classes.)

cabbey,
@cabbey@phpc.social avatar

@Girgias not sure I follow how that would help?

cabbey,
@cabbey@phpc.social avatar

@Girgias ooh, yeah. I thought you meant down a level in foo. That's easy enough to determine if the flag is null that I don't think this is helpful. Also I'll note that in the real code, due to multiple named optional parameters it's a bit more complex: https://3v4l.org/PfBe4

cabbey,
@cabbey@phpc.social avatar

@Crell honestly mostly trying to avoid having two copies of the call to foo() in an if/else with different argument lists. (way more obvious why in the real case with more params to foo.)
It really boils down to "this library allows you to specify an old format version and defaults to it's current one, which is an internal detail." vs "this function lets you specify the version of the object you're dealing with, in case you need to use an old object from storage"

cabbey,
@cabbey@phpc.social avatar

@Girgias yeah, certain Obj-C library programmers really love that trick too. I recall an entire library for doing graphics that had functions like drawLine() which took 100 named variables, because you could specify points with x/y coords or with angle (as degrees or radians) and distance, or with a data class called a Point, then the other end could be specified with all sorts of different approaches including both absolute and relative offset from the start. Ugh. So glad doesn't do that!

cabbey,
@cabbey@phpc.social avatar

@Crell I was a Java developer for several years, I still cringe every time I resort to using reflection (all in tests, never in production code!) because of the memories of just how painful the performance penalties were back then.

I just started the PR with the "assemble an array and spread it" approach. I suspect it won't be received with torches and pitchforks.

cabbey,
@cabbey@phpc.social avatar

@ramsey @gmazzap yeah, as I discussed with crell in another branch of the thread the root issue was avoiding two calls to foo in a conditional with a long argument list. The solution I put into PR Friday assembles an argument array, conditionally adds the one discussed here then calls foo(…$args);

  • All
  • Subscribed
  • Moderated
  • Favorites
  • Leos
  • mdbf
  • Youngstown
  • ngwrru68w68
  • ethstaker
  • slotface
  • PowerRangers
  • hgfsjryuu7
  • khanakhh
  • kavyap
  • tsrsr
  • InstantRegret
  • DreamBathrooms
  • tacticalgear
  • normalnudes
  • magazineikmin
  • rosin
  • GTA5RPClips
  • thenastyranch
  • Durango
  • osvaldo12
  • vwfavf
  • cubers
  • everett
  • modclub
  • cisconetworking
  • tester
  • anitta
  • All magazines