Skip to content

Conversation

@Voltra
Copy link
Contributor

@Voltra Voltra commented Oct 15, 2025

Before this PR, it was possible to call \Spatie\Crawler\CrawlUrl::getId on an object with an uninitialized îd property:

$crawlUrl = CrawlUrl::create(
  url: $someUriObj,
  foundOnUrl: $foundOnUrl,
  linkText: "some text",
); // Here `$crawlUrl->id` is left uninitialized

// Here $crawlUrl is in a "constructed" but invalid state

$crawlUrl->getId(); // This throws an exception, unless the ID has been set externally before being called

This is because $id is type-annotated with mixed (which is the default any way) and the PHP manual says:

Typed properties must be initialized before accessing, otherwise an Error is thrown.

This PR fixes this issue

PS: It also introduces a minimally usable devcontainer configuration for Github codespaces and the like, this can be cherrypicked out

@freekmurze
Copy link
Member

Could you add a test for this?

@Voltra
Copy link
Contributor Author

Voltra commented Oct 16, 2025

Done

@freekmurze
Copy link
Member

So of the tests are failing, could you take a look?

@Voltra
Copy link
Contributor Author

Voltra commented Oct 20, 2025

Fixed, seems like describe was introduced after Pest 2.0.0

@freekmurze freekmurze merged commit e9dd610 into spatie:main Oct 22, 2025
18 checks passed
@freekmurze
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants