first commit

This commit is contained in:
Sampanna Rimal
2024-08-27 17:48:06 +05:45
commit 53c0140f58
10839 changed files with 1125847 additions and 0 deletions

View File

@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\PHPStan;
use PHPStan\BetterReflection\Reflection;
use ReflectionMethod;
if (!class_exists(AbstractReflectionMacro::class, false)) {
abstract class AbstractReflectionMacro extends AbstractMacro
{
/**
* {@inheritdoc}
*/
public function getReflection(): ?ReflectionMethod
{
if ($this->reflectionFunction instanceof Reflection\ReflectionMethod) {
return new Reflection\Adapter\ReflectionMethod($this->reflectionFunction);
}
return $this->reflectionFunction instanceof ReflectionMethod
? $this->reflectionFunction
: null;
}
}
}

View File

@ -0,0 +1,45 @@
<?php
declare(strict_types=1);
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\PHPStan;
use PHPStan\BetterReflection\Reflection;
use ReflectionMethod;
if (!class_exists(AbstractReflectionMacro::class, false)) {
abstract class AbstractReflectionMacro extends AbstractMacro
{
/**
* {@inheritdoc}
*/
public function getReflection(): ?Reflection\Adapter\ReflectionMethod
{
if ($this->reflectionFunction instanceof Reflection\Adapter\ReflectionMethod) {
return $this->reflectionFunction;
}
if ($this->reflectionFunction instanceof Reflection\ReflectionMethod) {
return new Reflection\Adapter\ReflectionMethod($this->reflectionFunction);
}
return $this->reflectionFunction instanceof ReflectionMethod
? new Reflection\Adapter\ReflectionMethod(
Reflection\ReflectionMethod::createFromName(
$this->reflectionFunction->getDeclaringClass()->getName(),
$this->reflectionFunction->getName()
)
)
: null;
}
}
}

View File

@ -0,0 +1,45 @@
<?php
declare(strict_types=1);
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\PHPStan;
if (!class_exists(LazyMacro::class, false)) {
abstract class LazyMacro extends AbstractReflectionMacro
{
/**
* {@inheritdoc}
*/
public function getFileName(): ?string
{
$file = $this->reflectionFunction->getFileName();
return (($file ? realpath($file) : null) ?: $file) ?: null;
}
/**
* {@inheritdoc}
*/
public function getStartLine(): ?int
{
return $this->reflectionFunction->getStartLine();
}
/**
* {@inheritdoc}
*/
public function getEndLine(): ?int
{
return $this->reflectionFunction->getEndLine();
}
}
}

View File

@ -0,0 +1,51 @@
<?php
declare(strict_types=1);
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <brian@nesbot.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Carbon\PHPStan;
if (!class_exists(LazyMacro::class, false)) {
abstract class LazyMacro extends AbstractReflectionMacro
{
/**
* {@inheritdoc}
*
* @return string|false
*/
public function getFileName()
{
$file = $this->reflectionFunction->getFileName();
return (($file ? realpath($file) : null) ?: $file) ?: null;
}
/**
* {@inheritdoc}
*
* @return int|false
*/
public function getStartLine()
{
return $this->reflectionFunction->getStartLine();
}
/**
* {@inheritdoc}
*
* @return int|false
*/
public function getEndLine()
{
return $this->reflectionFunction->getEndLine();
}
}
}