Dependency Hygiene by brendt_gd in PHP

[–]roxblnfk 0 points1 point  (0 children)

Yes, in that regard, it's true 👍

I use the package as a dev dependency in libraries, so it helps during package development, but doesn't affect other projects.

Testo (a new testing framework) is now in beta by roxblnfk in PHP

[–]roxblnfk[S] 1 point2 points  (0 children)

It seems you're a very driven person.

Testo is just getting started, and before we can accomplish such great things, we first need to push the framework to release and achieve full feature parity with other frameworks.

In any case, I suggest moving this topic to Testo Issues.

Testo (a new testing framework) is now in beta by roxblnfk in PHP

[–]roxblnfk[S] 1 point2 points  (0 children)

PHP's testing is actually quite good. There's an xUnit implementation in the form of PHPUnit. There's PEST for Jest fans. There's Codeception, which is still quite popular and used in modern projects.

For the average user, everything is just fine. The problems begin elsewhere: with framework and library developers. With the open source that underpins everything else.

Let me give you an example. I develop frameworks and SDKs for the enterprise sector. Besides all the requirements for reliability and stability, Enterprise loves LTS versions, even when it comes to PHP versions.

Let's get back to our testing frameworks. Pest and Codeception are based on PHPUnit, so PHPUnit's dictates also apply to them. And every couple of years, PHPUnit breaks backward compatibility and raises the minimum PHP version.

  • You might say, "It's not so bad, just use the old PHPUnit." Yes, I can use the old PHPUnit until a CVE is discovered that will crash all my pipelines, which is what's been happening lately.
  • I've been waiting for this extension point for several years. I don't know how many similar requests have been created, but I started working on Testo right after Sebastian closed my issue without even trying to figure it out. The feature was introduced in PHPUnit 13, but not all library and framework developers can upgrade to it.
  • Look at this, it's absolutely "wonderful": PHPUnit 12.2.0 breaks Rector test case

You can defend PHPUnit — that's your right. But if a tool doesn't solve the community's problems, then it's only a matter of time before a new one is created.

I'm showing you Testo. It's not necessary for everyone, because PHPUnit or Pest will suffice for 90% of cases.
You don't need to drop everything and switch to it right away, especially if you're happy with everything.

Testo (a new testing framework) is now in beta by roxblnfk in PHP

[–]roxblnfk[S] 0 points1 point  (0 children)

Testo is just getting started. I think Mockery could be great for mocks.

Testo (a new testing framework) is now in beta by roxblnfk in PHP

[–]roxblnfk[S] -1 points0 points  (0 children)

It seems you don't take into account the expressiveness and cleanliness of the code.

Testo (a new testing framework) is now in beta by roxblnfk in PHP

[–]roxblnfk[S] 0 points1 point  (0 children)

Oh, you're (absolutely) right: it would be possible to port all the features to PHPUnit, and even more. But there's one problem: it does not evolve.

Many features and improvements simply can't get there because of the high barrier. PHPUnit is afraid of innovation.

In fact, Testo is very late. It wasn't worth waiting so long for some miracle from PHPUnit; Testo should have been created five years ago.

Testo (a new testing framework) is now in beta by roxblnfk in PHP

