[–] [S] 2 points 6 months ago

Thank you for your kind words, the feelings are mutual - you were definitely one of the bright sides on Lemmy.

I currently need a break from Lemmy but if I ever come back, your instance is definitely the one I'll be joining.

Thank you as well, you were always helpful on Matrix and I really appreciate it.

  • source
  • parent
  • context
  • [–] [S] 11 points 8 months ago (1 child)

    Can't say I have one, as that was pretty much the niche (freedom of speech where you're allowed to say anything as long as it's not illegal or hurting other people) I tried to fill because it was empty. Haven't really checked newer instances, so don't know if there's one with similar mindset.

  • source
  • parent
  • context
  • [–] [S] 4 points 8 months ago (4 children)

    Ain't that the truth! As someone who's center-left for the most part, I feel that every day.

    But my real issue is pretty much that Lemmy has almost no other content besides political one - I'm fine not fitting in with the online masses politically but I kinda can't find anything else to do on here.

  • source
  • parent
  • context
  •  

    Hey there everyone!

    It's been a nice run, but all good things come to an end as they say.

    This nice thing comes to an end on Jul 2nd, 2026 which is when the domain expires and I've decided to not renew it.

    It's been a nice run and I'm grateful to all the active users of our small Fediverse home!


    click here if you're interested in the reasonAs for the reason for this decision, it's because Lemmy and the Threadiverse in general didn't turn out into what I envisioned it would be.

    For a hot minute it was honestly great but eventually all that remained was tankies propaganda and depressing news. And probably a few non-political communities that sadly don't really offset it for me.

    I was pondering on keeping it running even if I don't really use it that much anymore, but then Hetzner announced a significant price change (and you can bet that Lemmy is an unoptimized resource hog) which is not the reason on its own, but the proverbial last straw.


    So yeah, that's it I guess. I promised that if the instance ever goes down, I'll let everyone know with enough time and I believe I managed to do it.

    I'll maintain the instance until it expires and I'll keep on moderating it of course but it's probably a good time to start looking for a new Threadiverse home.


    Yet again, thank you very much to everyone who has been part of this instance! And to many of the friendly admins of other instances!

    [–] 0 points 9 months ago (9 children)

    Nope, I treat reports as confidential. Well, "every time" was a bit of an exaggeration, cause I mostly get spam or "I disagree with this so I report it" reports, but astro turfing does happen multiple times a month.

  • source
  • parent
  • context
  •  
    • You can't post anything that's illegal in Germany or Czechia
    • All NSFW posts must be tagged NSFW
    • No hate groups promotion and no hate speech
    • You can create any community you want (even NSFW) as long as it complies with the above rules
    • No disinformation spreading

    I hope I don't have to specify individual items (for example, racism is part of "no hate speech", child porn is part of illegal stuff and so on).

     

    cross-posted from: https://chrastecky.dev/post/24

    Changing a Readonly Property

    So, you know how readonly properties are, well… read-only? Turns out they’re not!

    I stumbled upon this mechanism just as PHP started deprecating it — but hey, if you ignore the deprecation warnings, you can still use it up until PHP 9!

    A bit of theory first: readonly properties can only be assigned inside a class constructor. After that, they’re supposed to be immutable.

    final readonly class ReadonlyClass
    {
        public string $someProp;
    
        public function __construct()
        {
            $this->someProp = 'unchangeable!';
        }
    }
    
    

    The only official way to set such a property outside the constructor is via reflection — but even then, only if the property hasn’t been initialized yet:

    final readonly class ReadonlyClass
    {
        public string $someProp;
    }
    $test = new ReadonlyClass();
    $reflection = new ReflectionClass(ReadonlyClass::class)->getProperty('someProp');
    $reflection->setValue($test, 'changed once!');
    var_dump($test->someProp);
    $reflection->setValue($test, 'changed twice?');
    

    This produces the predictable result:

    string(13) "changed once!"
    
    Fatal error: Uncaught Error: Cannot modify readonly property ReadonlyClass::$someProp
    

    Changing It Multiple Times

    Enough stalling — let’s dive in! The magical object that can modify a readonly property (and much more) is ArrayObject.

    Normally, you’d use ArrayObject to wrap an array. But it also accepts any object as the backing value — and that’s where the fun begins. Once you know how PHP stores properties internally (which is actually pretty simple), chaos follows.

    Let’s start with this class:

    final readonly class ReadonlyClass
    {
        public string $someProp;
        private string $somePrivateProp;
        protected string $someProtectedProp;
    
        public function __construct()
        {
            $this->someProp = 'unchangeable?';
            $this->somePrivateProp = 'unchangeable?';
            $this->someProtectedProp = 'unchangeable?';
        }
    
        public function getSomePrivateProp(): string
        {
            return $this->somePrivateProp;
        }
    
        public function getSomeProtectedProp(): string
        {
            return $this->someProtectedProp;
        }
    }
    

    Now we create an instance and wrap it in an ArrayObject:

    $instance = new ReadonlyClass();
    $arrayObj = new ArrayObject($instance);
    
    

    And now comes the fun part:

    // simply use the property name for public properties
    $arrayObj['someProp'] = 'changeable public!';
    // use "\0[FQN]\0[Property name]" for private properties
    $arrayObj["\0ReadonlyClass\0somePrivateProp"] = 'changeable private!';
    // use "\0*\0[Property name]" for protected properties
    $arrayObj["\0*\0someProtectedProp"] = 'changeable protected!';
    
    var_dump($instance->someProp, $instance->getSomePrivateProp(), $instance->getSomeProtectedProp());
    

    This prints:

    string(18) "changeable public!"
    string(19) "changeable private!"
    string(21) "changeable protected!"
    

    And just like that, you’ve changed an unchangeable property. You can modify it as many times as you want. So… what other arcane tricks are possible?

    Changing an Enum Value

    Enums are basically fancy objects that represent a specific named instance — optionally with a value. The key difference from old userland implementations is that PHP guarantees every enum case is a unique instance that’s always equal to itself, no matter where it’s referenced from.

    In other words, an enum is really just a class, and ->value or ->name are plain properties.

    enum MyEnum: string {
        case A = 'a';
        case B = 'b';
    }
    
    $arrayObj = new ArrayObject(MyEnum::A);
    $arrayObj['value'] = 'b';
    $arrayObj['name'] = 'C';
    
    var_dump(MyEnum::A->value);
    var_dump(MyEnum::A->name);
    

    This prints exactly what you’d expect after reading the previous examples:

    string(1) "b"
    string(1) "C"
    

    Even more amusing: Running var_dump(MyEnum::A); now prints enum(MyEnum::C).

    It won’t actually make it equal to another enum case, but if you use the value somewhere and reconstruct it using MyEnum::from(), you’ll get back MyEnum::B.

    If you try to serialize and deserialize it, you’ll get an error — because MyEnum::C doesn’t exist:

    var_dump(MyEnum::from(MyEnum::A->value));
    var_dump(unserialize(serialize(MyEnum::A)));
    

    The first prints enum(MyEnum::B), while the second throws a warning: Undefined constant MyEnum::C.

    Breaking Types

    ArrayObject is so powerful that even the type system trembles before it. Types? Mere suggestions!

    final class TestTypedClass
    {
        public string $str = 'test';
        public bool $bool = true;
        public int $int = 42;
    }
    
    $instance = new TestTypedClass();
    $arrayObj = new ArrayObject($instance);
    
    $arrayObj['str'] = 5;
    $arrayObj['bool'] = 'hello';
    $arrayObj['int'] = new stdClass();
    
    var_dump($instance->str, $instance->bool, $instance->int);
    

    Output:

    int(5)
    string(5) "hello"
    object(stdClass)#3 (0) {
    }
    

    So if you ever thought “Hmm, this boolean could really use more than two possible values” — now you know how!

    Dynamic Properties Everywhere

    Some internal classes like Closure, Generator, and DateTime disallow dynamic properties. Nevermore!

    $closure = fn () => true;
    $arrayObject = new ArrayObject($closure);
    $arrayObject['test'] = 'hello';
    
    var_dump($closure->test);
    // prints string(5) "hello"
    

    Crashing PHP

    And finally — my favourite one! Ever wanted to cause a segmentation fault? Try this:

    $exception = new Exception("Hello there!");
    $arrayObject = new ArrayObject($exception);
    $arrayObject["\0Exception\0trace"] = -1;
    
    var_dump($exception->getTraceAsString());
    

    That gave me one beautiful Segmentation fault (core dumped)!

    So, how did you like these all-powerful ArrayObject shenanigans?

     

    cross-posted from: https://chrastecky.dev/post/16

    Starting with PHP 8.5, you'll be able to do the following:

     public function __construct(
        final public string $someProperty,
    ) {}
    

    This wasn't possible before, as promoted properties couldn't be declared final.

    Perhaps the more interesting part is that you can now omit the visibility modifier if you include final. In that case, the property will default to public:

     public function __construct(
        final string $someProperty, // this property will be public
    ) {}
    

    Personally, I’m not a fan of this behavior — I prefer explicit over implicit. Fortunately, it can be enforced by third-party tools like code style fixers. Still, I would have preferred if the core required the visibility to be specified.

    What do you think? Do you like this change, or would you have preferred a stricter approach?

    view more: next ›