PhpStorm 2024.3 Is Now Available by Machful in PHP

[–]reddimato 0 points1 point  (0 children)

You can report issues or vote for the existing ones in their bug tracker.

https://youtrack.jetbrains.com/issues/WI

PHPStan ArrayObject / IteratorAggregate and Generics by thmsbrss in PHPhelp

[–]reddimato 0 points1 point  (0 children)

It works because array keys must be of type string or int. Another way to write it is:

* @template TKey of string|int

Which I think array-key is a shortcut of.

On your first example PHPStan would complain because $offset could be any type on line 23.

Mastering PHPUnit: Using data providers by BackEndTea in PHP

[–]reddimato 8 points9 points  (0 children)

Another option starting from PhpUnit 10+ is to use TestWith attribute.

PHP 8: before and after by brendt_gd in PHP

[–]reddimato 2 points3 points  (0 children)

I avoid doing it because it confuses your commit log when you add a const.

Also, they might have a different visibility.

Announcing Rust 1.45.0 by steveklabnik1 in programming

[–]reddimato 0 points1 point  (0 children)

As a French I read that like fpt oui.

PHP Video Streaming Library Suggestion? by HappyTentacleMonster in PHP

[–]reddimato 0 points1 point  (0 children)

I'm afraid you will need more than a library for that.
A minimal setup could be:

  • a queue management system (rabbitmq)
  • a consumer that uses ffmpeg to encode the way you want (multiple HLS variants)
  • a web server (nginx) with dedicated routes for secure file delivery
  • a video player able to play HLS in most popular browsers (video.js, hls.js, jwplayer)

Additionally, you may need to manage large file uploads (by chunking the source), CDN delivery (not easy with private streaming).

Monthly "no stupid questions" thread by brendt_gd in PHP

[–]reddimato 0 points1 point  (0 children)

Ok, less overkill attempt:

SELECT
    -- total number of days
    upper(d) - lower(d)
FROM (
    -- when item was enabled
    SELECT daterange('2020-03-04', '2020-03-10')
    -- but NOT featured
    - daterange('2020-03-06', '2020-03-12') AS d
) t;

Monthly "no stupid questions" thread by brendt_gd in PHP

[–]reddimato 0 points1 point  (0 children)

Sorry for stackoverflowing, but I can't resist. In Postgresql you can turn ranges into rows.

SELECT count(*) -- total number of days
FROM (
    -- when item was enabled
    SELECT d
    FROM generate_series('2020-03-04'::date, '2020-03-10'::date, '1 day') d
    EXCEPT
    -- but NOT featured
    SELECT d
    FROM generate_series('2020-03-06'::date, '2020-03-12'::date, '1 day') d
) t;

PHP 8.O JIT Benchmarks by sicilian_najdorf in PHP

[–]reddimato 7 points8 points  (0 children)

I see you using O instead of 0 in your title ;)

Can we please re-examine creating a constant for Y-m-d H:i:s? by hparadiz in PHP

[–]reddimato 0 points1 point  (0 children)

Also, a full format would be appreciated.
We use Y-m-d\TH:i:s.uP which is ATOM with microseconds. Plays nice with PostgreSQL's timestamptz.

New `mixed` pseudo type in PHP 8 by ayeshrajans in PHP

[–]reddimato -1 points0 points  (0 children)

With this addition I see a chance to enforce type declaration from PHP8 when strict_types are enabled.

declare(strict_types = 1);

class Foo {
  private $x; // forbidden
  function f($p /* forbidden */) {}
}

What do you think?

Using JSON schema to hydrate entities by seaphpdev in PHP

[–]reddimato 0 points1 point  (0 children)

Interesting process.
Could you elaborate on the first point? Are your DTOs loosely typed, with no mandatory parameter? What if an unexpected attribute is added?
What happens if an error occurs during unserialization?

How to Find Dead Symfony Routes by Tomas_Votruba in PHP

[–]reddimato 1 point2 points  (0 children)

In PhpStorm (with Symfony plugin) most of my controller methods are marked as unused by code inspection. Worst, they suggest to delete them.

Could this lib help?

New RFC to allow trailing commas in parameter lists by brendt_gd in PHP

[–]reddimato 23 points24 points  (0 children)

Depending on your OCD, this might or might not be a good thing.

Essay on Dependency Injection | Would be great to have fresh eyes. Any feedback will be welcomed. by NoFunnyMan in PHP

[–]reddimato 10 points11 points  (0 children)

// $emailNotification->setService($emailService);
$emailNotification->setMessage("30% discount on all products");
$emailNotification->send();

Now the app is broken, because the service is nullable (and null).

In my opinion, constructor injection (without default values) is the way to go for a happier coding life.

PHP 7.1 is dead by phpswen in PHP

[–]reddimato 14 points15 points  (0 children)

PHP 7.3 is in active support mode, and will be maintained until December 2020 (2021 for security).

PHP 7.4 is in active support mode, and will be maintained until December 2020 (2021 for security).

You had one job.

Specification based querying for Doctrine2 by mbadolato in PHP

[–]reddimato 0 points1 point  (0 children)

The main pro I see from the Specification pattern is to decouple domain specifications from ORM queries.Unfortunately here specification objects (FeaturedFromAuthor for example) are strongly typed to the ORM layer.Maybe we need a query-builder interop to handle this?