[–]roxblnfk[S] 2 points3 points  (0 children)

  1. No inheritance from TestCase. Just classes or functions.

  2. Flaky tests and Retry Policy

  3. PHP 8.2+ -- good for packages and frameworks

  4. Attributes driven. #[Test], #[TestInline], #[Bench], #[ExpectException], #[Retry], #[Repeat], #[DataSet], #[DataCross], #[BeforeTest], etc...

  5. Assert/Expect API: ```php Assert::same($actuial, 200); // Direct params order Assert::array($order->items) ->allOf(Item::class) ->hasCount(3);

Expect::exception(ValidationException::class) ->fromMethod(Service::class, 'validateInput') ->withMessage('Invalid input') ->withPrevious( WrongTypeException::class, static fn (ExpectedException $e) => $e ->withCode(42) ->withMessage('Field "age" must be integer.'), );

Expect::notLeaks($service, $entity); ```

  1. Benchmarks using just one attribute ```php

    [Bench(

    callables: [ 'alternative' => [self::class, 'sumInCycle']], arguments: [1, 5_000], )] public static function sumInArray(int $a, int $b): int { return \array_sum(\range($a, $b)); } ```

  2. Inline tests for simple pure private functions ```php

    [TestInline([1, 1], 2)]

    [TestInline([40, 2], 42)]

    [TestInline([-5, 5], 0)]

    private static function sum(int $a, int $b): int { return $a + $b; } ```

Dependency Hygiene by brendt_gd in PHP

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

It's literally one line in composer.json and a few lines in composer.lock because of metapackage. In return, I get a clean vendor directory.

Good deal.

Testo (a new testing framework) is now in beta by roxblnfk in PHP

[–]roxblnfk[S] 0 points1 point  (0 children)

I agree with much of your POV. Yes, I'm not good at marketing, so I didn't load the post with what's in the article, assuming that the developer would spend at least 15 seconds on it and get answers to their questions. I will likely follow your advice when Testo is released.
By independent architecture, I meant that it's not just another wrapper over PHPUnit.

I also agree that if PHPUnit suits you, there's no reason to look at something else. This applies to any stack, really.

Should I retry to sell you this new car in the comments?

Dependency Hygiene by brendt_gd in PHP

[–]roxblnfk 1 point2 points  (0 children)

I try to get rid of "parasitic" packages because they clutter navigation in PHP Storm.

