for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
/**
* This file is part of Laravel Code Analyse.
*
* (c) Nuno Maduro <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace NunoMaduro\LaravelCodeAnalyse\Extensions;
use PHPStan\Broker\Broker;
use Illuminate\Database\Eloquent\Model;
use PHPStan\Reflection\ClassReflection;
use PHPStan\Reflection\MethodReflection;
use PHPStan\Reflection\BrokerAwareExtension;
use PHPStan\Reflection\MethodsClassReflectionExtension;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
final class BelongsToManyMethodExtension implements MethodsClassReflectionExtension, BrokerAwareExtension
{
* @var \PHPStan\Broker\Broker
private $broker;
* @param \PHPStan\Broker\Broker $broker
public function setBroker(Broker $broker): void
$this->broker = $broker;
}
* {@inheritdoc}
public function hasMethod(ClassReflection $classReflection, string $methodName): bool
return $classReflection->isSubclassOf(BelongsToMany::class) && $this->broker->getClass(BelongsToMany::class)
->hasNativeMethod($methodName);
public function getMethod(ClassReflection $classReflection, string $methodName): MethodReflection
return $this->broker->getClass(BelongsToMany::class)
->getNativeMethod($methodName);