One solution to this issue is to create stub files for the classes that Larastan is having trouble with. These stub files will provide the necessary information for Larastan to understand the magic methods and properties.
For example, to create a stub file for the Spatie\Onboard\OnboardingStep class, create a new file called OnboardingStep.php in the stubs directory of your project (if it doesn't exist, create it). In this file, define the missing property like this:
<?php
namespace Spatie\Onboard;
/**
* @property mixed $link
*/
class OnboardingStep
{
// ...
}
This tells Larastan that the OnboardingStep class has a magic property called $link.
Similarly, to create a stub file for the Faker\Generator class, create a new file called Generator.php in the stubs directory of your project. In this file, define the missing properties like this:
<?php
namespace Faker;
/**
* @property-read string $state
* @property-read string $stateAbbr
*/
class Generator
{
// ...
}
This tells Larastan that the Generator class has magic properties called $state and $stateAbbr.
Once you've created these stub files, you need to tell Larastan to use them. To do this, add the following to your phpstan.neon file:
parameters:
autoload_files:
- /path/to/project/stubs/OnboardingStep.php
- /path/to/project/stubs/Generator.php
Replace /path/to/project with the actual path to your project.
With these stub files in place, Larastan should be able to find the missing magic methods and properties and the errors should disappear.