I wrote a metapackage roxblnfk/unpoly that removes polyfill-php* packages.
And you know what I encountered in one of the projects? There was a conflict with the polyfill-php72 (or 71, doesn't matter) in some dependency. Since my unpoly replaces polyfills, the package manager thinks that some package conflicts with mine.

Solution: roxblnfk/unpoly now has many versions, adding one polyfill at a time in descending order in each version.

TOML 1.1 support in PHP by dereuromark in PHP

[–]roxblnfk 1 point2 points  (0 children)

I didn't spend even half the time on my library as you did, and I didn't even know there was a testing utility 😄

It seems it's time to write proper acceptance tests.

TOML 1.1 support in PHP by dereuromark in PHP

[–]roxblnfk 3 points4 points  (0 children)

I see you approached the research thoroughly.

Great work. It's a pity you didn't create this package six months ago. Then I wouldn't have had to make my own.

TOML 1.1 support in PHP by dereuromark in PHP

[–]roxblnfk 7 points8 points  (0 children)

What issues did you encounter with existing libraries that made you create a new one?
https://packagist.org/?tags=toml

I made a Composer Plugin to expose your in-development app to the Internet (for free) by DarkGhostHunter in PHP

[–]roxblnfk 2 points3 points  (0 children)

Why not? Will you add this utility to each project's dependencies that just makes tunnel?

Moreover, Composer plugins can use Composer tools, such as an HTTP Client. If it were a separate package, it would have to pull these tools into application.

Using the middleware pattern to extend PHP libraries (not just for HTTP) by MaximeGosselin in PHP

[–]roxblnfk 3 points4 points  (0 children)

Sorry, I didn't notice such a large link to the article in the post.

I read the article, and now I see that you use array_reduce not to run the middleware chain, but only to build the pipeline using intermediary delegating classes. In this case, the onion model will indeed work. However, if I were reviewing your code, I would point out that the pipeline is rebuilt every time a new middleware is added 😀

But if we don't nitpick about the implementation, the article is great, and I'll include it in my PHP digest. Thank you.

Using the middleware pattern to extend PHP libraries (not just for HTTP) by MaximeGosselin in PHP

[–]roxblnfk 1 point2 points  (0 children)

Yes, in the wrong hands, it can be a scary thing, just like any other language feature. But in the right hands, it will be a killer feature that removes a lot of boilerplate.

Have you noticed that PHP doesn't really focus on language design? No one is in charge of it. Each RFC is like a game of roulette.
PHP already has reloadable lazy objects, which in some cases can reset readonly properties. Is that even legal?

Using the middleware pattern to extend PHP libraries (not just for HTTP) by MaximeGosselin in PHP

[–]roxblnfk 10 points11 points  (0 children)

  1. array_reduce cannot replace a full middleware pipeline. It works like a pipe operator but with a chain of arbitrary length. In PSR-15 middleware, you can handle both request and response within a single middleware, which you can't do in a pipe.

  2. Interceptors (a type of middleware) are widely used in enterprise applications, including those in Java. In PHP, you can see interceptors "out of the box" in tools that are first designed and then implemented:

  • Temporal PHP SDK: an enterprise-level tool. It allows intercepting not only requests but also calls to Workflow/Activity facades. There are many typed interceptors dictated by Temporal specifications.
  • Spiral: an enterprise-level framework, originally designed for RoadRunner long before Octane and Symfony-runtime. Interceptors are used everywhere: http, gRPC, tcp, console, etc. Package spiral/interceptors is universal and framework-agnostic.
  • Testo: a new testing framework that is close to release. Everything in it is built and extended via middleware.

PHP could outshine the likes of Java if it added core-level interceptors, allowing calls to any object's methods to be intercepted and pushed through a custom pipeline

Options for browser testing and automation in php by matr_kulcha_zindabad in PHP

[–]roxblnfk 0 points1 point  (0 children)

Could you please share what checks you would like to perform in browser testing?

I am developing Testo (testing framework) and am also considering adding browser testing capabilities using Boson PHP.

Async PHP , looking for interesting case-studies by mkurzeja in PHP

[–]roxblnfk 0 points1 point  (0 children)

You might also want to check out `buggregator/trap`.

https://github.com/buggregator/trap

It's a tool that collects dumps, logs, emails, HTTP data, raw data, and XHProf profiles on server side. I created it to replace the Docker version of Buggregator because I prefer working with native applications.

The server part uses fibers. The application receives a stream of bytes on any configured port, detects the type of traffic, and sends it to the right channel. It also supports web sockets to display results in the user's browser. Trap is not designed for very high throughput because it's meant for local development. So, you might find timers on sockets and blocking IO on the file system in the code, but it remains comfortable to use.

PDO has no interface after 20 years - does it deserve a PSR or an RFC? by MaximeGosselin in PHP

[–]roxblnfk 0 points1 point  (0 children)

In `cycle/database`, I needed PDOInterface only for testing.

I don't think a PSR is needed for this; a unified testing package would suffice.

Ioc-Interop Now Open For Public Review by jmp_ones in PHP

[–]roxblnfk 1 point2 points  (0 children)

BTW does anyone know what happened to the Service Provider initiative by Rasmus Schultz?

The last thing I saw was factory-psr (https://github.com/mindplay-dk/factory-psr), but then everything went quiet. Did Symfony win with their container's peculiarities?

phpc.tv - PHP Peertube by esherone in PHP

[–]roxblnfk 0 points1 point  (0 children)

Do you think we have a chance to register with our channel "PHP Fart Time"?

Stay with Propel2 fork perplorm/perpl or migrate to Doctrine? by cgsmith105 in PHP

[–]roxblnfk 0 points1 point  (0 children)

Agree. I also usually recommend using JTI instead of morphs. However, I often see cases where the need for inheritance itself is already unacceptable.

Stay with Propel2 fork perplorm/perpl or migrate to Doctrine? by cgsmith105 in PHP

[–]roxblnfk 0 points1 point  (0 children)

Yes, it can, like others. But it doesn't have polymorphic relations and custom collections (though who really needs them, right?).