repo stringlengths 7 63 | file_url stringlengths 81 284 | file_path stringlengths 5 200 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:02:33 2026-01-05 05:24:06 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Validator/Rule/NotEmptyTest.php | tests/unit/Validator/Rule/NotEmptyTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Validator\Rule;
use Bluz\Tests;
use Bluz\Validator\Rule\NotEmptyRule as Rule;
/**
* Class NotEmptyTest
*
* @package Bluz\Tests\Validator\Rule
*/
class NotEmptyTest extends Tests\FrameworkTestCase
{
/**
* @var Rule
*/
protected $rule;
/**
* Setup validator instance
*/
protected function setUp(): void
{
$this->rule = new Rule();
}
/**
* @dataProvider providerForPass
*
* @param $input
*/
public function testStringNotEmptyShouldPass($input)
{
self::assertTrue($this->rule->validate($input));
self::assertNotEmpty($this->rule->__toString());
}
/**
* @dataProvider providerForFail
*
* @param $input
*/
public function testStringIsEmptyShouldFail($input)
{
self::assertFalse($this->rule->validate($input));
self::assertNotEmpty($this->rule->__toString());
}
/**
* @return array
*/
public function providerForPass(): array
{
return array(
[1],
[' oi'],
[[5]],
[[0]],
[new \stdClass()]
);
}
/**
* @return array
*/
public function providerForFail(): array
{
return array(
[''],
[' '],
["\n"],
[false],
[null],
[[]]
);
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Validator/Rule/InTest.php | tests/unit/Validator/Rule/InTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Validator\Rule;
use Bluz\Tests;
use Bluz\Validator\Rule\InRule as Rule;
/**
* Class InTest
*
* @package Bluz\Tests\Validator\Rule
*/
class InTest extends Tests\FrameworkTestCase
{
/**
* @dataProvider providerForPass
*
* @param $input
* @param null $haystack
*/
public function testSuccessInValidatorCases($input, $haystack = null)
{
$rule = new Rule($haystack);
self::assertTrue($rule->validate($input));
self::assertNotEmpty($rule->__toString());
}
/**
* @dataProvider providerForFail
*
* @param $input
* @param null $haystack
*/
public function testInvalidInValidatorCases($input, $haystack = null)
{
$rule = new Rule($haystack);
self::assertFalse($rule->validate($input));
self::assertNotEmpty($rule->__toString());
}
/**
* @return array
*/
public function providerForPass(): array
{
return array(
['foo', ['foo', 'bar']],
['foo', 'foo'],
['foo', 'barfoobaz'],
['foo', 'barbazFOO'],
['1', [1, 2, 3]],
['1', ['1', 2, 3]],
);
}
/**
* @return array
*/
public function providerForFail(): array
{
return array(
['', 'barfoobaz'],
['', 42],
['bat', ['foo', 'bar']],
['foo', 'barfaabaz'],
[4, [1, 2, 3]],
);
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Validator/Rule/LengthTest.php | tests/unit/Validator/Rule/LengthTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Validator\Rule;
use Bluz\Tests;
use Bluz\Validator\Exception\ComponentException;
use Bluz\Validator\Rule\LengthRule as Rule;
/**
* Class LengthTest
*
* @package Bluz\Tests\Validator\Rule
*/
class LengthTest extends Tests\FrameworkTestCase
{
/**
* @dataProvider providerForPass
*
* @param $string
* @param $min
* @param $max
*/
public function testLengthInsideBoundsShouldPass($string, $min, $max)
{
$rule = new Rule($min, $max);
self::assertTrue($rule->validate($string));
self::assertNotEmpty($rule->__toString());
}
/**
* @dataProvider providerForFail
*
* @param $string
* @param $min
* @param $max
*/
public function testLengthOutsideValidBoundsShouldFail($string, $min, $max)
{
$rule = new Rule($min, $max);
self::assertFalse($rule->validate($string));
self::assertNotEmpty($rule->__toString());
}
/**
* @dataProvider providerForComponentException
*
* @param $min
* @param $max
*/
public function testInvalidConstructorParametersShouldThrowComponentExceptionUponInstantiation($min, $max)
{
$this->expectException(ComponentException::class);
new Rule($min, $max);
}
/**
* @return array
*/
public function providerForPass(): array
{
return array(
['foobar', 1, 15],
['ççççç', 4, 6],
[range(1, 20), 1, 30],
[(object)['foo' => 'bar', 'bar' => 'baz'], 1, 2],
['foobar', 1, null], //null is a valid max length, means "no maximum",
['foobar', null, 15] //null is a valid min length, means "no minimum"
);
}
/**
* @return array
*/
public function providerForFail(): array
{
return array(
[0, 1, 3],
['foobar', 1, 3],
[(object)['foo' => 'bar', 'bar' => 'baz'], 3, 5],
[range(1, 50), 1, 30],
);
}
/**
* @return array
*/
public function providerForComponentException(): array
{
return [
['a', 15],
[1, 'abc d'],
[10, 1],
];
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Validator/Rule/ArrayInputTest.php | tests/unit/Validator/Rule/ArrayInputTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Validator\Rule;
use Bluz\Tests;
use Bluz\Validator\Rule\ArrayRule as Rule;
/**
* Class StringTest
*
* @package Bluz\Tests\Validator\Rule
*/
class ArrayInputTest extends Tests\FrameworkTestCase
{
/**
* @var Rule
*/
protected $rule;
protected function setUp(): void
{
$this->rule = new Rule('is_numeric');
}
/**
* @dataProvider providerForPass
*
* @param $input
*/
public function testArrayWithNumbersShouldPass($input)
{
self::assertTrue($this->rule->validate($input));
self::assertNotEmpty($this->rule->__toString());
}
/**
* @dataProvider providerForFail
*
* @param $input
*/
public function testArrayMixedArrayShouldFail($input)
{
self::assertFalse($this->rule->validate($input));
self::assertNotEmpty($this->rule->__toString());
}
/**
* @return array
*/
public function providerForPass(): array
{
return [
[[]],
[[1, 2, 3]],
[['1', '2', '3']],
[['1.2', '2e10']],
];
}
/**
* @return array
*/
public function providerForFail(): array
{
return [
[null],
[150],
['abc'],
[['abc']],
[['abc', 1, 2, 3]],
];
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Validator/Rule/NegativeTest.php | tests/unit/Validator/Rule/NegativeTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Validator\Rule;
use Bluz\Tests;
use Bluz\Validator\Rule\NegativeRule as Rule;
/**
* Class NegativeTest
*
* @package Bluz\Tests\Validator\Rule
*/
class NegativeTest extends Tests\FrameworkTestCase
{
/**
* @var Rule
*/
protected $rule;
/**
* Setup validator instance
*/
protected function setUp(): void
{
$this->rule = new Rule();
}
/**
* @dataProvider providerForPass
*
* @param $input
*/
public function testNegativeShouldPass($input)
{
self::assertTrue($this->rule->validate($input));
self::assertNotEmpty($this->rule->__toString());
}
/**
* @dataProvider providerForFail
*
* @param $input
*/
public function testNegativeShouldFail($input)
{
self::assertFalse($this->rule->validate($input));
self::assertNotEmpty($this->rule->__toString());
}
/**
* @return array
*/
public function providerForPass(): array
{
return [
['-1.44'],
[-1e-5],
[-10],
];
}
/**
* @return array
*/
public function providerForFail(): array
{
return array(
[0],
[-0],
[null],
[''],
['a'],
[' '],
['Foo'],
[16],
['165'],
[123456],
[1e10],
);
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Validator/Rule/LatinNumericTest.php | tests/unit/Validator/Rule/LatinNumericTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Validator\Rule;
use Bluz\Tests;
use Bluz\Validator\Exception\ComponentException;
use Bluz\Validator\Rule\LatinNumericRule as Rule;
/**
* Class AlphaTest
*
* @package Bluz\Tests\Validator\Rule
*/
class LatinNumericTest extends Tests\FrameworkTestCase
{
/**
* @dataProvider providerForPass
*
* @param $validAlpha
* @param string $additional
*/
public function testValidAlphanumericCharsShouldPass($validAlpha, $additional = '')
{
$rule = new Rule($additional);
self::assertTrue($rule->validate($validAlpha));
self::assertNotEmpty($rule->__toString());
}
/**
* @dataProvider providerForFail
*
* @param $invalidAlpha
* @param string $additional
*/
public function testInvalidAlphanumericCharsShouldFail($invalidAlpha, $additional = '')
{
$rule = new Rule($additional);
self::assertFalse($rule->validate($invalidAlpha));
self::assertNotEmpty($rule->__toString());
}
/**
* @dataProvider providerAdditionalChars
*
* @param $additional
* @param $query
*/
public function testAdditionalCharsShouldBeRespected($additional, $query)
{
$rule = new Rule($additional);
self::assertTrue($rule->validate($query));
self::assertNotEmpty($rule->__toString());
}
/**
* Check messages
*/
public function testRuleDescriptionShouldBePresent()
{
$rule = new Rule();
self::assertNotEmpty($rule->__toString());
$rule = new Rule('[]');
self::assertNotEmpty($rule->__toString());
}
/**
* @return array
*/
public function providerForPass(): array
{
return [
[0],
[123456789],
['1234567890'],
['foobar'],
['foobar1234567890'],
['foobar_', '_'],
['google.com.ua', '.'],
['foobar foobar', ' ']
];
}
/**
* @return array
*/
public function providerForFail(): array
{
return [
[1e21],
['@#$'],
['_'],
['dgç'],
[null],
[new \stdClass()],
[[]],
];
}
/**
* @return array
*/
public function providerAdditionalChars(): array
{
return [
['!@#$%^&*(){} ', '!@#$%^&*(){} abc'],
['[]?+=/\\-_|"\',<>. ', "[]?+=/\\-_|\"',<>. abc"],
];
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Validator/Rule/RequiredTest.php | tests/unit/Validator/Rule/RequiredTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Validator\Rule;
use Bluz\Tests;
use Bluz\Validator\Rule\RequiredRule as Rule;
/**
* Class RequiredTest
*
* @package Bluz\Tests\Validator\Rule
*/
class RequiredTest extends Tests\FrameworkTestCase
{
/**
* @var Rule
*/
protected $rule;
/**
* Setup validator instance
*/
protected function setUp(): void
{
$this->rule = new Rule();
}
/**
* @dataProvider providerForPass
*
* @param $input
*/
public function testRequiredShouldPass($input)
{
self::assertTrue($this->rule->validate($input));
self::assertNotEmpty($this->rule->__toString());
}
/**
* @dataProvider providerForFail
*
* @param $input
*/
public function testNotExistsShouldFail($input)
{
self::assertFalse($this->rule->validate($input));
self::assertNotEmpty($this->rule->__toString());
}
/**
* @return array
*/
public function providerForPass(): array
{
return array(
[1],
['foo'],
[[5]],
[[0]],
[new \stdClass()]
);
}
/**
* @return array
*/
public function providerForFail(): array
{
return [
[''],
[false],
[null]
];
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Validator/Rule/EmailTest.php | tests/unit/Validator/Rule/EmailTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Validator\Rule;
use Bluz\Tests;
use Bluz\Validator\Rule\EmailRule as Rule;
/**
* Class EmailTest
*
* @package Bluz\Tests\Validator\Rule
*/
class EmailTest extends Tests\FrameworkTestCase
{
/**
* @dataProvider providerForPass
*
* @param $validEmail
*/
public function testValidEmailShouldPassValidation($validEmail)
{
$rule = new Rule();
self::assertTrue($rule->validate($validEmail));
self::assertNotEmpty($rule->__toString());
}
/**
* @dataProvider providerForFail
*
* @param $invalidEmail
*/
public function testInvalidEmailsShouldFailValidation($invalidEmail)
{
$rule = new Rule();
self::assertFalse($rule->validate($invalidEmail));
self::assertNotEmpty($rule->__toString());
}
/**
* Used small set for testing
*/
public function testValidEmailWithDomainCheck()
{
self::markTestIncomplete('To slow to check it every time');
return;
$validator = new Rule(true);
self::assertTrue($validator->validate('test@test.com'));
self::assertFalse($validator->validate('a@a.a'));
}
/**
* @return array
*/
public function providerForPass(): array
{
return [
['test@test.com'],
['mail+mail@gmail.com'],
['mail.email@e.test.com'],
['a@a.a']
];
}
/**
* @return array
*/
public function providerForFail(): array
{
return [
['test@test'],
['test'],
['test@тест.рф'],
['@test.com'],
['mail@test@test.com'],
['test.test@'],
['test.@test.com'],
['test@.test.com'],
['test@test..com'],
['test@test.com.'],
['.test@test.com']
];
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Validator/Rule/BetweenInclusiveTest.php | tests/unit/Validator/Rule/BetweenInclusiveTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Validator\Rule;
use Bluz\Tests;
use Bluz\Validator\Rule\BetweenInclusiveRule as Rule;
/**
* Class BetweenTest
*
* @package Bluz\Tests\Validator\Rule
*/
class BetweenInclusiveTest extends Tests\FrameworkTestCase
{
/**
* @dataProvider providerForPass
*
* @param $min
* @param $max
* @param $input
*/
public function testValuesBetweenBoundsShouldPass($min, $max, $input)
{
$rule = new Rule($min, $max);
self::assertTrue($rule->validate($input));
self::assertNotEmpty($rule->__toString());
}
/**
* @dataProvider providerForFail
*
* @param $min
* @param $max
* @param $input
*/
public function testValuesOutBoundsShouldFail($min, $max, $input)
{
$rule = new Rule($min, $max);
self::assertFalse($rule->validate($input));
self::assertNotEmpty($rule->__toString());
}
/**
* @return array
*/
public function providerForPass(): array
{
return [
[10, 20, 10],
[10, 20, 20],
['a', 'z', 'z'],
[
new \DateTime('yesterday'),
new \DateTime('tomorrow'),
new \DateTime('tomorrow')
],
];
}
/**
* @return array
*/
public function providerForFail(): array
{
return [
[0, 1, -1],
[0, 1, 3],
['a', 'j', 'z'],
[
new \DateTime('yesterday'),
new \DateTime('now'),
new \DateTime('tomorrow')
],
];
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Validator/Rule/PositiveTest.php | tests/unit/Validator/Rule/PositiveTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Validator\Rule;
use Bluz\Tests;
use Bluz\Validator\Rule\PositiveRule as Rule;
/**
* Class PositiveTest
*
* @package Bluz\Tests\Validator\Rule
*/
class PositiveTest extends Tests\FrameworkTestCase
{
/**
* @var Rule
*/
protected $rule;
/**
* Setup validator instance
*/
protected function setUp(): void
{
$this->rule = new Rule();
}
/**
* @dataProvider providerForPass
*
* @param $input
*/
public function testPositiveNumbersShouldPass($input)
{
self::assertTrue($this->rule->validate($input));
self::assertNotEmpty($this->rule->__toString());
}
/**
* @dataProvider providerForFail
*
* @param $input
*/
public function testNegativeNumbersShouldFail($input)
{
self::assertFalse($this->rule->validate($input));
self::assertNotEmpty($this->rule->__toString());
}
/**
* @return array
*/
public function providerForPass(): array
{
return array(
[16],
['165'],
[123456],
[1e10],
);
}
/**
* @return array
*/
public function providerForFail(): array
{
return array(
[null],
[''],
['a'],
[' '],
['Foo'],
['-1.44'],
[-1e-5],
[0],
[-0],
[-10],
);
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Validator/Rule/FloatInputTest.php | tests/unit/Validator/Rule/FloatInputTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Validator\Rule;
use Bluz\Tests;
use Bluz\Validator\Rule\FloatRule as Rule;
/**
* Class FloatTest
*
* @package Bluz\Tests\Validator\Rule
*/
class FloatInputTest extends Tests\FrameworkTestCase
{
/**
* @var Rule
*/
protected $rule;
/**
* Setup validator instance
*/
protected function setUp(): void
{
$this->rule = new Rule();
}
/**
* @dataProvider providerForPass
*
* @param $input
*/
public function testFloatNumbersShouldPass($input)
{
self::assertTrue($this->rule->validate($input));
self::assertNotEmpty($this->rule->__toString());
}
/**
* @dataProvider providerForFail
*
* @param $input
*/
public function testNotFloatNumbersShouldFail($input)
{
self::assertFalse($this->rule->validate($input));
self::assertNotEmpty($this->rule->__toString());
}
/**
* @return array
*/
public function providerForPass(): array
{
return [
[165],
[1],
[0],
[0.0],
['1'],
['19347e12'],
[165.0],
['165.7'],
[1e12],
];
}
/**
* @return array
*/
public function providerForFail(): array
{
return [
[null],
[''],
['a'],
[' '],
['Foo'],
];
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Validator/Rule/CreditCardTest.php | tests/unit/Validator/Rule/CreditCardTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Validator\Rule;
use Bluz\Tests;
use Bluz\Validator\Rule\CreditCardRule as Rule;
/**
* Class CreditCardTest
*
* @package Bluz\Tests\Validator\Rule
*/
class CreditCardTest extends Tests\FrameworkTestCase
{
/**
* @var Rule
*/
protected $rule;
/**
* Setup validator instance
*/
protected function setUp(): void
{
$this->rule = new Rule();
}
/**
* @dataProvider providerForPass
*
* @param $input
*/
public function testValidCreditCardsShouldPass($input)
{
self::assertTrue($this->rule->validate($input));
self::assertNotEmpty($this->rule->__toString());
}
/**
* @dataProvider providerForFail
*
* @param $input
*/
public function testInvalidCreditCardsShouldFail($input)
{
self::assertFalse($this->rule->validate($input));
self::assertNotEmpty($this->rule->__toString());
}
/**
* @return array
*/
public function providerForPass(): array
{
return [
['5376 7473 9720 8720'], // MasterCard
['4024.0071.5336.1885'], // Visa 16
['4024 007 193 879'], // Visa 13
['340-3161-9380-9364'], // AmericanExpress
['30351042633884'], // Dinners
];
}
/**
* @return array
*/
public function providerForFail(): array
{
return [
[null],
[''],
['it isnt my credit card number'],
['&stR@ng3|) (|-|@r$'],
['1234 1234 1234 1234'],
['1234.1234.1234.1234'],
];
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Validator/Rule/DateTest.php | tests/unit/Validator/Rule/DateTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Validator\Rule;
use Bluz\Tests;
use Bluz\Validator\Rule\DateRule as Rule;
/**
* Class DateTest
*
* @package Bluz\Tests\Validator\Rule
*/
class DateTest extends Tests\FrameworkTestCase
{
/**
* @var Rule
*/
protected $rule;
/**
* Setup validator instance
*/
protected function setUp(): void
{
$this->rule = new Rule();
}
public function testDateWithoutFormatShouldPass()
{
self::assertTrue($this->rule->validate('today'));
}
public function testDateTimeInstancesShouldAlwaysValidAndPass()
{
self::assertTrue($this->rule->validate(new \DateTime('today')));
}
/**
* @dataProvider providerForPass
*
* @param $format
* @param $date
*/
public function testValidDateShouldPass($format, $date)
{
$rule = new Rule($format);
self::assertTrue($rule->validate($date));
self::assertNotEmpty($rule->__toString());
}
/**
* @dataProvider providerForFail
*
* @param $format
* @param $date
*/
public function testInvalidateDateShouldFail($format, $date)
{
$rule = new Rule($format);
self::assertFalse($rule->validate($date));
self::assertNotEmpty($rule->__toString());
}
/**
* @return array
*/
public function providerForPass(): array
{
return [
['Y-m-d', '2009-09-09'],
['d/m/Y', '23/05/1987'],
];
}
/**
* @return array
*/
public function providerForFail(): array
{
return [
[null, 'invalid date'],
['Y-m-d', '2009-09-00'],
['y-m-d', '2009-09-09'],
['y-m-d', new \stdClass()],
];
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Validator/Rule/BetweenTest.php | tests/unit/Validator/Rule/BetweenTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Validator\Rule;
use Bluz\Tests;
use Bluz\Validator\Exception\ComponentException;
use Bluz\Validator\Rule\BetweenRule as Rule;
/**
* Class BetweenTest
*
* @package Bluz\Tests\Validator\Rule
*/
class BetweenTest extends Tests\FrameworkTestCase
{
/**
* @dataProvider providerForPass
*
* @param $min
* @param $max
* @param $input
*/
public function testValuesBetweenBoundsShouldPass($min, $max, $input)
{
$rule = new Rule($min, $max);
self::assertTrue($rule->validate($input));
self::assertNotEmpty($rule->__toString());
}
/**
* @dataProvider providerForFail
*
* @param $min
* @param $max
* @param $input
*/
public function testValuesOutBoundsShouldFail($min, $max, $input)
{
$rule = new Rule($min, $max);
self::assertFalse($rule->validate($input));
self::assertNotEmpty($rule->__toString());
}
/**
* @dataProvider providerForComponentException
*
* @param $min
* @param $max
*/
public function testInvalidConstructionParamsShouldRaiseException($min, $max)
{
$this->expectException(ComponentException::class);
new Rule($min, $max);
}
/**
* @return array
*/
public function providerForPass(): array
{
return [
[10, 20, 11],
[10, 20, 19],
[-10, 20, -5],
[-10, 20, 0],
['a', 'z', 'j'],
[
new \DateTime('yesterday'),
new \DateTime('tomorrow'),
new \DateTime('now')
],
];
}
/**
* @return array
*/
public function providerForFail(): array
{
return [
[0, 1, -1],
[0, 1, 0],
[0, 1, 1],
[0, 1, 3],
[10, 20, ''],
[10, 20, 999],
[10, 20, 20],
[-10, 20, -11],
['a', 'j', 'z'],
[
new \DateTime('yesterday'),
new \DateTime('now'),
new \DateTime('tomorrow')
],
];
}
/**
* @return array
*/
public function providerForComponentException(): array
{
return [
[10, 5],
[10, null],
[null, 5],
];
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Validator/Rule/LessOrEqualTest.php | tests/unit/Validator/Rule/LessOrEqualTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Validator\Rule;
use Bluz\Tests;
use Bluz\Validator\Rule\LessOrEqualRule as Rule;
/**
* Class MaxTest
*
* @package Bluz\Tests\Validator\Rule
*/
class LessOrEqualTest extends Tests\FrameworkTestCase
{
/**
* @dataProvider providerForPass
*
* @param $maxValue
* @param $input
*/
public function testValidLessInputShouldPass($maxValue, $input)
{
$rule = new Rule($maxValue);
self::assertTrue($rule->validate($input));
self::assertNotEmpty($rule->__toString());
}
/**
* @dataProvider providerForFail
*
* @param $maxValue
* @param $input
*/
public function testInvalidLessValueShouldFail($maxValue, $input)
{
$rule = new Rule($maxValue);
self::assertFalse($rule->validate($input));
self::assertNotEmpty($rule->__toString());
}
/**
* @return array
*/
public function providerForPass(): array
{
return [
[0, ''], // empty string is equal zero
[1, true],
[0, false],
[0, null],
[0, 0],
[0, '0'],
['1', 0],
];
}
/**
* @return array
*/
public function providerForFail(): array
{
return [
[0, true],
[0, 1],
];
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Validator/Rule/JsonTest.php | tests/unit/Validator/Rule/JsonTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Validator\Rule;
use Bluz\Tests;
use Bluz\Validator\Rule\JsonRule as Rule;
/**
* Class JsonTest
*
* @package Bluz\Tests\Validator\Rule
*/
class JsonTest extends Tests\FrameworkTestCase
{
/**
* @var Rule
*/
protected $rule;
/**
* Setup validator instance
*/
protected function setUp(): void
{
$this->rule = new Rule();
}
/**
* @dataProvider providerForPass
*
* @param $input
*/
public function testValidJsonsShouldPass($input)
{
self::assertTrue($this->rule->validate($input));
self::assertNotEmpty($this->rule->__toString());
}
/**
* @dataProvider providerForFail
*
* @param $input
*/
public function testInvalidJsonsShouldFail($input)
{
self::assertFalse($this->rule->validate($input));
self::assertNotEmpty($this->rule->__toString());
}
/**
* @return array
*/
public function providerForPass(): array
{
return array(
['2'],
['"abc"'],
['[1,2,3]'],
['["foo", "bar", "number", 1]'],
['{"foo": "bar", "number":1}'],
);
}
/**
* @return array
*/
public function providerForFail(): array
{
return [
[''],
['{foo:bar}'],
];
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Validator/Rule/InStrictTest.php | tests/unit/Validator/Rule/InStrictTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Validator\Rule;
use Bluz\Tests;
use Bluz\Validator\Rule\InStrictRule as Rule;
/**
* Class InTest
*
* @package Bluz\Tests\Validator\Rule
*/
class InStrictTest extends Tests\FrameworkTestCase
{
/**
* @dataProvider providerForPass
*
* @param $input
* @param null $haystack
*/
public function testSuccessInValidatorCases($input, $haystack = null)
{
$rule = new Rule($haystack);
self::assertTrue($rule->validate($input));
self::assertNotEmpty($rule->__toString());
}
/**
* @dataProvider providerForFail
*
* @param $input
* @param null $haystack
*/
public function testInvalidInValidatorCases($input, $haystack = null)
{
$rule = new Rule($haystack);
self::assertFalse($rule->validate($input));
self::assertNotEmpty($rule->__toString());
}
/**
* @return array
*/
public function providerForPass(): array
{
return [
['foo', 'foo'],
['foo', ['foo', 'bar']],
['foo', 'barfoobaz'],
[1, [1, 2, 3]],
['1', ['1', 2, 3]],
];
}
/**
* @return array
*/
public function providerForFail(): array
{
return [
['', 'barfoobaz'],
['foo', 'barbazFOO'],
['', 42],
[1, ['1', 2, 3]],
['1', [1, 2, 3]],
];
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Validator/Rule/StringInputTest.php | tests/unit/Validator/Rule/StringInputTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Validator\Rule;
use Bluz\Tests;
use Bluz\Validator\Rule\StringRule as Rule;
/**
* Class StringTest
*
* @package Bluz\Tests\Validator\Rule
*/
class StringInputTest extends Tests\FrameworkTestCase
{
/**
* @var Rule
*/
protected $rule;
protected function setUp(): void
{
$this->rule = new Rule();
}
/**
* @dataProvider providerForPass
*
* @param $input
*/
public function testValidStringShouldPass($input)
{
self::assertTrue($this->rule->validate($input));
self::assertNotEmpty($this->rule->__toString());
}
/**
* @dataProvider providerForFail
*
* @param $input
*/
public function testInvalidStringShouldFail($input)
{
self::assertFalse($this->rule->validate($input));
self::assertNotEmpty($this->rule->__toString());
}
/**
* @return array
*/
public function providerForPass(): array
{
return [
[''],
['165.7'],
];
}
/**
* @return array
*/
public function providerForFail(): array
{
return [
[null],
[[]],
[new \stdClass()],
[150]
];
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Validator/Rule/AlphaTest.php | tests/unit/Validator/Rule/AlphaTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Validator\Rule;
use Bluz\Tests;
use Bluz\Validator\Exception\ComponentException;
use Bluz\Validator\Rule\AlphaRule as Rule;
/**
* Class AlphaTest
*
* @package Bluz\Tests\Validator\Rule
*/
class AlphaTest extends Tests\FrameworkTestCase
{
/**
* @dataProvider providerForPass
*
* @param $validAlpha
* @param $additional
*/
public function testValidAlphanumericCharsShouldPass($validAlpha, $additional)
{
$rule = new Rule($additional);
self::assertTrue($rule->validate($validAlpha));
self::assertNotEmpty($rule->__toString());
}
/**
* @dataProvider providerForFail
*
* @param $invalidAlpha
* @param $additional
*/
public function testInvalidAlphanumericCharsShouldFail($invalidAlpha, $additional)
{
$rule = new Rule($additional);
self::assertFalse($rule->validate($invalidAlpha));
self::assertNotEmpty($rule->__toString());
}
/**
* @dataProvider providerAdditionalChars
*
* @param $additional
* @param $query
*/
public function testAdditionalCharsShouldBeRespected($additional, $query)
{
$rule = new Rule($additional);
self::assertTrue($rule->validate($query));
self::assertNotEmpty($rule->__toString());
}
/**
* Check templates
*/
public function testTemplates()
{
$rule = new Rule();
self::assertNotEmpty($rule->__toString());
$rule = new Rule('[]');
self::assertNotEmpty($rule->__toString());
}
/**
* @return array
*/
public function providerForPass()
{
return [
['', ''],
['foobar', ''],
['foobar', 'foobar'],
['0alg-anet0', '0-9'],
['a', ''],
["\t", ''],
["\n", ''],
['foobar', ''],
['python_', '_'],
['google.com.ua', '.'],
['foobar foobar', ''],
["\nabc", ''],
["\tdef", ''],
["\nabc \t", ''],
];
}
/**
* @return array
*/
public function providerForFail(): array
{
return [
['@#$', ''],
['_', ''],
['dgç', ''],
['122al', ''],
['122', ''],
[11123, ''],
[1e21, ''],
[0, ''],
[null, ''],
[new \stdClass(), ''],
[[], ''],
];
}
/**
* @return array
*/
public function providerAdditionalChars(): array
{
return [
['!@#$%^&*(){}', '!@#$%^&*(){} abc'],
['[]?+=/\\-_|"\',<>.', "[]?+=/\\-_|\"',<>. \t \n abc"],
];
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Validator/Rule/CountryCodeTest.php | tests/unit/Validator/Rule/CountryCodeTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Validator\Rule;
use Bluz\Tests;
use Bluz\Validator\Rule\CountryCodeRule as Rule;
/**
* Class CountryCodeTest
*
* @package Bluz\Tests\Validator\Rule
*/
class CountryCodeTest extends Tests\FrameworkTestCase
{
/**
* @var Rule
*/
protected $rule;
/**
* Setup validator instance
*/
protected function setUp(): void
{
$this->rule = new Rule();
}
/**
* @dataProvider providerForPass
*
* @param $input
*/
public function testValidCountryCodeShouldPass($input)
{
self::assertTrue($this->rule->validate($input));
self::assertNotEmpty($this->rule->__toString());
}
/**
* @dataProvider providerForFail
*
* @param $input
*/
public function testInvalidCountryCodeShouldFail($input)
{
self::assertFalse($this->rule->validate($input));
self::assertNotEmpty($this->rule->__toString());
}
/**
* @return array
*/
public function providerForPass(): array
{
return [
['UA'],
];
}
/**
* @return array
*/
public function providerForFail(): array
{
return [
[''],
['UKR'],
];
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Validator/Rule/MoreTest.php | tests/unit/Validator/Rule/MoreTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Validator\Rule;
use Bluz\Tests;
use Bluz\Validator\Rule\MoreRule as Rule;
/**
* Class MinTest
*
* @package Bluz\Tests\Validator\Rule
*/
class MoreTest extends Tests\FrameworkTestCase
{
/**
* @dataProvider providerForPass
*
* @param $minValue
* @param $input
*/
public function testValidMoreShouldPass($minValue, $input)
{
$rule = new Rule($minValue);
codecept_debug($minValue);
codecept_debug($input);
codecept_debug($rule->validate($input));
self::assertTrue($rule->validate($input));
self::assertNotEmpty($rule->__toString());
}
/**
* @dataProvider providerForFail
*
* @param $minValue
* @param $input
*/
public function testInvalidMoreShouldFail($minValue, $input)
{
$rule = new Rule($minValue);
self::assertFalse($rule->validate($input));
self::assertNotEmpty($rule->__toString());
}
/**
* @return array
*/
public function providerForPass(): array
{
return array(
[0, 100],
[0, 123.0],
[-50, 0],
);
}
/**
* @return array
*/
public function providerForFail(): array
{
return array(
[100, 0],
[0, -50],
[0, 0],
);
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Validator/Rule/VersionTest.php | tests/unit/Validator/Rule/VersionTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Validator\Rule;
use Bluz\Tests;
use Bluz\Validator\Exception\ValidatorException;
use Bluz\Validator\Rule\VersionRule as Rule;
/**
* Class VersionTest
*
* @package Bluz\Tests\Validator\Rule
*/
class VersionTest extends Tests\FrameworkTestCase
{
/**
* @var Rule
*/
protected $rule;
protected function setUp(): void
{
$this->rule = new Rule();
}
/**
* @dataProvider providerForPass
*
* @param $input
*/
public function testValidVersionNumberShouldPass($input)
{
$rule = $this->rule;
self::assertTrue($rule($input));
self::assertTrue($this->rule->validate($input));
self::assertNotEmpty($this->rule->__toString());
}
/**
* @dataProvider providerForFail
*
* @param $input
*/
public function testInvalidVersionNumberShouldFail($input)
{
$rule = $this->rule;
self::assertFalse($rule($input));
self::assertFalse($this->rule->validate($input));
self::assertNotEmpty($this->rule->__toString());
}
/**
* @dataProvider providerForFail
*
* @param $input
*/
public function testInvalidVersionNumberShouldThrowException($input)
{
$this->expectException(ValidatorException::class);
$this->rule->assert($input);
}
/**
* @return array
*/
public function providerForPass(): array
{
return [
['1.0.0'],
['1.0.0-alpha'],
['1.0.0-alpha.1'],
['1.0.0-0.3.7'],
['1.0.0-x.7.z.92'],
['1.3.7+build.2.b8f12d7'],
['1.3.7-rc.1'],
];
}
/**
* @return array
*/
public function providerForFail(): array
{
return [
[''],
['1.3.7--'],
['1.3.7++'],
['foo'],
['1.2.3.4'],
['1.2.3.4-beta'],
['beta'],
];
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Validator/Rule/DomainTest.php | tests/unit/Validator/Rule/DomainTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Respect\Validation\Rules;
use Bluz\Tests;
use Bluz\Validator\Rule\DomainRule as Rule;
/**
* Class DomainTest
*
* @package Respect\Validation\Rules
*/
class DomainTest extends Tests\FrameworkTestCase
{
/**
* @dataProvider providerForPass
* @param string $input
*/
public function testValidDomainsShouldPass($input)
{
$rule = new Rule();
self::assertTrue($rule->validate($input));
self::assertNotEmpty($rule->__toString());
}
/**
* @dataProvider providerForFail
* @param string $input
*/
public function testValidDomainsShouldFail($input)
{
$rule = new Rule();
self::assertFalse($rule->validate($input));
self::assertNotEmpty($rule->__toString());
}
/**
* @dataProvider providerRealDomainForPass
* @param string $input
*/
public function testValidDomainWithDomainCheck($input)
{
self::markTestIncomplete('To slow to check it every time');
return;
$rule = new Rule(true);
self::assertTrue($rule->validate($input));
self::assertNotEmpty($rule->__toString());
}
/**
* @dataProvider providerRealDomainForFail
* @param string $input
*/
public function testInvalidDomainWithDomainCheck($input)
{
self::markTestIncomplete('To slow to check it every time');
return;
$rule = new Rule(true);
self::assertFalse($rule->validate($input));
self::assertNotEmpty($rule->__toString());
}
/**
* @return array
*/
public function providerForPass(): array
{
return [
['domain.local'],
['example.com'],
['xn--bcher-kva.com'],
['example-hyphen.com'],
];
}
/**
* @return array
*/
public function providerForFail(): array
{
return [
[null],
[''],
['-example-invalid.com'],
['example.invalid.-com'],
];
}
/**
* @return array
*/
public function providerRealDomainForPass(): array
{
return [
['google.com'],
];
}
/**
* @return array
*/
public function providerRealDomainForFail(): array
{
return [
['domain.local'],
['1.2.3.4'],
];
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Validator/Rule/IntegerTest.php | tests/unit/Validator/Rule/IntegerTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Validator\Rule;
use Bluz\Tests;
use Bluz\Validator\Rule\IntegerRule as Rule;
/**
* Class IntegerTest
*
* @package Bluz\Tests\Validator\Rule
*/
class IntegerTest extends Tests\FrameworkTestCase
{
/**
* @var Rule
*/
protected $rule;
/**
* Setup validator instance
*/
protected function setUp(): void
{
$this->rule = new Rule();
}
/**
* @dataProvider providerForPass
*
* @param $input
*/
public function testValidIntegersShouldPass($input)
{
self::assertTrue($this->rule->validate($input));
self::assertNotEmpty($this->rule->__toString());
}
/**
* @dataProvider providerForFail
*
* @param $input
*/
public function testInvalidIntegersShouldFail($input)
{
self::assertFalse($this->rule->validate($input));
self::assertNotEmpty($this->rule->__toString());
}
/**
* @return array
*/
public function providerForPass(): array
{
return array(
[16],
['165'],
[123456],
[PHP_INT_MAX],
);
}
/**
* @return array
*/
public function providerForFail(): array
{
return array(
[null],
[''],
[' '],
['a'],
['Foo'],
['1.44'],
[1e-5],
);
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Validator/Rule/LatinTest.php | tests/unit/Validator/Rule/LatinTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Validator\Rule;
use Bluz\Tests;
use Bluz\Validator\Exception\ComponentException;
use Bluz\Validator\Rule\LatinRule as Rule;
/**
* Class AlphaTest
*
* @package Bluz\Tests\Validator\Rule
*/
class LatinTest extends Tests\FrameworkTestCase
{
/**
* @dataProvider providerForPass
*
* @param $validAlpha
* @param string $additional
*/
public function testValidAlphanumericCharsShouldPass($validAlpha, $additional = '')
{
$rule = new Rule($additional);
self::assertTrue($rule->validate($validAlpha));
self::assertNotEmpty($rule->__toString());
}
/**
* @dataProvider providerForFail
*
* @param $invalidAlpha
* @param string $additional
*/
public function testInvalidAlphanumericCharsShouldFail($invalidAlpha, $additional = '')
{
$rule = new Rule($additional);
self::assertFalse($rule->validate($invalidAlpha));
self::assertNotEmpty($rule->__toString());
}
/**
* @dataProvider providerAdditionalChars
*
* @param $additional
* @param $query
*/
public function testAdditionalCharsShouldBeRespected($additional, $query)
{
$rule = new Rule($additional);
self::assertTrue($rule->validate($query));
self::assertNotEmpty($rule->__toString());
}
/**
* Check messages
*/
public function testRuleDescriptionShouldBePresent()
{
$rule = new Rule();
self::assertNotEmpty($rule->__toString());
$rule = new Rule('[]');
self::assertNotEmpty($rule->__toString());
}
/**
* @return array
*/
public function providerForPass(): array
{
return array(
['foobar'],
['foobar', 'foobar'],
['foobar_', '_'],
['google.com.ua', '.'],
['foobar foobar', ' ']
);
}
/**
* @return array
*/
public function providerForFail(): array
{
return array(
['@#$'],
['_'],
['dgç'],
['122al'],
['122'],
[11123],
[1e21],
[0],
[null],
[new \stdClass()],
[[]],
);
}
/**
* @return array
*/
public function providerAdditionalChars(): array
{
return [
['!@#$%^&*(){} ', '!@#$%^&*(){} abc'],
['[]?+=/\\-_|"\',<>. ', "[]?+=/\\-_|\"',<>. abc"],
];
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Validator/Rule/RegexTest.php | tests/unit/Validator/Rule/RegexTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Validator\Rule;
use Bluz\Tests;
use Bluz\Validator\Rule\RegexpRule as Rule;
/**
* Class RegexTest
*
* @package Bluz\Tests\Validator\Rule
*/
class RegexTest extends Tests\FrameworkTestCase
{
/**
* @dataProvider providerForPass
*
* @param $expression
* @param $input
*/
public function testValidRegexpShouldPass($expression, $input)
{
$rule = new Rule($expression);
self::assertTrue($rule->validate($input));
self::assertNotEmpty($rule->__toString());
}
/**
* @dataProvider providerForFail
*
* @param $expression
* @param $input
*/
public function testInvalidRegexpShouldFail($expression, $input)
{
$rule = new Rule($expression);
self::assertFalse($rule->validate($input));
self::assertNotEmpty($rule->__toString());
}
/**
* @return array
*/
public function providerForPass(): array
{
return [
['/^[a-z]+$/', 'foobar'],
['/^[a-z]+$/i', 'FooBar'],
];
}
/**
* @return array
*/
public function providerForFail(): array
{
return [
['/^[a-z]+$/', 'foo bar'],
['/^w+$/', 'foo bar'],
];
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Validator/Rule/NumericTest.php | tests/unit/Validator/Rule/NumericTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Validator\Rule;
use Bluz\Tests;
use Bluz\Validator\Rule\NumericRule as Rule;
/**
* Class NumericTest
*
* @package Bluz\Tests\Validator\Rule
*/
class NumericTest extends Tests\FrameworkTestCase
{
/**
* @var Rule
*/
protected $rule;
/**
* Setup validator instance
*/
protected function setUp(): void
{
$this->rule = new Rule();
}
/**
* @dataProvider providerForPass
*
* @param $input
*/
public function testValidNumericShouldPass($input)
{
self::assertTrue($this->rule->validate($input));
self::assertNotEmpty($this->rule->__toString());
}
/**
* @dataProvider providerForFail
*
* @param $input
*/
public function testNotNumericShouldFail($input)
{
self::assertFalse($this->rule->validate($input));
self::assertNotEmpty($this->rule->__toString());
}
/**
* @return array
*/
public function providerForPass(): array
{
return array(
[165],
[165.0],
[-165],
['165'],
['165.0'],
['+165.0'],
);
}
/**
* @return array
*/
public function providerForFail(): array
{
return array(
[null],
['a'],
[''],
[' '],
['Foo'],
);
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Validator/Rule/AlphaNumericTest.php | tests/unit/Validator/Rule/AlphaNumericTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Validator\Rule;
use Bluz\Tests;
use Bluz\Validator\Exception\ComponentException;
use Bluz\Validator\Rule\AlphaNumericRule as Rule;
/**
* Class AlphaNumericTest
*
* @package Bluz\Tests\Validator\Rule
*/
class AlphaNumericTest extends Tests\FrameworkTestCase
{
/**
* @dataProvider providerForPass
*
* @param $validAlphaNumeric
* @param $additional
*/
public function testValidAlphaNumericCharsShouldPass($validAlphaNumeric, $additional)
{
$rule = new Rule($additional);
self::assertTrue($rule->validate($validAlphaNumeric));
self::assertNotEmpty($rule->__toString());
}
/**
* @dataProvider providerForFail
*
* @param $invalidAlphaNumeric
* @param $additional
*/
public function testInvalidAlphaNumericCharsShouldFail($invalidAlphaNumeric, $additional)
{
$rule = new Rule($additional);
self::assertFalse($rule->validate($invalidAlphaNumeric));
self::assertNotEmpty($rule->__toString());
}
/**
* @dataProvider providerAdditionalChars
*
* @param $additional
* @param $query
*/
public function testAdditionalCharsShouldBeRespected($additional, $query)
{
$rule = new Rule($additional);
self::assertTrue($rule->validate($query));
}
/**
* Check templates
*/
public function testTemplates()
{
$rule = new Rule();
self::assertNotEmpty($rule->__toString());
$rule = new Rule('[]');
self::assertNotEmpty($rule->__toString());
}
/**
* @return array
*/
public function providerForPass(): array
{
return [
['', ''],
['foobar', ''],
['foobar', 'foobar'],
['0alg-anet0', '0-9'],
['1', ''],
["\t", ''],
["\n", ''],
['a', ''],
['foobar', ''],
['rubinho_', '_'],
['google.com', '.'],
['foobar foobar', ''],
["\nabc", ''],
["\tdef", ''],
["\nabc \t", ''],
[0, ''],
];
}
/**
* @return array
*/
public function providerForFail(): array
{
return [
['@#$', ''],
['_', ''],
['dgç', ''],
[1e21, ''], //evaluates to "1.0E+21"
[null, ''],
[new \stdClass(), ''],
[[], ''],
];
}
/**
* @return array
*/
public function providerAdditionalChars(): array
{
return [
['!@#$%^&*(){}', '!@#$%^&*(){} abc 123'],
['[]?+=/\\-_|"\',<>.', "[]?+=/\\-_|\"',<>. \t \n abc 123"],
];
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Validator/Rule/ConditionTest.php | tests/unit/Validator/Rule/ConditionTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Validator\Rule;
use Bluz\Tests;
use Bluz\Validator\Rule\ConditionRule as Rule;
/**
* Class AlphaTest
*
* @package Bluz\Tests\Validator\Rule
*/
class ConditionTest extends Tests\FrameworkTestCase
{
/**
* @dataProvider providerForPass
*
* @param $condition
* @param string $input
*/
public function testValidAlphanumericCharsShouldPass($condition, $input = 'any')
{
$rule = new Rule($condition);
self::assertTrue($rule->validate($input));
self::assertNotEmpty($rule->__toString());
}
/**
* @dataProvider providerForFail
*
* @param $condition
* @param string $input
*/
public function testInvalidAlphanumericCharsShouldFail($condition, $input = 'any')
{
$rule = new Rule($condition);
self::assertFalse($rule->validate($input));
self::assertNotEmpty($rule->__toString());
}
/**
* @return array
*/
public function providerForPass(): array
{
return [
[4 > 2, 'always'],
[is_int(42), 'always'],
];
}
/**
* @return array
*/
public function providerForFail(): array
{
return [
[4 < 2, 'always'],
[is_int(42.0204), 'always'],
];
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Validator/Rule/EqualsStrictTest.php | tests/unit/Validator/Rule/EqualsStrictTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Validator\Rule;
use Bluz\Tests;
use Bluz\Validator\Rule\EqualsStrictRule as Rule;
/**
* Class EqualsTest
*
* @package Bluz\Tests\Validator\Rule
*/
class EqualsStrictTest extends Tests\FrameworkTestCase
{
/**
* @dataProvider providerForPass
*
* @param $start
* @param $input
*/
public function testStringsContainingExpectedValueShouldPass($start, $input)
{
$rule = new Rule($start);
self::assertTrue($rule->validate($input));
self::assertNotEmpty($rule->__toString());
}
/**
* @dataProvider providerForFail
*
* @param $start
* @param $input
*/
public function testStringsNotEqualsExpectedValueShouldNotPass($start, $input)
{
$rule = new Rule($start);
self::assertFalse($rule->validate($input));
self::assertNotEmpty($rule->__toString());
}
/**
* @return array
*/
public function providerForPass(): array
{
return [
['', ''],
['foo', 'foo'],
[10, 10],
['10', '10'],
];
}
/**
* @return array
*/
public function providerForFail(): array
{
return [
['', 0],
['', null],
['', false],
['foo', ''],
['foo', 'Foo'],
[10, '10'],
];
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Validator/Rule/EqualsTest.php | tests/unit/Validator/Rule/EqualsTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Validator\Rule;
use Bluz\Tests;
use Bluz\Validator\Rule\EqualsRule as Rule;
/**
* Class EqualsTest
*
* @package Bluz\Tests\Validator\Rule
*/
class EqualsTest extends Tests\FrameworkTestCase
{
/**
* @dataProvider providerForPass
*
* @param $start
* @param $input
*/
public function testStringsContainingExpectedValueShouldPass($start, $input)
{
$rule = new Rule($start);
self::assertTrue($rule->validate($input));
self::assertNotEmpty($rule->__toString());
}
/**
* @dataProvider providerForFail
*
* @param $start
* @param $input
*/
public function testStringsNotEqualsExpectedValueShouldNotPass($start, $input)
{
$rule = new Rule($start);
self::assertFalse($rule->validate($input));
self::assertNotEmpty($rule->__toString());
}
/**
* @return array
*/
public function providerForPass(): array
{
return [
['', null],
['', false],
['', ''],
['foo', 'foo'],
[10, '10'],
];
}
/**
* @return array
*/
public function providerForFail(): array
{
return [
['foo', ''],
['foo', 'bar'],
];
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Validator/Rule/NoWhitespaceTest.php | tests/unit/Validator/Rule/NoWhitespaceTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Validator\Rule;
use Bluz\Tests;
use Bluz\Validator\Rule\NoWhitespaceRule as Rule;
/**
* Class NoWhitespaceTest
*
* @package Bluz\Tests\Validator\Rule
*/
class NoWhitespaceTest extends Tests\FrameworkTestCase
{
/**
* @var Rule
*/
protected $rule;
/**
* Setup validator instance
*/
protected function setUp(): void
{
$this->rule = new Rule();
}
/**
* @dataProvider providerForPass
*
* @param $input
*/
public function testStringWithNoWhitespaceShouldPass($input)
{
self::assertTrue($this->rule->validate($input));
self::assertNotEmpty($this->rule->__toString());
}
/**
* @dataProvider providerForFail
*
* @param $input
*/
public function testStringWithWhitespaceShouldFail($input)
{
self::assertFalse($this->rule->validate($input));
self::assertNotEmpty($this->rule->__toString());
}
/**
* @return array
*/
public function providerForPass(): array
{
return array(
[''],
[0],
['wpoiur'],
['Foo'],
);
}
/**
* @return array
*/
public function providerForFail(): array
{
return array(
[' '],
['w poiur'],
[' '],
["Foo\nBar"],
["Foo\tBar"],
);
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Validator/Rule/IpTest.php | tests/unit/Validator/Rule/IpTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Validator\Rule;
use Bluz\Tests;
use Bluz\Validator\Exception\ComponentException;
use Bluz\Validator\Rule\IpRule as Rule;
/**
* Class IpTest
*
* @package Bluz\Tests\Validator\Rule
*/
class IpTest extends Tests\FrameworkTestCase
{
/**
* @dataProvider providerForPass
*
* @param $input
* @param null $options
*/
public function testValidIpsShouldPass($input, $options = null)
{
$rule = new Rule($options);
self::assertTrue($rule->validate($input));
self::assertNotEmpty($rule->__toString());
}
/**
* @dataProvider providerForFail
*
* @param $input
* @param null $options
*/
public function testInvalidIpsShouldFail($input, $options = null)
{
$rule = new Rule($options);
self::assertFalse($rule->validate($input));
self::assertNotEmpty($rule->__toString());
}
/**
* @dataProvider providerForComponentException
*
* @param $range
*/
public function testInvalidRangeShouldRaiseException($range)
{
$this->expectException(ComponentException::class);
new Rule($range);
}
/**
* @dataProvider providerForIpBetweenRange
*
* @param $input
* @param $networkRange
*/
public function testIpsBetweenRangeShouldPass($input, $networkRange)
{
$rule = new Rule($networkRange);
self::assertTrue($rule->validate($input));
self::assertNotEmpty($rule->__toString());
}
/**
* @dataProvider providerForIpOutsideRange
*
* @param $input
* @param $networkRange
*/
public function testIpsOutsideRangeShouldFail($input, $networkRange)
{
$rule = new Rule($networkRange);
self::assertFalse($rule->validate($input));
self::assertNotEmpty($rule->__toString());
}
/**
* @return array
*/
public function providerForPass(): array
{
return [
['127.0.0.1'],
];
}
/**
* @return array
*/
public function providerForFail(): array
{
return array(
[null],
[''],
['j'],
[' '],
['Foo'],
['192.168.0.1', FILTER_FLAG_NO_PRIV_RANGE],
);
}
/**
* @return array
*/
public function providerForComponentException(): array
{
return array(
['192.168'],
['asd'],
['192.168.0.0-192.168.0.256'],
['192.168.0.0-192.168.0.1/4'],
['192.168.0.256-192.168.0.255'],
['192.168.0/1'],
['192.168.2.0/256.256.256.256'],
['192.168.2.0/8.256.256.256'],
);
}
/**
* @return array
*/
public function providerForIpBetweenRange(): array
{
return array(
['127.0.0.1', '127.*'],
['127.0.0.1', '127.0.*'],
['127.0.0.1', '127.0.0.*'],
['192.168.2.6', '192.168.*.6'],
['192.168.2.6', '192.*.2.6'],
['10.168.2.6', '*.168.2.6'],
['192.168.2.6', '192.168.*.*'],
['192.10.2.6', '192.*.*.*'],
['192.168.255.156', '*'],
['192.168.255.156', '*.*.*.*'],
['127.0.0.1', '127.0.0.0-127.0.0.255'],
['192.168.2.6', '192.168.0.0-192.168.255.255'],
['192.10.2.6', '192.0.0.0-192.255.255.255'],
['192.168.255.156', '0.0.0.0-255.255.255.255'],
['220.78.173.2', '220.78.168/21'],
['220.78.173.2', '220.78.168.0/21'],
['220.78.173.2', '220.78.168.0/255.255.248.0'],
);
}
/**
* @return array
*/
public function providerForIpOutsideRange(): array
{
return array(
['127.0.0.1', '127.0.1.*'],
['192.168.2.6', '192.163.*.*'],
['192.10.2.6', '193.*.*.*'],
['127.0.0.1', '127.0.1.0-127.0.1.255'],
['192.168.2.6', '192.163.0.0-192.163.255.255'],
['192.10.2.6', '193.168.0.0-193.255.255.255'],
['220.78.176.1', '220.78.168/21'],
['220.78.176.2', '220.78.168.0/21'],
['220.78.176.3', '220.78.168.0/255.255.248.0'],
);
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Validator/Rule/ContainsStrictTest.php | tests/unit/Validator/Rule/ContainsStrictTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Validator\Rule;
use Bluz\Tests;
use Bluz\Validator\Rule\ContainsStrictRule as Rule;
/**
* Class ContainsTest
*
* @package Bluz\Tests\Validator\Rule
*/
class ContainsStrictTest extends Tests\FrameworkTestCase
{
/**
* @dataProvider providerForPass
*
* @param $start
* @param $input
*/
public function testStringsContainingExpectedValueShouldPass($start, $input)
{
$rule = new Rule($start);
self::assertTrue($rule->validate($input));
self::assertNotEmpty($rule->__toString());
}
/**
* @dataProvider providerForFail
*
* @param $start
* @param $input
*/
public function testStringsNotContainsExpectedValueShouldFail($start, $input)
{
$rule = new Rule($start);
self::assertFalse($rule->validate($input));
self::assertNotEmpty($rule->__toString());
}
/**
* @return array
*/
public function providerForPass(): array
{
return [
['foo', ['bar', 'foo']],
['foo', 'barfoo'],
[1, [1, 2, 3]],
];
}
/**
* @return array
*/
public function providerForFail(): array
{
return [
['foo', ['bar', 'Foo']],
['foo', 'barFoo'],
['1', [1, 2, 3]],
];
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Validator/Rule/CallbackTest.php | tests/unit/Validator/Rule/CallbackTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Validator\Rule;
use Bluz\Tests;
use Bluz\Validator\Rule\CallbackRule as Rule;
/**
* Class CallbackTest
*
* @package Bluz\Tests\Validator\Rule
*/
class CallbackTest extends Tests\FrameworkTestCase
{
/**
* @var Rule
*/
private $alwaysTrue;
/**
* @var Rule
*/
private $alwaysFalse;
/**
* Setup Callbacks
*/
public function setUp(): void
{
$this->alwaysTrue = new Rule(
function () {
return true;
}
);
$this->alwaysFalse = new Rule(
function () {
return false;
}
);
}
public function testCallbackValidatorShouldPassIfCallbackReturnsTrue()
{
self::assertTrue($this->alwaysTrue->validate('foo-bar'));
self::assertNotEmpty($this->alwaysFalse->__toString());
}
public function testCallbackValidatorShouldFailIfCallbackReturnsFalse()
{
self::assertFalse($this->alwaysFalse->validate('foo-bar'));
self::assertNotEmpty($this->alwaysFalse->__toString());
}
public function testCallbackValidatorShouldAcceptArrayCallbackDefinitions()
{
$rule = new Rule([$this, 'thisIsASampleCallbackUsedInsideThisTest']);
self::assertTrue($rule->validate('test'));
}
public function testCallbackValidatorShouldAcceptFunctionNamesAsString()
{
$rule = new Rule('is_string');
self::assertTrue($rule->validate('test'));
}
public function testInvalidCallbacksShouldRaiseComponentExceptionUponInstantiation()
{
$this->expectException(\TypeError::class);
new Rule(new \stdClass());
}
/**
* @return bool
*/
public function thisIsASampleCallbackUsedInsideThisTest()
{
return true;
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Session/SessionTest.php | tests/unit/Session/SessionTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\Session;
use Bluz\Session\Session;
use Bluz\Tests\FrameworkTestCase;
/**
* SessionTest
*
* @package Bluz\Tests\Session
*
* @author Anton Shevchuk
* @created 20.08.2014 13:00
*/
class SessionTest extends FrameworkTestCase
{
/**
* @var Session
*/
protected $session;
/**
* setUp
*/
public function setUp(): void
{
parent::setUp();
$this->session = new Session();
$this->session->setNamespace('testing');
$this->session->start();
}
/**
* Complex test for setter/getter
*
* @covers \Bluz\Session\Session::set()
* @covers \Bluz\Session\Session::get()
*/
public function testSetGet()
{
self::assertNull($this->session->get('foo'));
$this->session->set('foo', 'baz');
self::assertEquals('baz', $this->session->get('foo'));
}
/**
* Complex test for __isset
*
* @covers \Bluz\Session\Session::contains()
*/
public function testIsset()
{
$this->session->set('moo', 'maz');
self::assertTrue($this->session->contains('moo'));
self::assertFalse($this->session->contains('boo'));
}
/**
* Complex test for __unset
*
* @covers \Bluz\Session\Session::delete()
*/
public function testUnset()
{
$this->session->set('moo', 'maz');
$this->session->delete('moo');
self::assertNull($this->session->get('moo'));
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Proxy/MessagesTest.php | tests/unit/Proxy/MessagesTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/skeleton
*/
namespace Bluz\Tests\Proxy;
use Bluz\Messages\Messages as Target;
use Bluz\Proxy\Messages as Proxy;
use Bluz\Tests\FrameworkTestCase;
/**
* Proxy Test
*
* @package Bluz\Tests\Proxy
* @author Anton Shevchuk
*/
class MessagesTest extends FrameworkTestCase
{
public function testGetProxyInstance()
{
self::assertInstanceOf(Target::class, Proxy::getInstance());
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Proxy/CacheTest.php | tests/unit/Proxy/CacheTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/skeleton
*/
namespace Bluz\Tests\Proxy;
use Bluz\Proxy\Cache as Proxy;
use Bluz\Tests\FrameworkTestCase;
/**
* CacheTest
*
* @package Bluz\Tests\Proxy
* @author Anton Shevchuk
*/
class CacheTest extends FrameworkTestCase
{
public function testGetProxyInstanceReturnFalse()
{
self::assertFalse(Proxy::getInstance());
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Proxy/SessionTest.php | tests/unit/Proxy/SessionTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/skeleton
*/
namespace Bluz\Tests\Proxy;
use Bluz\Session\Session as Target;
use Bluz\Proxy\Session as Proxy;
use Bluz\Tests\FrameworkTestCase;
/**
* Proxy Test
*
* @package Bluz\Tests\Proxy
* @author Anton Shevchuk
*/
class SessionTest extends FrameworkTestCase
{
public function testGetProxyInstance()
{
self::assertInstanceOf(Target::class, Proxy::getInstance());
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Proxy/TranslatorTest.php | tests/unit/Proxy/TranslatorTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/skeleton
*/
namespace Bluz\Tests\Proxy;
use Bluz\Translator\Translator as Target;
use Bluz\Proxy\Translator as Proxy;
use Bluz\Tests\FrameworkTestCase;
/**
* Proxy Test
*
* @package Bluz\Tests\Proxy
* @author Anton Shevchuk
*/
class TranslatorTest extends FrameworkTestCase
{
public function testGetProxyInstance()
{
self::assertInstanceOf(Target::class, Proxy::getInstance());
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Proxy/DbTest.php | tests/unit/Proxy/DbTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/skeleton
*/
namespace Bluz\Tests\Proxy;
use Bluz\Db\Db as Target;
use Bluz\Proxy\Db as Proxy;
use Bluz\Tests\FrameworkTestCase;
/**
* Proxy Test
*
* @package Bluz\Tests\Proxy
* @author Anton Shevchuk
*/
class DbTest extends FrameworkTestCase
{
public function testGetProxyInstance()
{
self::assertInstanceOf(Target::class, Proxy::getInstance());
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Proxy/RouterTest.php | tests/unit/Proxy/RouterTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/skeleton
*/
namespace Bluz\Tests\Proxy;
use Bluz\Common\Exception\ComponentException;
use Bluz\Router\Router as Target;
use Bluz\Proxy\Router as Proxy;
use Bluz\Tests\FrameworkTestCase;
/**
* Proxy Test
*
* @package Bluz\Tests\Proxy
* @author Anton Shevchuk
*/
class RouterTest extends FrameworkTestCase
{
public function testGetAlreadyInitedProxyInstance()
{
self::assertInstanceOf(Target::class, Proxy::getInstance());
}
public function testLazyInitialInstanceShouldThrowError()
{
$this->expectException(ComponentException::class);
Proxy::resetInstance();
Proxy::getInstance();
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Proxy/AclTest.php | tests/unit/Proxy/AclTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/skeleton
*/
namespace Bluz\Tests\Proxy;
use Bluz\Acl\Acl as Target;
use Bluz\Proxy\Acl as Proxy;
use Bluz\Tests\FrameworkTestCase;
/**
* Proxy Test
*
* @package Bluz\Tests\Proxy
* @author Anton Shevchuk
*/
class AclTest extends FrameworkTestCase
{
public function testGetProxyInstance()
{
self::assertInstanceOf(Target::class, Proxy::getInstance());
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Proxy/EventManagerTest.php | tests/unit/Proxy/EventManagerTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/skeleton
*/
namespace Bluz\Tests\Proxy;
use Bluz\EventManager\EventManager as Target;
use Bluz\Proxy\EventManager as Proxy;
use Bluz\Tests\FrameworkTestCase;
/**
* Proxy Test
*
* @package Bluz\Tests\Proxy
* @author Anton Shevchuk
*/
class EventManagerTest extends FrameworkTestCase
{
public function testGetProxyInstance()
{
self::assertInstanceOf(Target::class, Proxy::getInstance());
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Proxy/HttpCacheControlTest.php | tests/unit/Proxy/HttpCacheControlTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/skeleton
*/
namespace Bluz\Tests\Proxy;
use Bluz\Common\Nil as Target;
use Bluz\Proxy\HttpCacheControl as Proxy;
use Bluz\Tests\FrameworkTestCase;
/**
* Proxy Test
*
* @package Bluz\Tests\Proxy
* @author Anton Shevchuk
*/
class HttpCacheControlTest extends FrameworkTestCase
{
public function testGetProxyInstanceReturnNilForCLI()
{
self::assertInstanceOf(Target::class, Proxy::getInstance());
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Proxy/LayoutTest.php | tests/unit/Proxy/LayoutTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/skeleton
*/
namespace Bluz\Tests\Proxy;
use Bluz\Layout\Layout as Target;
use Bluz\Proxy\Layout as Proxy;
use Bluz\Tests\FrameworkTestCase;
/**
* Proxy Test
*
* @package Bluz\Tests\Proxy
* @author Anton Shevchuk
*/
class LayoutTest extends FrameworkTestCase
{
public function testGetProxyInstance()
{
self::assertInstanceOf(Target::class, Proxy::getInstance());
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Proxy/ResponseTest.php | tests/unit/Proxy/ResponseTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/skeleton
*/
namespace Bluz\Tests\Proxy;
use Bluz\Http\Exception\RedirectException;
use Bluz\Proxy\Response;
use Bluz\Proxy\Router;
use Bluz\Tests\FrameworkTestCase;
/**
* ResponseTest
*
* @package Bluz\Tests\Proxy
* @author Anton Shevchuk
*/
class ResponseTest extends FrameworkTestCase
{
/**
* Test Helper Redirect
*/
public function testHelperRedirect()
{
$this->expectException(RedirectException::class);
Response::redirect('/');
}
/**
* Test Helper RedirectTo
*/
public function testHelperRedirectTo()
{
$this->expectException(RedirectException::class);
Response::redirectTo(Router::getDefaultModule(), Router::getDefaultController());
}
/**
* Test Helper Reload
*/
public function testHelperReload()
{
$this->expectException(RedirectException::class);
Response::reload();
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Proxy/MailerTest.php | tests/unit/Proxy/MailerTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/skeleton
*/
namespace Bluz\Tests\Proxy;
use Bluz\Mailer\Mailer as Target;
use Bluz\Proxy\Mailer as Proxy;
use Bluz\Tests\FrameworkTestCase;
/**
* Proxy Test
*
* @package Bluz\Tests\Proxy
* @author Anton Shevchuk
*/
class MailerTest extends FrameworkTestCase
{
public function testGetProxyInstance()
{
self::assertInstanceOf(Target::class, Proxy::getInstance());
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Proxy/LoggerTest.php | tests/unit/Proxy/LoggerTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/skeleton
*/
namespace Bluz\Tests\Proxy;
use Bluz\Logger\Logger as Target;
use Bluz\Proxy\Logger as Proxy;
use Bluz\Tests\FrameworkTestCase;
/**
* Proxy Test
*
* @package Bluz\Tests\Proxy
* @author Anton Shevchuk
*/
class LoggerTest extends FrameworkTestCase
{
public function testGetProxyInstance()
{
self::assertInstanceOf(Target::class, Proxy::getInstance());
}
public function testExeptionsLogger()
{
$line = __LINE__ + 2;
try {
throw new \Exception('Message');
} catch (\Exception $e) {
Proxy::exception($e);
}
$errors = Proxy::get('error');
$error = current($errors);
self::assertArrayHasSize($errors, 1);
self::assertEquals('Message [' . __FILE__ . ':' . $line . ']', $error);
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Proxy/RegistryTest.php | tests/unit/Proxy/RegistryTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/skeleton
*/
namespace Bluz\Tests\Proxy;
use Bluz\Registry\Registry as Target;
use Bluz\Proxy\Registry as Proxy;
use Bluz\Tests\FrameworkTestCase;
/**
* Proxy Test
*
* @package Bluz\Tests\Proxy
* @author Anton Shevchuk
*/
class RegistryTest extends FrameworkTestCase
{
public function testGetProxyInstance()
{
self::assertInstanceOf(Target::class, Proxy::getInstance());
}
public function testGetDataFromRegistry()
{
self::assertEquals('baz', Proxy::get('moo'));
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Proxy/ConfigTest.php | tests/unit/Proxy/ConfigTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/skeleton
*/
namespace Bluz\Tests\Proxy;
use Bluz\Config\Config as Target;
use Bluz\Proxy\Config as Proxy;
use Bluz\Tests\FrameworkTestCase;
/**
* Proxy Test
*
* @package Bluz\Tests\Proxy
* @author Anton Shevchuk
*/
class ConfigTest extends FrameworkTestCase
{
public function testGetProxyInstance()
{
self::assertInstanceOf(Target::class, Proxy::getInstance());
}
public function testGetConfigurationDataOfApplication()
{
// merged
// - configs/default/
// - configs/testing/
// hardcoded numbers of configuration items
self::assertCount(14, Proxy::get());
self::assertEquals(['foo' => 'bar'], Proxy::get('test'));
self::assertEquals('bar', Proxy::get('test', 'foo'));
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Proxy/RequestTest.php | tests/unit/Proxy/RequestTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/skeleton
*/
namespace Bluz\Tests\Proxy;
use Bluz\Http\RequestMethod;
use Bluz\Proxy\Request;
use Bluz\Tests\FrameworkTestCase;
/**
* RequestTest
*
* @package Bluz\Tests\Proxy
* @author Anton Shevchuk
*/
class RequestTest extends FrameworkTestCase
{
/**
* Test $_ENV variables
*/
public function testEnvParams()
{
$_ENV['foo'] = 'bar';
self::setRequestParams('/');
self::assertEquals('bar', Request::getEnv('foo'));
}
/**
* Test $_GET variables
*/
public function testQueryParams()
{
self::setRequestParams('/', ['foo' => 'bar']);
self::assertEquals('bar', Request::getQuery('foo'));
self::assertEquals('bar', Request::getParam('foo'));
}
/**
* Test $_POST variables
*/
public function testParsedBodyParams()
{
self::setRequestParams('/', [], ['foo' => 'bar'], RequestMethod::POST);
self::assertTrue(Request::isPost());
self::assertEquals('bar', Request::getPost('foo'));
self::assertEquals('bar', Request::getParam('foo'));
}
/**
* Test $_COOKIE variables
*/
public function testCookieParams()
{
self::setRequestParams('/', [], [], RequestMethod::GET, [], ['foo' => 'bar']);
self::assertTrue(Request::isGet());
self::assertEquals('bar', Request::getCookie('foo'));
}
/**
* Test merge of params
*/
public function testGetParams()
{
self::setRequestParams('/', ['foo' => 'bar'], ['foo' => 'baz', 'baz' => 'qux']);
self::assertEqualsArray(['foo' => 'bar', 'baz' => 'qux'], Request::getParams());
}
/**
* Test priority of params
*/
public function testGetParamPriority()
{
self::setRequestParams('/', ['foo' => 'bar'], ['foo' => 'baz']);
self::assertEquals('bar', Request::getQuery('foo'));
self::assertEquals('baz', Request::getPost('foo'));
self::assertEquals('bar', Request::getParam('foo'));
}
/**
* Test default value of params
*/
public function testGetParamDefaultValue()
{
self::setRequestParams('/');
self::assertEquals('bar', Request::getParam('foo', 'bar'));
}
public function testGetClienIp()
{
self::setRequestParams('/');
self::assertNull(Request::getClientIp());
self::assertNull(Request::getClientIp(true));
}
public function testIsCli()
{
self::setRequestParams('/');
self::assertTrue(Request::isCli());
}
public function testIsGet()
{
self::setRequestParams('/', [], [], RequestMethod::GET);
self::assertTrue(Request::isGet());
}
public function testIsPost()
{
self::setRequestParams('/', [], [], RequestMethod::POST);
self::assertTrue(Request::isPost());
}
public function testIsPut()
{
self::setRequestParams('/', [], [], RequestMethod::PUT);
self::assertTrue(Request::isPut());
}
public function testIsDelete()
{
self::setRequestParams('/', [], [], RequestMethod::DELETE);
self::assertTrue(Request::isDelete());
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/Proxy/AuthTest.php | tests/unit/Proxy/AuthTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/skeleton
*/
namespace Bluz\Tests\Proxy;
use Bluz\Auth\Auth as Target;
use Bluz\Proxy\Auth as Proxy;
use Bluz\Tests\FrameworkTestCase;
/**
* Proxy Test
*
* @package Bluz\Tests\Proxy
* @author Anton Shevchuk
*/
class AuthTest extends FrameworkTestCase
{
public function testGetProxyInstance()
{
self::assertInstanceOf(Target::class, Proxy::getInstance());
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/unit/View/ViewTest.php | tests/unit/View/ViewTest.php | <?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
*/
namespace Bluz\Tests\View;
use Bluz\Proxy\Router;
use Bluz\Tests\FrameworkTestCase;
use Bluz\View\View;
use Bluz\View\ViewException;
/**
* ViewTest
*
* @package Bluz\Tests\View
*
* @author Anton Shevchuk
* @created 11.08.2014 10:15
*/
class ViewTest extends FrameworkTestCase
{
/**
* Setup `test` table before the first test
*/
public static function setUpBeforeClass(): void
{
self::getApp();
}
/**
* Drop `test` table after the last test
*/
public static function tearDownAfterClass(): void
{
self::resetGlobals();
self::resetApp();
}
/**
* Working with View container over MagicAccess
*/
public function testMagicMethods()
{
$view = new View();
$view->foo = 'bar';
$view->baz = 'qux';
unset($view->baz);
self::assertTrue(isset($view->foo));
self::assertEquals('bar', $view->foo);
self::assertNull($view->baz);
}
/**
* Set Data Test
*/
public function testData()
{
$view = new View();
$view->setFromArray(['foo' => '---']);
$view->setFromArray(['foo' => 'bar', 'baz' => 'qux']);
self::assertEquals('bar', $view->foo);
self::assertEquals('qux', $view->baz);
self::assertEqualsArray(['foo' => 'bar', 'baz' => 'qux'], $view->toArray());
}
/**
* Test JSON serialization
*/
public function testJson()
{
$view = new View();
$view->foo = 'bar';
$view->baz = 'qux';
$view = json_decode(json_encode($view));
self::assertEquals('bar', $view->foo);
self::assertEquals('qux', $view->baz);
}
/**
* Get new View instance
*
* @return View
* @throws \Bluz\Application\Exception\ApplicationException
* @throws \Bluz\Common\Exception\CommonException
* @throws \ReflectionException
*/
protected function getView(): View
{
$view = new View();
// setup default partial path
$view->addPartialPath(self::getApp()->getPath() . '/layouts/partial');
return $view;
}
/**
* Helper Ahref
*/
public function testHelperAhref()
{
$view = $this->getView();
self::assertEmpty($view->ahref('text', null));
self::assertEquals('<a href="test/test" >text</a>', $view->ahref('text', 'test/test'));
self::assertEquals(
'<a href="/" class="active">text</a>',
$view->ahref('text', [Router::getDefaultModule(), Router::getDefaultController()])
);
self::assertEquals(
'<a href="/" class="foo active">text</a>',
$view->ahref('text', [Router::getDefaultModule(), Router::getDefaultController()], ['class' => 'foo'])
);
}
/**
* Helper Attributes
*/
public function testHelperAttributes()
{
$view = $this->getView();
self::assertEmpty($view->attributes([]));
$result = $view->attributes(['foo' => 'bar', 'baz' => null, 'qux']);
self::assertEquals('foo="bar" qux', $result);
}
/**
* Helper BaseUrl
*/
public function testHelperBaseUrl()
{
$view = $this->getView();
self::assertEquals('/', $view->baseUrl());
self::assertEquals('/about.html', $view->baseUrl('/about.html'));
}
/**
* Helper Checkbox
*/
public function testHelperCheckbox()
{
$view = $this->getView();
$result = $view->checkbox('test', 1, true, ['class' => 'foo']);
self::assertEquals('<input class="foo" checked="checked" value="1" name="test" type="checkbox"/>', $result);
$result = $view->checkbox('sex', 'male', 'male', ['class' => 'foo']);
self::assertEquals('<input class="foo" checked="checked" value="male" name="sex" type="checkbox"/>', $result);
}
/**
* Helper Controller
*/
public function testHelperController()
{
$view = $this->getView();
self::assertEquals(Router::getDefaultController(), $view->controller());
self::assertTrue($view->controller(Router::getDefaultController()));
}
/**
* Helper Dispatch
* - this Controller is not exists -> call Exception helper
*/
public function testHelperDispatch()
{
$view = $this->getView();
self::assertEmpty($view->dispatch('helper', 'dispatch'));
}
/**
* Helper Exception
* - should be empty for disabled debug
*/
public function testHelperException()
{
$view = $this->getView();
self::assertEmpty($view->exception(new \Exception()));
}
/**
* Helper Gravatar
* - should return URL to gravatar
*/
public function testHelperGravatar()
{
$view = $this->getView();
self::assertEquals(
'https://www.gravatar.com/avatar/56887ad8e17c7c6f6f4f95caee8ad028?s=80&d=mm&r=g',
$view->gravatar('admin@bluzphp.github.com')
);
}
/**
* Helper Has Module
* - should return true, if module directory is exists
* - should return false, if directory not exists
*/
public function testHelperHasModule()
{
$view = $this->getView();
self::assertTrue($view->hasModule('index'));
self::assertFalse($view->hasModule(uniqid('index', true)));
}
/**
* Helper Script
*/
public function testHelperHeadScript()
{
$view = $this->getView();
$view->headScript('foo.js');
$view->headScript('bar.js');
$result = $view->headScript();
self::assertEquals(
'<script src="/foo.js" ></script>' .
'<script src="/bar.js" ></script>',
str_replace(["\t", "\n", "\r"], '', $result)
);
}
/**
* Helper Style
*/
public function testHelperHeadStyle()
{
$view = $this->getView();
$view->headStyle('foo.css');
$view->headStyle('bar.css');
$result = $view->headStyle();
self::assertEquals(
'<link href="/foo.css" rel="stylesheet" media="all"/>' .
'<link href="/bar.css" rel="stylesheet" media="all"/>',
str_replace(["\t", "\n", "\r"], '', $result)
);
}
/**
* Helper Module
*/
public function testHelperModule()
{
$view = $this->getView();
self::assertEquals(Router::getDefaultModule(), $view->module());
self::assertTrue($view->module(Router::getDefaultModule()));
}
/**
* Helper Partial
*/
public function testHelperPartial()
{
$view = $this->getView();
$view->setPath(self::getApp()->getPath() . '/modules/index/views');
$result = $view->partial('partial/partial.phtml', ['foo' => 'bar']);
self::assertEquals('bar', $result);
}
/**
* Helper Partial throws
*/
public function testHelperPartialNotFoundTrowsException()
{
$this->expectException(ViewException::class);
$view = $this->getView();
$view->partial('file-not-exists.phtml');
}
/**
* Helper Partial Loop
*/
public function testHelperPartialLoop()
{
$view = $this->getView();
$view->setPath(self::getApp()->getPath() . '/modules/index/views');
$result = $view->partialLoop('partial/partial-loop.phtml', [1, 2, 3], ['foo' => 'bar']);
self::assertEquals('bar:0:1:bar:1:2:bar:2:3:', $result);
}
/**
* Helper Partial Loop throws
*/
public function testHelperPartialLoopInvalidArgumentsTrowsException()
{
$this->expectException(\InvalidArgumentException::class);
$view = $this->getView();
$view->partialLoop('file-not-exists.phtml', null);
}
/**
* Helper Partial Loop throws
*/
public function testHelperPartialLoopNotFoundTrowsException()
{
$this->expectException(ViewException::class);
$view = $this->getView();
$view->partialLoop('file-not-exists.phtml', ['foo', 'bar']);
}
/**
* Helper Radio
*/
public function testHelperRadio()
{
$view = $this->getView();
$result = $view->radio('test', 1, true, ['class' => 'foo']);
self::assertEquals('<input class="foo" checked="checked" value="1" name="test" type="radio"/>', $result);
}
/**
* Helper Redactor
*/
public function testHelperRedactor()
{
$view = $this->getView();
$result = $view->redactor('#editor');
self::assertNotEmpty($result);
}
/**
* Helper Script
*/
public function testHelperScript()
{
$view = $this->getView();
$result = $view->script('foo.js', ['async']);
self::assertEquals('<script src="/foo.js" async></script>', trim($result));
}
/**
* Helper Script inline
*/
public function testHelperScriptBlock()
{
$view = $this->getView();
$result = $view->scriptBlock('alert("foo=bar")');
$result = str_replace(["\t", "\n", "\r"], '', $result);
self::assertEquals('<script type="text/javascript"><!--alert("foo=bar")//--></script>', $result);
}
/**
* Helper Select
*/
public function testHelperSelect()
{
$view = $this->getView();
$result = $view->select(
'car',
[
'none' => "No Car",
'class-A' => [
'citroen-c1' => 'Citroen C1',
'mercedes-benz-a200' => 'Mercedes Benz A200',
],
'class-B' => [
'audi-a1' => 'Audi A1',
'citroen-c3' => 'Citroen C3',
],
],
null,
[
'id' => 'car'
]
);
$result = str_replace(["\t", "\n", "\r"], '', $result);
self::assertEquals(
'<select id="car" name="car">' .
'<option value="none">No Car</option>' .
'<optgroup label="class-A">' .
'<option value="citroen-c1">Citroen C1</option>' .
'<option value="mercedes-benz-a200">Mercedes Benz A200</option>' .
'</optgroup>' .
'<optgroup label="class-B">' .
'<option value="audi-a1">Audi A1</option>' .
'<option value="citroen-c3">Citroen C3</option>' .
'</optgroup>' .
'</select>',
$result
);
}
/**
* Helper Select
*/
public function testHelperSelectWithSelectedElement()
{
$view = $this->getView();
$result = $view->select(
'car',
[
'none' => 'No Car',
'citroen-c1' => 'Citroen C1',
'citroen-c3' => 'Citroen C3',
'citroen-c4' => 'Citroen C4',
],
'citroen-c4',
[
'id' => 'car'
]
);
$result = str_replace(["\t", "\n", "\r"], '', $result);
self::assertEquals(
'<select id="car" name="car">' .
'<option value="none">No Car</option>' .
'<option value="citroen-c1">Citroen C1</option>' .
'<option value="citroen-c3">Citroen C3</option>' .
'<option value="citroen-c4" selected="selected">Citroen C4</option>' .
'</select>',
$result
);
}
/**
* Helper Select
*/
public function testHelperSelectMultiple()
{
$view = $this->getView();
$result = $view->select(
'car',
[
'citroen-c1' => 'Citroen C1',
'mercedes-benz-a200' => 'Mercedes Benz A200',
'audi-a1' => 'Audi A1',
'citroen-c3' => 'Citroen C3',
],
[
'citroen-c1',
'citroen-c3'
]
);
$result = str_replace(["\t", "\n", "\r"], '', $result);
self::assertEquals(
'<select name="car" multiple="multiple">' .
'<option value="citroen-c1" selected="selected">Citroen C1</option>' .
'<option value="mercedes-benz-a200">Mercedes Benz A200</option>' .
'<option value="audi-a1">Audi A1</option>' .
'<option value="citroen-c3" selected="selected">Citroen C3</option>' .
'</select>',
$result
);
}
/**
* Helper Style
*/
public function testHelperStyle()
{
$view = $this->getView();
$result = $view->style('foo.css');
self::assertEquals('<link href="/foo.css" rel="stylesheet" media="all"/>', trim($result));
}
/**
* Helper Style inline
*/
public function testHelperStyleBlock()
{
$view = $this->getView();
$result = $view->styleBlock('#my{color:red}');
$result = str_replace(["\t", "\n", "\r"], '', $result);
self::assertEquals('<style type="text/css" media="all">#my{color:red}</style>', $result);
}
/**
* Helper Url
*/
public function testHelperUrl()
{
$view = $this->getView();
self::assertEquals('/test/test/foo/bar', $view->url('test', 'test', ['foo' => 'bar']));
self::assertEquals('/test/test', $view->url('test', 'test', null));
self::assertEquals('/test', $view->url('test', null));
self::assertEquals('/index/test', $view->url(null, 'test'));
}
/**
* Helper Url Exceptions
*/
public function testHelperUrlException()
{
$this->expectException(ViewException::class);
$view = $this->getView();
self::assertEquals('/test/test', $view->url('test', 'test', [], true));
}
/**
* Helper User
*/
public function testHelperUser()
{
$view = $this->getView();
self::assertNull($view->user());
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/_support/AcceptanceTester.php | tests/_support/AcceptanceTester.php | <?php
/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = null)
*
* @SuppressWarnings(PHPMD)
*/
class AcceptanceTester extends \Codeception\Actor
{
use _generated\AcceptanceTesterActions;
/**
* Define custom actions here
*/
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/_support/UnitTester.php | tests/_support/UnitTester.php | <?php
/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = null)
*
* @SuppressWarnings(PHPMD)
*/
class UnitTester extends \Codeception\Actor
{
use _generated\UnitTesterActions;
/**
* Define custom actions here
*/
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/_support/FunctionalTester.php | tests/_support/FunctionalTester.php | <?php
/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = null)
*
* @SuppressWarnings(PHPMD)
*/
class FunctionalTester extends \Codeception\Actor
{
use _generated\FunctionalTesterActions;
/**
* Define custom actions here
*/
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/_support/Helper/Functional.php | tests/_support/Helper/Functional.php | <?php
namespace Helper;
// here you can define custom actions
// all public methods declared in helper class will be available in $I
class Functional extends \Codeception\Module
{
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/_support/Helper/Unit.php | tests/_support/Helper/Unit.php | <?php
namespace Helper;
// here you can define custom actions
// all public methods declared in helper class will be available in $I
class Unit extends \Codeception\Module
{
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/_support/Helper/Acceptance.php | tests/_support/Helper/Acceptance.php | <?php
namespace Helper;
// here you can define custom actions
// all public methods declared in helper class will be available in $I
class Acceptance extends \Codeception\Module
{
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/_support/_generated/AcceptanceTesterActions.php | tests/_support/_generated/AcceptanceTesterActions.php | <?php //[STAMP] f7ba3eae5c564c3fcb040f83083572c6
namespace _generated;
// This class was automatically generated by build task
// You should not change it manually as it will be overwritten on next build
// @codingStandardsIgnoreFile
trait AcceptanceTesterActions
{
/**
* @return \Codeception\Scenario
*/
abstract protected function getScenario();
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Alias to `haveHttpHeader`
*
* @param $name
* @param $value
* @see \Codeception\Module\PhpBrowser::setHeader()
*/
public function setHeader($name, $value) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('setHeader', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Authenticates user for HTTP_AUTH
*
* @param $username
* @param $password
* @see \Codeception\Module\PhpBrowser::amHttpAuthenticated()
*/
public function amHttpAuthenticated($username, $password) {
return $this->getScenario()->runStep(new \Codeception\Step\Condition('amHttpAuthenticated', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Open web page at the given absolute URL and sets its hostname as the base host.
*
* ``` php
* <?php
* $I->amOnUrl('http://codeception.com');
* $I->amOnPage('/quickstart'); // moves to http://codeception.com/quickstart
* ?>
* ```
* @see \Codeception\Module\PhpBrowser::amOnUrl()
*/
public function amOnUrl($url) {
return $this->getScenario()->runStep(new \Codeception\Step\Condition('amOnUrl', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Changes the subdomain for the 'url' configuration parameter.
* Does not open a page; use `amOnPage` for that.
*
* ``` php
* <?php
* // If config is: 'http://mysite.com'
* // or config is: 'http://www.mysite.com'
* // or config is: 'http://company.mysite.com'
*
* $I->amOnSubdomain('user');
* $I->amOnPage('/');
* // moves to http://user.mysite.com/
* ?>
* ```
*
* @param $subdomain
*
* @return mixed
* @see \Codeception\Module\PhpBrowser::amOnSubdomain()
*/
public function amOnSubdomain($subdomain) {
return $this->getScenario()->runStep(new \Codeception\Step\Condition('amOnSubdomain', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Low-level API method.
* If Codeception commands are not enough, use [Guzzle HTTP Client](http://guzzlephp.org/) methods directly
*
* Example:
*
* ``` php
* <?php
* $I->executeInGuzzle(function (\GuzzleHttp\Client $client) {
* $client->get('/get', ['query' => ['foo' => 'bar']]);
* });
* ?>
* ```
*
* It is not recommended to use this command on a regular basis.
* If Codeception lacks important Guzzle Client methods, implement them and submit patches.
*
* @param callable $function
* @see \Codeception\Module\PhpBrowser::executeInGuzzle()
*/
public function executeInGuzzle($function) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('executeInGuzzle', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Sets the HTTP header to the passed value - which is used on
* subsequent HTTP requests through PhpBrowser.
*
* Example:
* ```php
* <?php
* $I->haveHttpHeader('X-Requested-With', 'Codeception');
* $I->amOnPage('test-headers.php');
* ?>
* ```
*
* To use special chars in Header Key use HTML Character Entities:
* Example:
* Header with underscore - 'Client_Id'
* should be represented as - 'Client_Id' or 'Client_Id'
*
* ```php
* <?php
* $I->haveHttpHeader('Client_Id', 'Codeception');
* ?>
* ```
*
* @param string $name the name of the request header
* @param string $value the value to set it to for subsequent
* requests
* @see \Codeception\Lib\InnerBrowser::haveHttpHeader()
*/
public function haveHttpHeader($name, $value) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('haveHttpHeader', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Deletes the header with the passed name. Subsequent requests
* will not have the deleted header in its request.
*
* Example:
* ```php
* <?php
* $I->haveHttpHeader('X-Requested-With', 'Codeception');
* $I->amOnPage('test-headers.php');
* // ...
* $I->deleteHeader('X-Requested-With');
* $I->amOnPage('some-other-page.php');
* ?>
* ```
*
* @param string $name the name of the header to delete.
* @see \Codeception\Lib\InnerBrowser::deleteHeader()
*/
public function deleteHeader($name) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('deleteHeader', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Opens the page for the given relative URI.
*
* ``` php
* <?php
* // opens front page
* $I->amOnPage('/');
* // opens /register page
* $I->amOnPage('/register');
* ```
*
* @param string $page
* @see \Codeception\Lib\InnerBrowser::amOnPage()
*/
public function amOnPage($page) {
return $this->getScenario()->runStep(new \Codeception\Step\Condition('amOnPage', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Perform a click on a link or a button, given by a locator.
* If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string.
* For buttons, the "value" attribute, "name" attribute, and inner text are searched.
* For links, the link text is searched.
* For images, the "alt" attribute and inner text of any parent links are searched.
*
* The second parameter is a context (CSS or XPath locator) to narrow the search.
*
* Note that if the locator matches a button of type `submit`, the form will be submitted.
*
* ``` php
* <?php
* // simple link
* $I->click('Logout');
* // button of form
* $I->click('Submit');
* // CSS button
* $I->click('#form input[type=submit]');
* // XPath
* $I->click('//form/*[@type="submit"]');
* // link in context
* $I->click('Logout', '#nav');
* // using strict locator
* $I->click(['link' => 'Login']);
* ?>
* ```
*
* @param $link
* @param $context
* @see \Codeception\Lib\InnerBrowser::click()
*/
public function click($link, $context = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('click', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that the current page contains the given string (case insensitive).
*
* You can specify a specific HTML element (via CSS or XPath) as the second
* parameter to only search within that element.
*
* ``` php
* <?php
* $I->see('Logout'); // I can suppose user is logged in
* $I->see('Sign Up', 'h1'); // I can suppose it's a signup page
* $I->see('Sign Up', '//body/h1'); // with XPath
* $I->see('Sign Up', ['css' => 'body h1']); // with strict CSS locator
* ```
*
* Note that the search is done after stripping all HTML tags from the body,
* so `$I->see('strong')` will return true for strings like:
*
* - `<p>I am Stronger than thou</p>`
* - `<script>document.createElement('strong');</script>`
*
* But will *not* be true for strings like:
*
* - `<strong>Home</strong>`
* - `<div class="strong">Home</strong>`
* - `<!-- strong -->`
*
* For checking the raw source code, use `seeInSource()`.
*
* @param string $text
* @param array|string $selector optional
* Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Lib\InnerBrowser::see()
*/
public function canSee($text, $selector = null) {
return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('see', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that the current page contains the given string (case insensitive).
*
* You can specify a specific HTML element (via CSS or XPath) as the second
* parameter to only search within that element.
*
* ``` php
* <?php
* $I->see('Logout'); // I can suppose user is logged in
* $I->see('Sign Up', 'h1'); // I can suppose it's a signup page
* $I->see('Sign Up', '//body/h1'); // with XPath
* $I->see('Sign Up', ['css' => 'body h1']); // with strict CSS locator
* ```
*
* Note that the search is done after stripping all HTML tags from the body,
* so `$I->see('strong')` will return true for strings like:
*
* - `<p>I am Stronger than thou</p>`
* - `<script>document.createElement('strong');</script>`
*
* But will *not* be true for strings like:
*
* - `<strong>Home</strong>`
* - `<div class="strong">Home</strong>`
* - `<!-- strong -->`
*
* For checking the raw source code, use `seeInSource()`.
*
* @param string $text
* @param array|string $selector optional
* @see \Codeception\Lib\InnerBrowser::see()
*/
public function see($text, $selector = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Assertion('see', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that the current page doesn't contain the text specified (case insensitive).
* Give a locator as the second parameter to match a specific region.
*
* ```php
* <?php
* $I->dontSee('Login'); // I can suppose user is already logged in
* $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page
* $I->dontSee('Sign Up','//body/h1'); // with XPath
* $I->dontSee('Sign Up', ['css' => 'body h1']); // with strict CSS locator
* ```
*
* Note that the search is done after stripping all HTML tags from the body,
* so `$I->dontSee('strong')` will fail on strings like:
*
* - `<p>I am Stronger than thou</p>`
* - `<script>document.createElement('strong');</script>`
*
* But will ignore strings like:
*
* - `<strong>Home</strong>`
* - `<div class="strong">Home</strong>`
* - `<!-- strong -->`
*
* For checking the raw source code, use `seeInSource()`.
*
* @param string $text
* @param array|string $selector optional
* Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Lib\InnerBrowser::dontSee()
*/
public function cantSee($text, $selector = null) {
return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSee', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that the current page doesn't contain the text specified (case insensitive).
* Give a locator as the second parameter to match a specific region.
*
* ```php
* <?php
* $I->dontSee('Login'); // I can suppose user is already logged in
* $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page
* $I->dontSee('Sign Up','//body/h1'); // with XPath
* $I->dontSee('Sign Up', ['css' => 'body h1']); // with strict CSS locator
* ```
*
* Note that the search is done after stripping all HTML tags from the body,
* so `$I->dontSee('strong')` will fail on strings like:
*
* - `<p>I am Stronger than thou</p>`
* - `<script>document.createElement('strong');</script>`
*
* But will ignore strings like:
*
* - `<strong>Home</strong>`
* - `<div class="strong">Home</strong>`
* - `<!-- strong -->`
*
* For checking the raw source code, use `seeInSource()`.
*
* @param string $text
* @param array|string $selector optional
* @see \Codeception\Lib\InnerBrowser::dontSee()
*/
public function dontSee($text, $selector = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSee', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that the current page contains the given string in its
* raw source code.
*
* ``` php
* <?php
* $I->seeInSource('<h1>Green eggs & ham</h1>');
* ```
*
* @param $raw
* Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Lib\InnerBrowser::seeInSource()
*/
public function canSeeInSource($raw) {
return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInSource', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that the current page contains the given string in its
* raw source code.
*
* ``` php
* <?php
* $I->seeInSource('<h1>Green eggs & ham</h1>');
* ```
*
* @param $raw
* @see \Codeception\Lib\InnerBrowser::seeInSource()
*/
public function seeInSource($raw) {
return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInSource', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that the current page contains the given string in its
* raw source code.
*
* ```php
* <?php
* $I->dontSeeInSource('<h1>Green eggs & ham</h1>');
* ```
*
* @param $raw
* Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Lib\InnerBrowser::dontSeeInSource()
*/
public function cantSeeInSource($raw) {
return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInSource', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that the current page contains the given string in its
* raw source code.
*
* ```php
* <?php
* $I->dontSeeInSource('<h1>Green eggs & ham</h1>');
* ```
*
* @param $raw
* @see \Codeception\Lib\InnerBrowser::dontSeeInSource()
*/
public function dontSeeInSource($raw) {
return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInSource', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that there's a link with the specified text.
* Give a full URL as the second parameter to match links with that exact URL.
*
* ``` php
* <?php
* $I->seeLink('Logout'); // matches <a href="#">Logout</a>
* $I->seeLink('Logout','/logout'); // matches <a href="/logout">Logout</a>
* ?>
* ```
*
* @param string $text
* @param string $url optional
* Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Lib\InnerBrowser::seeLink()
*/
public function canSeeLink($text, $url = null) {
return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeLink', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that there's a link with the specified text.
* Give a full URL as the second parameter to match links with that exact URL.
*
* ``` php
* <?php
* $I->seeLink('Logout'); // matches <a href="#">Logout</a>
* $I->seeLink('Logout','/logout'); // matches <a href="/logout">Logout</a>
* ?>
* ```
*
* @param string $text
* @param string $url optional
* @see \Codeception\Lib\InnerBrowser::seeLink()
*/
public function seeLink($text, $url = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeLink', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that the page doesn't contain a link with the given string.
* If the second parameter is given, only links with a matching "href" attribute will be checked.
*
* ``` php
* <?php
* $I->dontSeeLink('Logout'); // I suppose user is not logged in
* $I->dontSeeLink('Checkout now', '/store/cart.php');
* ?>
* ```
*
* @param string $text
* @param string $url optional
* Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Lib\InnerBrowser::dontSeeLink()
*/
public function cantSeeLink($text, $url = null) {
return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeLink', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that the page doesn't contain a link with the given string.
* If the second parameter is given, only links with a matching "href" attribute will be checked.
*
* ``` php
* <?php
* $I->dontSeeLink('Logout'); // I suppose user is not logged in
* $I->dontSeeLink('Checkout now', '/store/cart.php');
* ?>
* ```
*
* @param string $text
* @param string $url optional
* @see \Codeception\Lib\InnerBrowser::dontSeeLink()
*/
public function dontSeeLink($text, $url = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeLink', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that current URI contains the given string.
*
* ``` php
* <?php
* // to match: /home/dashboard
* $I->seeInCurrentUrl('home');
* // to match: /users/1
* $I->seeInCurrentUrl('/users/');
* ?>
* ```
*
* @param string $uri
* Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Lib\InnerBrowser::seeInCurrentUrl()
*/
public function canSeeInCurrentUrl($uri) {
return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInCurrentUrl', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that current URI contains the given string.
*
* ``` php
* <?php
* // to match: /home/dashboard
* $I->seeInCurrentUrl('home');
* // to match: /users/1
* $I->seeInCurrentUrl('/users/');
* ?>
* ```
*
* @param string $uri
* @see \Codeception\Lib\InnerBrowser::seeInCurrentUrl()
*/
public function seeInCurrentUrl($uri) {
return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInCurrentUrl', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that the current URI doesn't contain the given string.
*
* ``` php
* <?php
* $I->dontSeeInCurrentUrl('/users/');
* ?>
* ```
*
* @param string $uri
* Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Lib\InnerBrowser::dontSeeInCurrentUrl()
*/
public function cantSeeInCurrentUrl($uri) {
return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInCurrentUrl', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that the current URI doesn't contain the given string.
*
* ``` php
* <?php
* $I->dontSeeInCurrentUrl('/users/');
* ?>
* ```
*
* @param string $uri
* @see \Codeception\Lib\InnerBrowser::dontSeeInCurrentUrl()
*/
public function dontSeeInCurrentUrl($uri) {
return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInCurrentUrl', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that the current URL is equal to the given string.
* Unlike `seeInCurrentUrl`, this only matches the full URL.
*
* ``` php
* <?php
* // to match root url
* $I->seeCurrentUrlEquals('/');
* ?>
* ```
*
* @param string $uri
* Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Lib\InnerBrowser::seeCurrentUrlEquals()
*/
public function canSeeCurrentUrlEquals($uri) {
return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCurrentUrlEquals', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that the current URL is equal to the given string.
* Unlike `seeInCurrentUrl`, this only matches the full URL.
*
* ``` php
* <?php
* // to match root url
* $I->seeCurrentUrlEquals('/');
* ?>
* ```
*
* @param string $uri
* @see \Codeception\Lib\InnerBrowser::seeCurrentUrlEquals()
*/
public function seeCurrentUrlEquals($uri) {
return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCurrentUrlEquals', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that the current URL doesn't equal the given string.
* Unlike `dontSeeInCurrentUrl`, this only matches the full URL.
*
* ``` php
* <?php
* // current url is not root
* $I->dontSeeCurrentUrlEquals('/');
* ?>
* ```
*
* @param string $uri
* Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlEquals()
*/
public function cantSeeCurrentUrlEquals($uri) {
return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCurrentUrlEquals', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that the current URL doesn't equal the given string.
* Unlike `dontSeeInCurrentUrl`, this only matches the full URL.
*
* ``` php
* <?php
* // current url is not root
* $I->dontSeeCurrentUrlEquals('/');
* ?>
* ```
*
* @param string $uri
* @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlEquals()
*/
public function dontSeeCurrentUrlEquals($uri) {
return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeCurrentUrlEquals', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that the current URL matches the given regular expression.
*
* ``` php
* <?php
* // to match root url
* $I->seeCurrentUrlMatches('~^/users/(\d+)~');
* ?>
* ```
*
* @param string $uri
* Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Lib\InnerBrowser::seeCurrentUrlMatches()
*/
public function canSeeCurrentUrlMatches($uri) {
return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCurrentUrlMatches', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that the current URL matches the given regular expression.
*
* ``` php
* <?php
* // to match root url
* $I->seeCurrentUrlMatches('~^/users/(\d+)~');
* ?>
* ```
*
* @param string $uri
* @see \Codeception\Lib\InnerBrowser::seeCurrentUrlMatches()
*/
public function seeCurrentUrlMatches($uri) {
return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCurrentUrlMatches', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that current url doesn't match the given regular expression.
*
* ``` php
* <?php
* // to match root url
* $I->dontSeeCurrentUrlMatches('~^/users/(\d+)~');
* ?>
* ```
*
* @param string $uri
* Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlMatches()
*/
public function cantSeeCurrentUrlMatches($uri) {
return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCurrentUrlMatches', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that current url doesn't match the given regular expression.
*
* ``` php
* <?php
* // to match root url
* $I->dontSeeCurrentUrlMatches('~^/users/(\d+)~');
* ?>
* ```
*
* @param string $uri
* @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlMatches()
*/
public function dontSeeCurrentUrlMatches($uri) {
return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeCurrentUrlMatches', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Executes the given regular expression against the current URI and returns the first capturing group.
* If no parameters are provided, the full URI is returned.
*
* ``` php
* <?php
* $user_id = $I->grabFromCurrentUrl('~^/user/(\d+)/~');
* $uri = $I->grabFromCurrentUrl();
* ?>
* ```
*
* @param string $uri optional
*
* @return mixed
* @see \Codeception\Lib\InnerBrowser::grabFromCurrentUrl()
*/
public function grabFromCurrentUrl($uri = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('grabFromCurrentUrl', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that the specified checkbox is checked.
*
* ``` php
* <?php
* $I->seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms
* $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user agreed to terms, If there is only one checkbox in form.
* $I->seeCheckboxIsChecked('//form/input[@type=checkbox and @name=agree]');
* ?>
* ```
*
* @param $checkbox
* Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Lib\InnerBrowser::seeCheckboxIsChecked()
*/
public function canSeeCheckboxIsChecked($checkbox) {
return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCheckboxIsChecked', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that the specified checkbox is checked.
*
* ``` php
* <?php
* $I->seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms
* $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user agreed to terms, If there is only one checkbox in form.
* $I->seeCheckboxIsChecked('//form/input[@type=checkbox and @name=agree]');
* ?>
* ```
*
* @param $checkbox
* @see \Codeception\Lib\InnerBrowser::seeCheckboxIsChecked()
*/
public function seeCheckboxIsChecked($checkbox) {
return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCheckboxIsChecked', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Check that the specified checkbox is unchecked.
*
* ``` php
* <?php
* $I->dontSeeCheckboxIsChecked('#agree'); // I suppose user didn't agree to terms
* $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user didn't check the first checkbox in form.
* ?>
* ```
*
* @param $checkbox
* Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Lib\InnerBrowser::dontSeeCheckboxIsChecked()
*/
public function cantSeeCheckboxIsChecked($checkbox) {
return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCheckboxIsChecked', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Check that the specified checkbox is unchecked.
*
* ``` php
* <?php
* $I->dontSeeCheckboxIsChecked('#agree'); // I suppose user didn't agree to terms
* $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user didn't check the first checkbox in form.
* ?>
* ```
*
* @param $checkbox
* @see \Codeception\Lib\InnerBrowser::dontSeeCheckboxIsChecked()
*/
public function dontSeeCheckboxIsChecked($checkbox) {
return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeCheckboxIsChecked', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that the given input field or textarea *equals* (i.e. not just contains) the given value.
* Fields are matched by label text, the "name" attribute, CSS, or XPath.
*
* ``` php
* <?php
* $I->seeInField('Body','Type your comment here');
* $I->seeInField('form textarea[name=body]','Type your comment here');
* $I->seeInField('form input[type=hidden]','hidden_value');
* $I->seeInField('#searchform input','Search');
* $I->seeInField('//form/*[@name=search]','Search');
* $I->seeInField(['name' => 'search'], 'Search');
* ?>
* ```
*
* @param $field
* @param $value
* Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Lib\InnerBrowser::seeInField()
*/
public function canSeeInField($field, $value) {
return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInField', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that the given input field or textarea *equals* (i.e. not just contains) the given value.
* Fields are matched by label text, the "name" attribute, CSS, or XPath.
*
* ``` php
* <?php
* $I->seeInField('Body','Type your comment here');
* $I->seeInField('form textarea[name=body]','Type your comment here');
* $I->seeInField('form input[type=hidden]','hidden_value');
* $I->seeInField('#searchform input','Search');
* $I->seeInField('//form/*[@name=search]','Search');
* $I->seeInField(['name' => 'search'], 'Search');
* ?>
* ```
*
* @param $field
* @param $value
* @see \Codeception\Lib\InnerBrowser::seeInField()
*/
public function seeInField($field, $value) {
return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInField', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that an input field or textarea doesn't contain the given value.
* For fuzzy locators, the field is matched by label text, CSS and XPath.
*
* ``` php
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | true |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/_support/_generated/FunctionalTesterActions.php | tests/_support/_generated/FunctionalTesterActions.php | <?php //[STAMP] e8872b12590e3101b504ba5587978728
namespace _generated;
// This class was automatically generated by build task
// You should not change it manually as it will be overwritten on next build
// @codingStandardsIgnoreFile
trait FunctionalTesterActions
{
/**
* @return \Codeception\Scenario
*/
abstract protected function getScenario();
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/_support/_generated/UnitTesterActions.php | tests/_support/_generated/UnitTesterActions.php | <?php //[STAMP] 4eeec53cfd31e4fe39ec44082985bab0
namespace _generated;
// This class was automatically generated by build task
// You should not change it manually as it will be overwritten on next build
// @codingStandardsIgnoreFile
trait UnitTesterActions
{
/**
* @return \Codeception\Scenario
*/
abstract protected function getScenario();
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Handles and checks exception called inside callback function.
* Either exception class name or exception instance should be provided.
*
* ```php
* <?php
* $I->expectException(MyException::class, function() {
* $this->doSomethingBad();
* });
*
* $I->expectException(new MyException(), function() {
* $this->doSomethingBad();
* });
* ```
* If you want to check message or exception code, you can pass them with exception instance:
* ```php
* <?php
* // will check that exception MyException is thrown with "Don't do bad things" message
* $I->expectException(new MyException("Don't do bad things"), function() {
* $this->doSomethingBad();
* });
* ```
*
* @deprecated Use expectThrowable() instead
* @param \Exception|string $exception
* @param callable $callback
* @see \Codeception\Module\Asserts::expectException()
*/
public function expectException($exception, $callback) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('expectException', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Handles and checks throwables (Exceptions/Errors) called inside the callback function.
* Either throwable class name or throwable instance should be provided.
*
* ```php
* <?php
* $I->expectThrowable(MyThrowable::class, function() {
* $this->doSomethingBad();
* });
*
* $I->expectThrowable(new MyException(), function() {
* $this->doSomethingBad();
* });
* ```
* If you want to check message or throwable code, you can pass them with throwable instance:
* ```php
* <?php
* // will check that throwable MyError is thrown with "Don't do bad things" message
* $I->expectThrowable(new MyError("Don't do bad things"), function() {
* $this->doSomethingBad();
* });
* ```
*
* @param \Throwable|string $throwable
* @param callable $callback
* @see \Codeception\Module\Asserts::expectThrowable()
*/
public function expectThrowable($throwable, $callback) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('expectThrowable', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a file does not exist.
*
* @param string $filename
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertFileNotExists()
*/
public function assertFileNotExists($filename, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileNotExists', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a value is greater than or equal to another value.
*
* @param $expected
* @param $actual
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertGreaterOrEquals()
*/
public function assertGreaterOrEquals($expected, $actual, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterOrEquals', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a variable is empty.
*
* @param $actual
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertIsEmpty()
*/
public function assertIsEmpty($actual, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsEmpty', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a value is smaller than or equal to another value.
*
* @param $expected
* @param $actual
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertLessOrEquals()
*/
public function assertLessOrEquals($expected, $actual, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertLessOrEquals', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a string does not match a given regular expression.
*
* @param string $pattern
* @param string $string
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertNotRegExp()
*/
public function assertNotRegExp($pattern, $string, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotRegExp', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a string matches a given regular expression.
*
* @param string $pattern
* @param string $string
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertRegExp()
*/
public function assertRegExp($pattern, $string, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertRegExp', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Evaluates a PHPUnit\Framework\Constraint matcher object.
*
* @param $value
* @param Constraint $constraint
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertThatItsNot()
*/
public function assertThatItsNot($value, $constraint, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertThatItsNot', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that an array has a specified key.
*
* @param int|string $key
* @param array|ArrayAccess $array
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertArrayHasKey()
*/
public function assertArrayHasKey($key, $array, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertArrayHasKey', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that an array does not have a specified key.
*
* @param int|string $key
* @param array|ArrayAccess $array
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertArrayNotHasKey()
*/
public function assertArrayNotHasKey($key, $array, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertArrayNotHasKey', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a class has a specified attribute.
*
* @param string $attributeName
* @param string $className
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertClassHasAttribute()
*/
public function assertClassHasAttribute($attributeName, $className, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertClassHasAttribute', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a class has a specified static attribute.
*
* @param string $attributeName
* @param string $className
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertClassHasStaticAttribute()
*/
public function assertClassHasStaticAttribute($attributeName, $className, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertClassHasStaticAttribute', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a class does not have a specified attribute.
*
* @param string $attributeName
* @param string $className
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertClassNotHasAttribute()
*/
public function assertClassNotHasAttribute($attributeName, $className, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertClassNotHasAttribute', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a class does not have a specified static attribute.
*
* @param string $attributeName
* @param string $className
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertClassNotHasStaticAttribute()
*/
public function assertClassNotHasStaticAttribute($attributeName, $className, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertClassNotHasStaticAttribute', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a haystack contains a needle.
*
* @param $needle
* @param $haystack
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertContains()
*/
public function assertContains($needle, $haystack, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertContains', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @param $needle
* @param $haystack
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertContainsEquals()
*/
public function assertContainsEquals($needle, $haystack, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertContainsEquals', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a haystack contains only values of a given type.
*
* @param string $type
* @param $haystack
* @param bool|null $isNativeType
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertContainsOnly()
*/
public function assertContainsOnly($type, $haystack, $isNativeType = NULL, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertContainsOnly', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a haystack contains only instances of a given class name.
*
* @param string $className
* @param $haystack
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertContainsOnlyInstancesOf()
*/
public function assertContainsOnlyInstancesOf($className, $haystack, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertContainsOnlyInstancesOf', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts the number of elements of an array, Countable or Traversable.
*
* @param int $expectedCount
* @param Countable|iterable $haystack
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertCount()
*/
public function assertCount($expectedCount, $haystack, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertCount', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a directory does not exist.
*
* @param string $directory
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertDirectoryDoesNotExist()
*/
public function assertDirectoryDoesNotExist($directory, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertDirectoryDoesNotExist', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a directory exists.
*
* @param string $directory
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertDirectoryExists()
*/
public function assertDirectoryExists($directory, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertDirectoryExists', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a directory exists and is not readable.
*
* @param string $directory
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertDirectoryIsNotReadable()
*/
public function assertDirectoryIsNotReadable($directory, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertDirectoryIsNotReadable', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a directory exists and is not writable.
*
* @param string $directory
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertDirectoryIsNotWritable()
*/
public function assertDirectoryIsNotWritable($directory, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertDirectoryIsNotWritable', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a directory exists and is readable.
*
* @param string $directory
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertDirectoryIsReadable()
*/
public function assertDirectoryIsReadable($directory, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertDirectoryIsReadable', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a directory exists and is writable.
*
* @param string $directory
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertDirectoryIsWritable()
*/
public function assertDirectoryIsWritable($directory, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertDirectoryIsWritable', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a string does not match a given regular expression.
*
* @param string $pattern
* @param string $string
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertDoesNotMatchRegularExpression()
*/
public function assertDoesNotMatchRegularExpression($pattern, $string, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertDoesNotMatchRegularExpression', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a variable is empty.
*
* @param $actual
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertEmpty()
*/
public function assertEmpty($actual, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertEmpty', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that two variables are equal.
*
* @param $expected
* @param $actual
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertEquals()
*/
public function assertEquals($expected, $actual, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertEquals', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that two variables are equal (canonicalizing).
*
* @param $expected
* @param $actual
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertEqualsCanonicalizing()
*/
public function assertEqualsCanonicalizing($expected, $actual, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertEqualsCanonicalizing', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that two variables are equal (ignoring case).
*
* @param $expected
* @param $actual
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertEqualsIgnoringCase()
*/
public function assertEqualsIgnoringCase($expected, $actual, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertEqualsIgnoringCase', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that two variables are equal (with delta).
*
* @param $expected
* @param $actual
* @param float $delta
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertEqualsWithDelta()
*/
public function assertEqualsWithDelta($expected, $actual, $delta, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertEqualsWithDelta', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a condition is false.
*
* @param $condition
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertFalse()
*/
public function assertFalse($condition, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFalse', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a file does not exist.
*
* @param string $filename
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertFileDoesNotExist()
*/
public function assertFileDoesNotExist($filename, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileDoesNotExist', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that the contents of one file is equal to the contents of another file.
*
* @param string $expected
* @param string $actual
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertFileEquals()
*/
public function assertFileEquals($expected, $actual, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileEquals', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that the contents of one file is equal to the contents of another file (canonicalizing).
*
* @param $expected
* @param $actual
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertFileEqualsCanonicalizing()
*/
public function assertFileEqualsCanonicalizing($expected, $actual, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileEqualsCanonicalizing', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that the contents of one file is equal to the contents of another file (ignoring case).
*
* @param $expected
* @param $actual
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertFileEqualsIgnoringCase()
*/
public function assertFileEqualsIgnoringCase($expected, $actual, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileEqualsIgnoringCase', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a file exists.
*
* @param string $filename
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertFileExists()
*/
public function assertFileExists($filename, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileExists', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a file exists and is not readable.
*
* @param string $file
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertFileIsNotReadable()
*/
public function assertFileIsNotReadable($file, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileIsNotReadable', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a file exists and is not writable.
*
* @param string $file
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertFileIsNotWritable()
*/
public function assertFileIsNotWritable($file, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileIsNotWritable', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a file exists and is readable.
*
* @param string $file
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertFileIsReadable()
*/
public function assertFileIsReadable($file, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileIsReadable', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a file exists and is writable.
*
* @param string $file
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertFileIsWritable()
*/
public function assertFileIsWritable($file, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileIsWritable', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that the contents of one file is not equal to the contents of another file.
*
* @param $expected
* @param $actual
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertFileNotEquals()
*/
public function assertFileNotEquals($expected, $actual, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileNotEquals', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that the contents of one file is not equal to the contents of another file (canonicalizing).
*
* @param $expected
* @param $actual
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertFileNotEqualsCanonicalizing()
*/
public function assertFileNotEqualsCanonicalizing($expected, $actual, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileNotEqualsCanonicalizing', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that the contents of one file is not equal to the contents of another file (ignoring case).
*
* @param $expected
* @param $actual
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertFileNotEqualsIgnoringCase()
*/
public function assertFileNotEqualsIgnoringCase($expected, $actual, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileNotEqualsIgnoringCase', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a variable is finite.
*
* @param $actual
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertFinite()
*/
public function assertFinite($actual, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFinite', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a value is greater than another value.
*
* @param $expected
* @param $actual
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertGreaterThan()
*/
public function assertGreaterThan($expected, $actual, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterThan', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a value is greater than or equal to another value.
*
* @param $expected
* @param $actual
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertGreaterThanOrEqual()
*/
public function assertGreaterThanOrEqual($expected, $actual, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterThanOrEqual', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a variable is infinite.
*
* @param $actual
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertInfinite()
*/
public function assertInfinite($actual, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertInfinite', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a variable is of a given type.
*
* @param $expected
* @param $actual
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertInstanceOf()
*/
public function assertInstanceOf($expected, $actual, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertInstanceOf', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a variable is of type array.
*
* @param $actual
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertIsArray()
*/
public function assertIsArray($actual, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsArray', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a variable is of type bool.
*
* @param $actual
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertIsBool()
*/
public function assertIsBool($actual, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsBool', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a variable is of type callable.
*
* @param $actual
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertIsCallable()
*/
public function assertIsCallable($actual, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsCallable', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a variable is of type resource and is closed.
*
* @param $actual
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertIsClosedResource()
*/
public function assertIsClosedResource($actual, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsClosedResource', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a variable is of type float.
*
* @param $actual
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertIsFloat()
*/
public function assertIsFloat($actual, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsFloat', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a variable is of type int.
*
* @param $actual
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertIsInt()
*/
public function assertIsInt($actual, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsInt', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a variable is of type iterable.
*
* @param $actual
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertIsIterable()
*/
public function assertIsIterable($actual, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsIterable', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a variable is not of type array.
*
* @param $actual
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertIsNotArray()
*/
public function assertIsNotArray($actual, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNotArray', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a variable is not of type bool.
*
* @param $actual
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertIsNotBool()
*/
public function assertIsNotBool($actual, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNotBool', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a variable is not of type callable.
*
* @param $actual
* @param string $message
* @see \Codeception\Module\AbstractAsserts::assertIsNotCallable()
*/
public function assertIsNotCallable($actual, $message = "") {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNotCallable', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a variable is not of type resource.
*
* @param $actual
* @param string $message
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | true |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/tests/functional/_bootstrap.php | tests/functional/_bootstrap.php | <?php
// Here you can initialize variables that will be available to your tests
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bluzphp/framework | https://github.com/bluzphp/framework/blob/be908a41e27f50f3786bfa8919d5245efb0d9942/docs/DockBlock.php | docs/DockBlock.php | <?php
/**
* An complex example of how to write "dockblock", based on PEAR standard
*
* PEAR standard you can find at http://pear.php.net/manual/tr/standards.sample.php
* PSR proposal you can find at https://github.com/phpDocumentor/fig-standards/tree/master/proposed
*
* Docblock comments start with "/**" at the top. Notice how the "/"
* lines up with the normal indenting and the asterisks on subsequent rows
* are in line with the first asterisk. The last line of comment text
* should be immediately followed on the next line by the closing asterisk
* and slash and then the item you are commenting on should be on the next
* line below that. Don't add extra lines. Please put a blank line
* between paragraphs as well as between the end of the description and
* the start of the tags. Wrap comments before 80 columns in order to
* ease readability for a wide variety of users.
*
* Docblocks can only be used for programming constructs which allow them
* (classes, properties, methods, defines, includes, globals). See the
* phpDocumentor documentation for more information.
* http://phpdoc.org/docs/latest/index.html
*
* The Javadoc Style Guide is an excellent resource for figuring out
* how to say what needs to be said in docblock comments. Much of what is
* written here is a summary of what is found there, though there are some
* cases where what's said here overrides what is said there.
* http://www.oracle.com/technetwork/java/javase/documentation/index-137868.html
*
* The first line of any docblock is the summary. Make them one short
* sentence, without a period at the end. Summaries for classes, properties
* and constants should omit the subject and simply state the object,
* because they are describing things rather than actions or behaviors.
*/
/**
* Short description for file
*
* Usually this block is the same for all files in your project
* It's should consists the following tags:
* - copyright string
* - license with link to full text
* - link to library repository or project homepage
* All other information should be write in class dockblock
*
* Syntax and order of tags:
* @.copyright [description]
* @.license [<url>] [name]
* @.link [URI] [<description>]
*
* @copyright Bluz PHP Team
* @license MIT
* @link https://github.com/bluzphp/framework
*/
declare(strict_types=1);
namespace Bluz;
/**
* Short summary for class
*
* You should know the simple rule - one class in one file,
* then all information about package, author, version, etc
* you can write in dockblock of class
*
* Syntax and order of tags:
* @.package [level 1]\[level 2]\[etc.]
* @.author [name] [<email address>]
* @.version [<vector>] [<description>]
* @.link [URI] [<description>]
* @.see [URI | FQSEN] [<description>]
* @.since [version] [<description>]
* @.deprecated [version] [<description>]
*
* Then you can describe magic methods and properties of class,
* it's required for autosuggestion mechanism in IDE
*
* Syntax and order of magic properties and methods:
* @.property [Type] [name] [<description>]
* @.method [return type] [name]([[type] [parameter]<, ...>]) [<description>]
*
* @package Bluz
* @author Anton Shevchuk <Anton.Shevchuk@gmail.com>
* @version 1.5.0 release version
* @link https://github.com/bluzphp/framework
* @see DockBlock, DockBlock::setFoo()
* @since 1.0.0 first time this was introduced
* @deprecated 2.0.0 no longer used by internal code and not recommended
*
* @property integer $number
* @method integer getMagicNumber()
*/
class DockBlock
{
/**
* Short summary for property is optional, but recommended
*
* Syntax and order of tags:
* @.var ["Type"] [$element_name] [<description>]
* @.link [URI] [<description>]
* @.see [URI | FQSEN] [<description>]
*
* @var string contain a description
* @link https://github.com/bluzphp/framework
* @see DockBlock
*/
protected $foo = 'bar';
/**
* @var string simple property description
*/
protected $bar;
/**
* Registers the status of foo's universe
*
* Summaries for methods should use 3rd person declarative rather
* than 2nd person imperative, beginning with a verb phrase.
*
* Summaries should add description beyond the method's name. The
* best method names are "self-documenting", meaning they tell you
* basically what the method does. If the summary merely repeats
* the method name in sentence form, it is not providing more
* information.
*
* Below are the tags commonly used for methods. A `param` tag is
* required for each parameter the method has. The `return` tag are
* mandatory. The `throws` tag is required if the method uses exceptions.
* The remainder should only be used when necessary.
* Please use them in the order they appear here. phpDocumentor has
* several other tags available, feel free to use them.
*
* The `param` tag contains the data type, then the parameter's
* name, followed by a description. By convention, the first noun in
* the description is the data type of the parameter. Articles like
* "a", "an", and "the" can precede the noun. The descriptions
* should start with a phrase. If further description is necessary,
* follow with sentences. Having two spaces between the name and the
* description aids readability.
*
* When writing a phrase, do not capitalize and do not end with a period.
* When writing a phrase followed by a sentence, do not capitalize the
* phrase, but end it with a period to distinguish it from the start
* of the next sentence
*
* Return tags should contain the data type then a description of
* the data returned. The data type can be any of PHP's data types
* (int, float, bool, string, array, object, resource, mixed)
* and should contain the type primarily returned. For example, if
* a method returns an object when things work correctly but false
* when an error happens, say 'object' rather than 'mixed'.
* Use 'void' if nothing is returned.
*
* Here's an example of how to format examples:
* <code>
* try {
* $dockBlock = new DockBlock();
* $dockBlock->setFoo('Bar');
* } catch (\Exception $e) {
* echo $e->getMessage();
* }
* </code>
*
* Syntax and order of tags:
* @.param [Type] [name] [<description>]
* @.return [Type] [<description>]
* @.throws [Type] [<description>]
*
* @.see [URI | FQSEN] [<description>]
* @.since [version] [<description>]
* @.deprecated [version] [<description>]
*
* @param string $arg1 the string to quote
* @param int $arg2 an integer of how many problems happened.
* Indent to the description's starting point
* for long ones.
*
* @return int the integer of the set mode used. FALSE if foo
* foo could not be set.
*
* @throws \Exception if first argument is not a string
*
* @see DockBlock::$foo, DockBlock::setFoo()
* @since 1.3.0 Added the $arg2
* @since 1.2.0
* @deprecated 2.0.0
*/
public function setFoo($arg1, $arg2 = 0)
{
/*
* This is a "Block Comment." The format is the same as
* Docblock Comments except there is only one asterisk at the
* top. phpDocumentor doesn't parse these.
*/
if (is_int($arg1)) {
throw new \Exception("First argument should be string");
}
if ($arg1 == 'good' || $arg1 == 'fair') {
$this->foo = $arg1;
return 1;
} elseif ($arg1 == 'poor' && $arg2 > 1) {
$this->foo = 'poor';
return 2;
} else {
return false;
}
}
}
| php | MIT | be908a41e27f50f3786bfa8919d5245efb0d9942 | 2026-01-05T04:45:21.018855Z | false |
bitExpert/disco | https://github.com/bitExpert/disco/blob/bfccc82a4757930e4ec1259fe87c3124888e327c/src/bitExpert/Disco/InitializedBean.php | src/bitExpert/Disco/InitializedBean.php | <?php
/*
* This file is part of the Disco package.
*
* (c) bitExpert AG
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace bitExpert\Disco;
/**
* Callback interface for an initialized bean. This method is the last method
* being called during bean instantiation process. It allows the bean to check,
* if it is configured correctly.
*
* @api
*/
interface InitializedBean
{
/**
* Callback method to check bean configuration.
*
* @throws \bitExpert\Disco\BeanException
*/
public function postInitialization(): void;
}
| php | Apache-2.0 | bfccc82a4757930e4ec1259fe87c3124888e327c | 2026-01-05T04:45:28.508624Z | false |
bitExpert/disco | https://github.com/bitExpert/disco/blob/bfccc82a4757930e4ec1259fe87c3124888e327c/src/bitExpert/Disco/BeanNotFoundException.php | src/bitExpert/Disco/BeanNotFoundException.php | <?php
/*
* This file is part of the Disco package.
*
* (c) bitExpert AG
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace bitExpert\Disco;
use Psr\Container\NotFoundExceptionInterface;
/**
* Exception being thrown if called / referenced bean does not exist in the
* {@link \bitExpert\Disco\BeanFactory}.
*/
class BeanNotFoundException extends BeanException implements NotFoundExceptionInterface
{
}
| php | Apache-2.0 | bfccc82a4757930e4ec1259fe87c3124888e327c | 2026-01-05T04:45:28.508624Z | false |
bitExpert/disco | https://github.com/bitExpert/disco/blob/bfccc82a4757930e4ec1259fe87c3124888e327c/src/bitExpert/Disco/BeanPostProcessor.php | src/bitExpert/Disco/BeanPostProcessor.php | <?php
/*
* This file is part of the Disco package.
*
* (c) bitExpert AG
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace bitExpert\Disco;
/**
* The {@link \bitExpert\Disco\BeanPostProcessor} is an beanFactory hook that
* allows for custom modification of new bean instances, e.g. checking for
* marker interfaces.
*/
interface BeanPostProcessor
{
/**
* Apply this BeanPostProcessor to the given new bean instance after the
* bean got created.
*
* @param object $bean
* @param string $beanName
*/
public function postProcess(object $bean, string $beanName): void;
}
| php | Apache-2.0 | bfccc82a4757930e4ec1259fe87c3124888e327c | 2026-01-05T04:45:28.508624Z | false |
bitExpert/disco | https://github.com/bitExpert/disco/blob/bfccc82a4757930e4ec1259fe87c3124888e327c/src/bitExpert/Disco/AnnotationBeanFactory.php | src/bitExpert/Disco/AnnotationBeanFactory.php | <?php
/*
* This file is part of the Disco package.
*
* (c) bitExpert AG
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace bitExpert\Disco;
use bitExpert\Disco\Proxy\Configuration\AliasContainerInterface;
use bitExpert\Disco\Proxy\Configuration\ConfigurationFactory;
/**
* {@link \bitExpert\Disco\BeanFactory} implementation.
*
* @api
*/
class AnnotationBeanFactory implements BeanFactory
{
/**
* @var AliasContainerInterface
*/
protected $beanConfig;
/**
* Creates a new {@link \bitExpert\Disco\BeanFactory}.
*
* @param class-string<Object> $configClassName
* @param array<string, mixed> $parameters
* @param BeanFactoryConfiguration $config
*/
public function __construct($configClassName, array $parameters = [], BeanFactoryConfiguration $config = null)
{
if ($config === null) {
$config = new BeanFactoryConfiguration(sys_get_temp_dir());
}
$configFactory = new ConfigurationFactory($config);
$this->beanConfig = $configFactory->createInstance($config, $configClassName, $parameters);
}
/**
* {@inheritDoc}
* @throws BeanException
* @throws BeanNotFoundException
*/
public function get(string $id)
{
$instance = null;
try {
if (is_callable([$this->beanConfig, $id])) {
$instance = $this->beanConfig->$id();
} elseif ($this->beanConfig->hasAlias($id)) {
$instance = $this->beanConfig->getAlias($id);
}
} catch (\Throwable $e) {
$message = sprintf(
'Exception occurred while instantiating "%s": %s',
$id,
$e->getMessage()
);
throw new BeanException($message, $e->getCode(), $e);
}
if (null === $instance) {
throw new BeanNotFoundException(sprintf('"%s" is not defined!', $id));
}
return $instance;
}
/**
* {@inheritDoc}
*/
public function has(string $id)
{
return is_callable([$this->beanConfig, $id]) || $this->beanConfig->hasAlias($id);
}
}
| php | Apache-2.0 | bfccc82a4757930e4ec1259fe87c3124888e327c | 2026-01-05T04:45:28.508624Z | false |
bitExpert/disco | https://github.com/bitExpert/disco/blob/bfccc82a4757930e4ec1259fe87c3124888e327c/src/bitExpert/Disco/BeanException.php | src/bitExpert/Disco/BeanException.php | <?php
/*
* This file is part of the Disco package.
*
* (c) bitExpert AG
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace bitExpert\Disco;
use Psr\Container\ContainerExceptionInterface;
/**
* Superclass for all exceptions thrown in the \bitExpert\Disco package and it`s
* subpackages.
*/
class BeanException extends \RuntimeException implements ContainerExceptionInterface
{
}
| php | Apache-2.0 | bfccc82a4757930e4ec1259fe87c3124888e327c | 2026-01-05T04:45:28.508624Z | false |
bitExpert/disco | https://github.com/bitExpert/disco/blob/bfccc82a4757930e4ec1259fe87c3124888e327c/src/bitExpert/Disco/BeanFactoryConfiguration.php | src/bitExpert/Disco/BeanFactoryConfiguration.php | <?php
/*
* This file is part of the Disco package.
*
* (c) bitExpert AG
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace bitExpert\Disco;
use bitExpert\Disco\Store\BeanStore;
use bitExpert\Disco\Store\SerializableBeanStore;
use InvalidArgumentException;
use ProxyManager\Autoloader\AutoloaderInterface;
use ProxyManager\Configuration;
use ProxyManager\FileLocator\FileLocator;
use ProxyManager\GeneratorStrategy\FileWriterGeneratorStrategy;
use ProxyManager\GeneratorStrategy\GeneratorStrategyInterface;
/**
* BeanFactory configuration class.
*
* @api
*/
class BeanFactoryConfiguration
{
/**
* @var BeanStore
*/
protected $sessionBeanStore;
/**
* @var string
*/
protected $proxyTargetDir;
/**
* @var ?GeneratorStrategyInterface
*/
protected $proxyWriterGenerator;
/**
* @var ?AutoloaderInterface
*/
protected $proxyAutoloader;
/**
* Creates a new {@link \bitExpert\Disco\BeanFactoryConfiguration}.
*
* @param string $proxyTargetDir
* @throws InvalidArgumentException
*/
public function __construct($proxyTargetDir)
{
try {
$proxyFileLocator = new FileLocator($proxyTargetDir);
} catch (\Exception $e) {
throw new InvalidArgumentException(
sprintf(
'Proxy target directory "%s" does not exist!',
$proxyTargetDir
),
$e->getCode(),
$e
);
}
$this->setProxyTargetDir($proxyTargetDir);
$this->setSessionBeanStore(new SerializableBeanStore());
$this->setProxyWriterGenerator(new FileWriterGeneratorStrategy($proxyFileLocator));
}
/**
* Sets the directory in which ProxyManager will store the generated proxy classes in.
*
* @param string $proxyTargetDir
* @throws InvalidArgumentException
*/
public function setProxyTargetDir(string $proxyTargetDir): void
{
if (!is_dir($proxyTargetDir)) {
throw new InvalidArgumentException(
sprintf(
'Proxy target directory "%s" does not exist!',
$proxyTargetDir
),
10
);
}
if (!is_writable($proxyTargetDir)) {
throw new InvalidArgumentException(
sprintf(
'Proxy target directory "%s" is not writable!',
$proxyTargetDir
),
20
);
}
$this->proxyTargetDir = $proxyTargetDir;
}
/**
* Sets the {@link \ProxyManager\GeneratorStrategy\GeneratorStrategyInterface} which
* ProxyManager will use the generate the proxy classes.
*
* @param GeneratorStrategyInterface $writergenerator
*/
public function setProxyWriterGenerator(GeneratorStrategyInterface $writergenerator): void
{
$this->proxyWriterGenerator = $writergenerator;
}
/**
* Sets the {@link \ProxyManager\Autoloader\AutoloaderInterface} that should be
* used by ProxyManager to load the generated classes.
*
* @param AutoloaderInterface $autoloader
* @throws \RuntimeException
*/
public function setProxyAutoloader(AutoloaderInterface $autoloader): void
{
if ($this->proxyAutoloader instanceof AutoloaderInterface) {
spl_autoload_unregister($this->proxyAutoloader);
}
$this->proxyAutoloader = $autoloader;
spl_autoload_register($this->proxyAutoloader);
}
/**
* Returns the ProxyManager configuration based on the current
* {@link \bitExpert\Disco\BeanFactoryConfiguration}.
*
* @return Configuration
*/
public function getProxyManagerConfiguration(): Configuration
{
$proxyManagerConfiguration = new Configuration();
$proxyManagerConfiguration->setProxiesTargetDir($this->proxyTargetDir);
if ($this->proxyWriterGenerator instanceof GeneratorStrategyInterface) {
$proxyManagerConfiguration->setGeneratorStrategy($this->proxyWriterGenerator);
}
if ($this->proxyAutoloader instanceof AutoloaderInterface) {
$proxyManagerConfiguration->setProxyAutoloader($this->proxyAutoloader);
}
return $proxyManagerConfiguration;
}
/**
* Returns the configured {@link \bitExpert\Disco\Store\BeanStore} used to store
* the session-aware beans in.
*
* @return BeanStore
*/
public function getSessionBeanStore(): BeanStore
{
return $this->sessionBeanStore;
}
/**
* Sets the {@link \bitExpert\Disco\Store\BeanStore} instance used to store the
* session-aware beans.
*
* @param BeanStore $sessionBeanStore
*/
public function setSessionBeanStore(BeanStore $sessionBeanStore): void
{
$this->sessionBeanStore = $sessionBeanStore;
}
}
| php | Apache-2.0 | bfccc82a4757930e4ec1259fe87c3124888e327c | 2026-01-05T04:45:28.508624Z | false |
bitExpert/disco | https://github.com/bitExpert/disco/blob/bfccc82a4757930e4ec1259fe87c3124888e327c/src/bitExpert/Disco/BeanFactory.php | src/bitExpert/Disco/BeanFactory.php | <?php
/*
* This file is part of the Disco package.
*
* (c) bitExpert AG
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace bitExpert\Disco;
use Psr\Container\ContainerInterface;
/**
* This interface is implemented by objects that hold a number of bean definitions,
* each uniquely identified by a bean identifier (name).
*/
interface BeanFactory extends ContainerInterface
{
}
| php | Apache-2.0 | bfccc82a4757930e4ec1259fe87c3124888e327c | 2026-01-05T04:45:28.508624Z | false |
bitExpert/disco | https://github.com/bitExpert/disco/blob/bfccc82a4757930e4ec1259fe87c3124888e327c/src/bitExpert/Disco/BeanFactoryRegistry.php | src/bitExpert/Disco/BeanFactoryRegistry.php | <?php
/*
* This file is part of the Disco package.
*
* (c) bitExpert AG
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace bitExpert\Disco;
/**
* Global registry for the configured {@link \bitExpert\Disco\BeanFactory} instance.
*
* @api
*/
class BeanFactoryRegistry
{
/**
* @var BeanFactory
*/
protected static $beanFactory = null;
/**
* Registers a {@link \bitExpert\Disco\BeanFactory} instance in the registry to make the instance
* globally available.
*
* @param BeanFactory $beanFactory
*/
public static function register(BeanFactory $beanFactory): void
{
self::$beanFactory = $beanFactory;
}
/**
* Returns the registered {@link \bitExpert\Disco\BeanFactory} instance or null if not defined.
*
* @return BeanFactory|null
*/
public static function getInstance(): ?BeanFactory
{
return self::$beanFactory;
}
}
| php | Apache-2.0 | bfccc82a4757930e4ec1259fe87c3124888e327c | 2026-01-05T04:45:28.508624Z | false |
bitExpert/disco | https://github.com/bitExpert/disco/blob/bfccc82a4757930e4ec1259fe87c3124888e327c/src/bitExpert/Disco/Annotations/Parameter.php | src/bitExpert/Disco/Annotations/Parameter.php | <?php
/*
* This file is part of the Disco package.
*
* (c) bitExpert AG
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace bitExpert\Disco\Annotations;
use Doctrine\Common\Annotations\Annotation\Attribute;
use Doctrine\Common\Annotations\Annotation\Attributes;
use Doctrine\Common\Annotations\AnnotationException;
/**
* @Annotation
* @Target({"ANNOTATION"})
* @Attributes({
* @Attribute("name", type = "string"),
* @Attribute("default", type = "string"),
* @Attribute("required", type = "bool")
* })
*/
final class Parameter
{
/**
* @var string
*/
private $name;
/**
* @var mixed
*/
private $defaultValue;
/**
* @var bool
*/
private $required;
/**
* Creates a new {@link \bitExpert\Disco\Annotations\Parameter}.
*
* @param array<string, array<string, mixed>> $attributes
* @throws AnnotationException
*/
public function __construct(array $attributes = [])
{
$this->required = true;
$this->name = '';
if (isset($attributes['value'])) {
if (isset($attributes['value']['name'])) {
$this->name = $attributes['value']['name'];
}
if (isset($attributes['value']['default'])) {
$this->defaultValue = $attributes['value']['default'];
}
if (isset($attributes['value']['required'])) {
$this->required = AnnotationAttributeParser::parseBooleanValue($attributes['value']['required']);
}
}
if ($this->name === '') {
throw new AnnotationException('name attribute missing!');
}
}
/**
* Returns the name of the configuration value to use.
*
* @return string
*/
public function getName(): string
{
return $this->name;
}
/**
* Returns the default value to use in case the configuration value is not defined.
*
* @return mixed
*/
public function getDefaultValue(): mixed
{
return $this->defaultValue;
}
/**
* Returns true if the parameter is required, false for an optional parameter.
*
* @return bool
*/
public function isRequired(): bool
{
return $this->required;
}
}
| php | Apache-2.0 | bfccc82a4757930e4ec1259fe87c3124888e327c | 2026-01-05T04:45:28.508624Z | false |
bitExpert/disco | https://github.com/bitExpert/disco/blob/bfccc82a4757930e4ec1259fe87c3124888e327c/src/bitExpert/Disco/Annotations/Alias.php | src/bitExpert/Disco/Annotations/Alias.php | <?php
/*
* This file is part of the Disco package.
*
* (c) bitExpert AG
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace bitExpert\Disco\Annotations;
use Doctrine\Common\Annotations\Annotation\Attribute;
use Doctrine\Common\Annotations\Annotation\Attributes;
use Doctrine\Common\Annotations\AnnotationException;
/**
* @Annotation
* @Target({"ANNOTATION"})
* @Attributes({
* @Attribute("name", type = "string"),
* @Attribute("type", type = "bool"),
* })
*/
final class Alias
{
/**
* @var ?string
*/
private $name;
/**
* @var bool
*/
private $type;
/**
* Creates a new {@link \bitExpert\Disco\Annotations\Bean\Alias}.
*
* @param array<string, array<string, mixed>> $attributes
* @throws AnnotationException
*/
public function __construct(array $attributes = [])
{
$this->type = false;
if (isset($attributes['value']['type'])) {
$this->type = AnnotationAttributeParser::parseBooleanValue($attributes['value']['type']);
}
if (isset($attributes['value']['name'])) {
if ($this->type) {
throw new AnnotationException('Type alias should not have a name!');
}
$this->name = $attributes['value']['name'];
}
if (!$this->type && (!is_string($this->name) || $this->name === '')) {
throw new AnnotationException('Alias should either be a named alias or a type alias!');
}
}
public function getName(): ?string
{
return $this->name;
}
public function isTypeAlias(): bool
{
return $this->type;
}
}
| php | Apache-2.0 | bfccc82a4757930e4ec1259fe87c3124888e327c | 2026-01-05T04:45:28.508624Z | false |
bitExpert/disco | https://github.com/bitExpert/disco/blob/bfccc82a4757930e4ec1259fe87c3124888e327c/src/bitExpert/Disco/Annotations/AnnotationAttributeParser.php | src/bitExpert/Disco/Annotations/AnnotationAttributeParser.php | <?php
/*
* This file is part of the Disco package.
*
* (c) bitExpert AG
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace bitExpert\Disco\Annotations;
final class AnnotationAttributeParser
{
/**
* Helper function to cast any value to a boolean representation.
*
* @param mixed $value
* @return bool
*/
public static function parseBooleanValue($value): bool
{
if (\is_bool($value)) {
return $value;
}
if (\is_string($value)) {
$value = \strtolower($value);
return 'true' === $value;
}
if (\is_object($value) || \is_array($value) || \is_callable($value)) {
return false;
}
// anything else is simply casted to bool
return (bool) $value;
}
}
| php | Apache-2.0 | bfccc82a4757930e4ec1259fe87c3124888e327c | 2026-01-05T04:45:28.508624Z | false |
bitExpert/disco | https://github.com/bitExpert/disco/blob/bfccc82a4757930e4ec1259fe87c3124888e327c/src/bitExpert/Disco/Annotations/BeanPostProcessor.php | src/bitExpert/Disco/Annotations/BeanPostProcessor.php | <?php
/*
* This file is part of the Disco package.
*
* (c) bitExpert AG
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace bitExpert\Disco\Annotations;
use Doctrine\Common\Annotations\Annotation\Attribute;
use Doctrine\Common\Annotations\Annotation\Attributes;
use Doctrine\Common\Annotations\AnnotationException;
/**
* @Annotation
* @Target({"METHOD"})
* @Attributes({
* @Attribute("parameters", type = "array<\bitExpert\Disco\Annotations\Parameter>")
* })
*/
final class BeanPostProcessor extends ParameterAwareAnnotation
{
/**
* Creates a new {@link \bitExpert\Disco\Annotations\BeanPostProcessor}.
*
* @param array<string, array<string, mixed>> $attributes
*/
public function __construct(array $attributes = [])
{
parent::__construct();
if (isset($attributes['value']['parameters']) && \is_array($attributes['value']['parameters'])) {
$this->setParameters(...$attributes['value']['parameters']);
}
}
}
| php | Apache-2.0 | bfccc82a4757930e4ec1259fe87c3124888e327c | 2026-01-05T04:45:28.508624Z | false |
bitExpert/disco | https://github.com/bitExpert/disco/blob/bfccc82a4757930e4ec1259fe87c3124888e327c/src/bitExpert/Disco/Annotations/Configuration.php | src/bitExpert/Disco/Annotations/Configuration.php | <?php
/*
* This file is part of the Disco package.
*
* (c) bitExpert AG
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace bitExpert\Disco\Annotations;
/**
* @Annotation
* @Target({"CLASS"})
*/
final class Configuration
{
}
| php | Apache-2.0 | bfccc82a4757930e4ec1259fe87c3124888e327c | 2026-01-05T04:45:28.508624Z | false |
bitExpert/disco | https://github.com/bitExpert/disco/blob/bfccc82a4757930e4ec1259fe87c3124888e327c/src/bitExpert/Disco/Annotations/Bean.php | src/bitExpert/Disco/Annotations/Bean.php | <?php
/*
* This file is part of the Disco package.
*
* (c) bitExpert AG
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace bitExpert\Disco\Annotations;
use Doctrine\Common\Annotations\Annotation\Attribute;
use Doctrine\Common\Annotations\Annotation\Attributes;
use Doctrine\Common\Annotations\AnnotationException;
/**
* @Annotation
* @Target({"METHOD"})
* @Attributes({
* @Attribute("scope", type = "string"),
* @Attribute("singleton", type = "bool"),
* @Attribute("lazy", type = "bool"),
* @Attribute("aliases", type = "array<\bitExpert\Disco\Annotations\Alias>"),
* @Attribute("parameters", type = "array<\bitExpert\Disco\Annotations\Parameter>")
* })
*/
final class Bean extends ParameterAwareAnnotation
{
const SCOPE_REQUEST = 1;
const SCOPE_SESSION = 2;
/**
* @var int
*/
protected $scope;
/**
* @var bool
*/
protected $singleton;
/**
* @var bool
*/
protected $lazy;
/**
* @var Alias[]
*/
protected $aliases;
/**
* Creates a new {@link \bitExpert\Disco\Annotations\Bean}.
*
* @param array<string, array<string, mixed>> $attributes
*/
public function __construct(array $attributes = [])
{
parent::__construct();
// initialize default values
$this->scope = self::SCOPE_REQUEST;
$this->singleton = true;
$this->lazy = false;
$this->aliases = [];
if (isset($attributes['value'])) {
if (isset($attributes['value']['scope']) && \strtolower($attributes['value']['scope']) === 'session') {
$this->scope = self::SCOPE_SESSION;
}
if (isset($attributes['value']['singleton'])) {
$this->singleton = AnnotationAttributeParser::parseBooleanValue($attributes['value']['singleton']);
}
if (isset($attributes['value']['lazy'])) {
$this->lazy = AnnotationAttributeParser::parseBooleanValue($attributes['value']['lazy']);
}
if (isset($attributes['value']['aliases']) && \is_array($attributes['value']['aliases'])) {
$this->setAliases(...$attributes['value']['aliases']);
}
if (isset($attributes['value']['parameters']) && \is_array($attributes['value']['parameters'])) {
$this->setParameters(...$attributes['value']['parameters']);
}
}
}
/**
* Helper methd to ensure that the passed aliases are of {@link \bitExpert\Disco\Annotations\Alias} type.
*
* @param Alias ...$aliases
*/
private function setAliases(Alias ...$aliases): void
{
$this->aliases = $aliases;
}
/**
* Returns true if the current scope if of type Scope::REQUEST.
*
* @return bool
*/
public function isRequest(): bool
{
return $this->scope === self::SCOPE_REQUEST;
}
/**
* Returns true if the current scope if of type Scope::SESSION.
*
* @return bool
*/
public function isSession(): bool
{
return $this->scope === self::SCOPE_SESSION;
}
/**
* Returns true if the Bean should be a singleton instance.
*
* @return bool
*/
public function isSingleton(): bool
{
return $this->singleton;
}
/**
* Returns true if the Bean should be a lazily instantiated.
*
* @return bool
*/
public function isLazy(): bool
{
return $this->lazy;
}
/**
* Returns the list of aliases for the bean instance. Returns an empty array when no alias was set.
*
* @return Alias[]
*/
public function getAliases(): array
{
return $this->aliases;
}
}
| php | Apache-2.0 | bfccc82a4757930e4ec1259fe87c3124888e327c | 2026-01-05T04:45:28.508624Z | false |
bitExpert/disco | https://github.com/bitExpert/disco/blob/bfccc82a4757930e4ec1259fe87c3124888e327c/src/bitExpert/Disco/Annotations/ParameterAwareAnnotation.php | src/bitExpert/Disco/Annotations/ParameterAwareAnnotation.php | <?php
/*
* This file is part of the Disco package.
*
* (c) bitExpert AG
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace bitExpert\Disco\Annotations;
/**
* Base class for all annotations that are parameter-aware.
*/
abstract class ParameterAwareAnnotation
{
/**
* @var Parameter[]
*/
private $parameters;
/**
* Creates a new {@link \bitExpert\Disco\Annotations\ParameterAwareAnnotation}.
*/
public function __construct()
{
$this->parameters = [];
}
/**
* Returns the list of parameters for the bean post processor instance. Returns an empty array when no parameters
* were set.
*
* @return Parameter[]
*/
public function getParameters(): array
{
return $this->parameters;
}
/**
* Helper methd to ensure that the passed parameters are of {@link \bitExpert\Disco\Annotations\Parameter} type.
*
* @param Parameter[] ...$parameters
*/
protected function setParameters(Parameter ...$parameters): void
{
$this->parameters = $parameters;
}
}
| php | Apache-2.0 | bfccc82a4757930e4ec1259fe87c3124888e327c | 2026-01-05T04:45:28.508624Z | false |
bitExpert/disco | https://github.com/bitExpert/disco/blob/bfccc82a4757930e4ec1259fe87c3124888e327c/src/bitExpert/Disco/Store/SerializableBeanStore.php | src/bitExpert/Disco/Store/SerializableBeanStore.php | <?php
/*
* This file is part of the Disco package.
*
* (c) bitExpert AG
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace bitExpert\Disco\Store;
/**
* The {@link \bitExpert\Disco\Store\SerializableBeanStore} contains all session-aware beans which
* can be persisted in your preferable format.
*/
class SerializableBeanStore implements BeanStore
{
/**
* @var array<string, mixed>
*/
protected $beans;
/**
* Creates a new {@link \bitExpert\Disco\Store\SerializableBeanStore}.
*/
public function __construct()
{
$this->beans = [];
}
/**
* {@inheritdoc}
*/
public function add(string $beanId, $bean): void
{
$this->beans[$beanId] = $bean;
}
/**
* {@inheritdoc}
*/
public function get(string $beanId): mixed
{
if (!isset($this->beans[$beanId])) {
throw new \InvalidArgumentException(
sprintf('Bean "%s" not defined in store!', $beanId)
);
}
return $this->beans[$beanId];
}
/**
* {@inheritdoc}
*/
public function has(string $beanId): bool
{
return isset($this->beans[$beanId]);
}
/**
* {@inheritDoc}
*/
public function __sleep()
{
return ['beans'];
}
}
| php | Apache-2.0 | bfccc82a4757930e4ec1259fe87c3124888e327c | 2026-01-05T04:45:28.508624Z | false |
bitExpert/disco | https://github.com/bitExpert/disco/blob/bfccc82a4757930e4ec1259fe87c3124888e327c/src/bitExpert/Disco/Store/BeanStore.php | src/bitExpert/Disco/Store/BeanStore.php | <?php
/*
* This file is part of the Disco package.
*
* (c) bitExpert AG
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace bitExpert\Disco\Store;
use InvalidArgumentException;
interface BeanStore
{
/**
* Adds given $bean instance (or primitive) to the bean store by the given $beanId.
*
* @param string $beanId
* @param mixed $bean
*/
public function add(string $beanId, $bean): void;
/**
* Retrieves bean instance for $beanId.
*
* @param string $beanId
* @return mixed
* @throws InvalidArgumentException
*/
public function get(string $beanId);
/**
* Checks if a bean instance for $beanId exists. Will return true if an instance
* exists and false if no instance can be found.
*
* @param string $beanId
* @return bool
*/
public function has(string $beanId): bool;
}
| php | Apache-2.0 | bfccc82a4757930e4ec1259fe87c3124888e327c | 2026-01-05T04:45:28.508624Z | false |
bitExpert/disco | https://github.com/bitExpert/disco/blob/bfccc82a4757930e4ec1259fe87c3124888e327c/src/bitExpert/Disco/Proxy/LazyBean/LazyBeanFactory.php | src/bitExpert/Disco/Proxy/LazyBean/LazyBeanFactory.php | <?php
/*
* This file is part of the Disco package.
*
* (c) bitExpert AG
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace bitExpert\Disco\Proxy\LazyBean;
use Closure;
use ProxyManager\Configuration;
use ProxyManager\Factory\AbstractBaseFactory;
use ProxyManager\ProxyGenerator\ProxyGeneratorInterface;
/**
* Factory responsible of producing virtual proxy instances.
*/
class LazyBeanFactory extends AbstractBaseFactory
{
/**
* @var LazyBeanGenerator|null
*/
private $generator;
/**
* @var string
*/
private $beanId;
/**
* Creates a new {@link \bitExpert\Disco\Proxy\LazyBean\LazyBeanFactory}.
*
* @param string $beanId
* @param \ProxyManager\Configuration $configuration
*/
public function __construct($beanId, Configuration $configuration = null)
{
parent::__construct($configuration);
$this->beanId = $beanId;
}
/**
* @param string $className
* @param Closure $initializer
*
* @return object
*/
public function createProxy(string $className, Closure $initializer): object
{
/** @var class-string<Object> $className */
$proxyClassName = $this->generateProxy($className);
return new $proxyClassName($this->beanId, $initializer);
}
/**
* {@inheritDoc}
*/
protected function getGenerator(): ProxyGeneratorInterface
{
return $this->generator = $this->generator ?? new LazyBeanGenerator();
}
}
| php | Apache-2.0 | bfccc82a4757930e4ec1259fe87c3124888e327c | 2026-01-05T04:45:28.508624Z | false |
bitExpert/disco | https://github.com/bitExpert/disco/blob/bfccc82a4757930e4ec1259fe87c3124888e327c/src/bitExpert/Disco/Proxy/LazyBean/LazyBeanGenerator.php | src/bitExpert/Disco/Proxy/LazyBean/LazyBeanGenerator.php | <?php
/*
* This file is part of the Disco package.
*
* (c) bitExpert AG
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace bitExpert\Disco\Proxy\LazyBean;
use bitExpert\Disco\Proxy\LazyBean\MethodGenerator\Constructor;
use bitExpert\Disco\Proxy\LazyBean\MethodGenerator\MagicSleep;
use bitExpert\Disco\Proxy\LazyBean\MethodGenerator\MagicWakeup;
use bitExpert\Disco\Proxy\LazyBean\PropertyGenerator\ValueHolderBeanIdProperty;
use ProxyManager\Exception\InvalidProxiedClassException;
use ProxyManager\Generator\Util\ClassGeneratorUtils;
use ProxyManager\Proxy\VirtualProxyInterface;
use ProxyManager\ProxyGenerator\Assertion\CanProxyAssertion;
use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\GetProxyInitializer;
use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\InitializeProxy;
use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\IsProxyInitialized;
use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\LazyLoadingMethodInterceptor;
use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\MagicClone;
use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\MagicGet;
use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\MagicIsset;
use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\MagicSet;
use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\MagicUnset;
use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\SetProxyInitializer;
use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\PropertyGenerator\InitializerProperty;
use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\PropertyGenerator\ValueHolderProperty;
use ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesMap;
use ProxyManager\ProxyGenerator\ProxyGeneratorInterface;
use ProxyManager\ProxyGenerator\Util\Properties;
use ProxyManager\ProxyGenerator\Util\ProxiedMethodsFilter;
use ProxyManager\ProxyGenerator\ValueHolder\MethodGenerator\GetWrappedValueHolderValue;
use ReflectionClass;
use ReflectionException;
use ReflectionMethod;
use Laminas\Code\Generator\ClassGenerator;
use Laminas\Code\Generator\Exception\InvalidArgumentException;
use Laminas\Code\Generator\MethodGenerator;
use Laminas\Code\Reflection\MethodReflection;
/**
* Generator for proxies implementing {@link \ProxyManager\Proxy\VirtualProxyInterface}.
*/
class LazyBeanGenerator implements ProxyGeneratorInterface
{
/**
* {@inheritDoc}
* @param ReflectionClass $originalClass
* @param ClassGenerator $classGenerator
* @throws InvalidProxiedClassException
* @throws InvalidArgumentException
* @throws ReflectionException
*/
public function generate(ReflectionClass $originalClass, ClassGenerator $classGenerator)
{
CanProxyAssertion::assertClassCanBeProxied($originalClass);
$interfaces = array(VirtualProxyInterface::class);
$publicProperties = new PublicPropertiesMap(Properties::fromReflectionClass($originalClass));
if ($originalClass->isInterface()) {
$interfaces[] = $originalClass->getName();
} else {
$classGenerator->setExtendedClass($originalClass->getName());
}
$classGenerator->setImplementedInterfaces($interfaces);
$classGenerator->addPropertyFromGenerator($valueHolder = new ValueHolderProperty($originalClass));
$classGenerator->addPropertyFromGenerator($valueHolderBeanId = new ValueHolderBeanIdProperty());
$classGenerator->addPropertyFromGenerator($initializer = new InitializerProperty());
$classGenerator->addPropertyFromGenerator($publicProperties);
array_map(
function (MethodGenerator $generatedMethod) use ($originalClass, $classGenerator): void {
ClassGeneratorUtils::addMethodIfNotFinal($originalClass, $classGenerator, $generatedMethod);
},
array_merge(
array_map(
function (ReflectionMethod $method) use ($initializer, $valueHolder): LazyLoadingMethodInterceptor {
return LazyLoadingMethodInterceptor::generateMethod(
new MethodReflection($method->class, $method->getName()),
$initializer,
$valueHolder
);
},
ProxiedMethodsFilter::getProxiedMethods($originalClass)
),
array(
new Constructor($originalClass, $initializer, $valueHolderBeanId),
new MagicGet($originalClass, $initializer, $valueHolder, $publicProperties),
new MagicSet($originalClass, $initializer, $valueHolder, $publicProperties),
new MagicIsset($originalClass, $initializer, $valueHolder, $publicProperties),
new MagicUnset($originalClass, $initializer, $valueHolder, $publicProperties),
new MagicClone($originalClass, $initializer, $valueHolder),
new MagicSleep($originalClass, $initializer, $valueHolder, $valueHolderBeanId),
new MagicWakeup($originalClass, $valueHolder, $valueHolderBeanId),
new SetProxyInitializer($initializer),
new GetProxyInitializer($initializer),
new InitializeProxy($initializer, $valueHolder),
new IsProxyInitialized($valueHolder),
new GetWrappedValueHolderValue($valueHolder),
)
)
);
}
}
| php | Apache-2.0 | bfccc82a4757930e4ec1259fe87c3124888e327c | 2026-01-05T04:45:28.508624Z | false |
bitExpert/disco | https://github.com/bitExpert/disco/blob/bfccc82a4757930e4ec1259fe87c3124888e327c/src/bitExpert/Disco/Proxy/LazyBean/MethodGenerator/Constructor.php | src/bitExpert/Disco/Proxy/LazyBean/MethodGenerator/Constructor.php | <?php
/*
* This file is part of the 02003-bitExpertLabs-24-Disco package.
*
* (c) bitExpert AG
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace bitExpert\Disco\Proxy\LazyBean\MethodGenerator;
use ProxyManager\Generator\MethodGenerator;
use ReflectionClass;
use ReflectionProperty;
use Laminas\Code\Generator\Exception\InvalidArgumentException;
use Laminas\Code\Generator\ParameterGenerator;
use Laminas\Code\Generator\PropertyGenerator;
/**
* `__construct` method for lazy loading value holder objects.
*/
class Constructor extends MethodGenerator
{
/**
* Creates a new {@link \bitExpert\Disco\Proxy\LazyBean\MethodGenerator\Constructor}.
*
* @param ReflectionClass<Object> $originalClass
* @param PropertyGenerator $initializerProperty
* @param PropertyGenerator $valueHolderBeanIdProperty
* @throws InvalidArgumentException
*/
public function __construct(
ReflectionClass $originalClass,
PropertyGenerator $initializerProperty,
PropertyGenerator $valueHolderBeanIdProperty
) {
parent::__construct('__construct');
$this->setParameter(new ParameterGenerator('beanId'));
$this->setParameter(new ParameterGenerator('initializer'));
/* @var $publicProperties \ReflectionProperty[] */
$publicProperties = $originalClass->getProperties(ReflectionProperty::IS_PUBLIC);
$unsetProperties = array();
foreach ($publicProperties as $publicProperty) {
$unsetProperties[] = '$this->' . $publicProperty->getName();
}
$this->setDocBlock(
'@override constructor for lazy initialization' . PHP_EOL . PHP_EOL
. '@param \string \$beanId' . PHP_EOL
. '@param \Closure|null \$initializer'
);
$this->setBody(
(count($unsetProperties) > 0 ? 'unset(' . implode(', ', $unsetProperties) . ');' . PHP_EOL . PHP_EOL : '')
. '$this->' . $initializerProperty->getName() . ' = $initializer;' . PHP_EOL
. '$this->' . $valueHolderBeanIdProperty->getName() . ' = $beanId;'
);
}
}
| php | Apache-2.0 | bfccc82a4757930e4ec1259fe87c3124888e327c | 2026-01-05T04:45:28.508624Z | false |
bitExpert/disco | https://github.com/bitExpert/disco/blob/bfccc82a4757930e4ec1259fe87c3124888e327c/src/bitExpert/Disco/Proxy/LazyBean/MethodGenerator/MagicSleep.php | src/bitExpert/Disco/Proxy/LazyBean/MethodGenerator/MagicSleep.php | <?php
/*
* This file is part of the Disco package.
*
* (c) bitExpert AG
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace bitExpert\Disco\Proxy\LazyBean\MethodGenerator;
use ProxyManager\Generator\MagicMethodGenerator;
use ReflectionClass;
use Laminas\Code\Generator\Exception\InvalidArgumentException;
use Laminas\Code\Generator\PropertyGenerator;
/**
* `__sleep` method for lazy loading value holder objects. Will return the
* beanId for the serialization process to that the "real" instance can be
* fetched again when the `__wakeup` method gets called. This way we ensure
* that singleton dependencies are properly fetched again from the
* {@link \bitExpert\Disco\BeanFactory}.
*/
class MagicSleep extends MagicMethodGenerator
{
/**
* Creates a new {@link \bitExpert\Disco\Proxy\LazyBean\MethodGenerator\MagicSleep}.
*
* @param ReflectionClass<Object> $originalClass
* @param PropertyGenerator $initializerProperty
* @param PropertyGenerator $valueHolderProperty
* @param PropertyGenerator $valueHolderBeanIdProperty
* @throws InvalidArgumentException
*/
public function __construct(
ReflectionClass $originalClass,
PropertyGenerator $initializerProperty,
PropertyGenerator $valueHolderProperty,
PropertyGenerator $valueHolderBeanIdProperty
) {
parent::__construct($originalClass, '__sleep');
$initializer = $initializerProperty->getName();
$valueHolder = $valueHolderProperty->getName();
$valueHolderBeanId = $valueHolderBeanIdProperty->getName();
$this->setBody(
'$this->' . $initializer . ' && $this->' . $initializer
. '->__invoke($this->' . $valueHolder . ', $this, \'__sleep\', array(), $this->'
. $initializer . ');' . PHP_EOL . PHP_EOL
. 'return array(' . var_export($valueHolderBeanId, true) . ');'
);
}
}
| php | Apache-2.0 | bfccc82a4757930e4ec1259fe87c3124888e327c | 2026-01-05T04:45:28.508624Z | false |
bitExpert/disco | https://github.com/bitExpert/disco/blob/bfccc82a4757930e4ec1259fe87c3124888e327c/src/bitExpert/Disco/Proxy/LazyBean/MethodGenerator/MagicWakeup.php | src/bitExpert/Disco/Proxy/LazyBean/MethodGenerator/MagicWakeup.php | <?php
/*
* This file is part of the Disco package.
*
* (c) bitExpert AG
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace bitExpert\Disco\Proxy\LazyBean\MethodGenerator;
use bitExpert\Disco\BeanFactoryRegistry;
use ProxyManager\Generator\MagicMethodGenerator;
use ProxyManager\Proxy\VirtualProxyInterface;
use ReflectionClass;
use Laminas\Code\Generator\Exception\InvalidArgumentException;
use Laminas\Code\Generator\PropertyGenerator;
/**
* `__wakeup` method for lazy loading value holder objects. Will fetch the
* dependency from the {@link \bitExpert\Disco\BeanFactory} during the
* unserialization process.
*/
class MagicWakeup extends MagicMethodGenerator
{
/**
* Creates a new {@link \bitExpert\Disco\Proxy\LazyBean\MethodGenerator\MagicWakeup}.
*
* @param ReflectionClass<Object> $originalClass
* @param PropertyGenerator $valueHolderProperty
* @param PropertyGenerator $valueHolderBeanIdProperty
* @throws InvalidArgumentException
*/
public function __construct(
ReflectionClass $originalClass,
PropertyGenerator $valueHolderProperty,
PropertyGenerator $valueHolderBeanIdProperty
) {
parent::__construct($originalClass, '__wakeup');
$valueHolder = $valueHolderProperty->getName();
$valueHolderBeanId = $valueHolderBeanIdProperty->getName();
$this->setBody(
'$beanFactory = \\' . BeanFactoryRegistry::class . '::getInstance();' . PHP_EOL . PHP_EOL
. '$this->' . $valueHolder . ' = $beanFactory->get($this->' . $valueHolderBeanId . ');' . PHP_EOL
. 'if ($this->' . $valueHolder . ' instanceof \\' . VirtualProxyInterface::class . ') {' . PHP_EOL
. ' $this->' . $valueHolder . ' = $this->' . $valueHolder . '->getWrappedValueHolderValue();' . PHP_EOL
. '}' . PHP_EOL
);
}
}
| php | Apache-2.0 | bfccc82a4757930e4ec1259fe87c3124888e327c | 2026-01-05T04:45:28.508624Z | false |
bitExpert/disco | https://github.com/bitExpert/disco/blob/bfccc82a4757930e4ec1259fe87c3124888e327c/src/bitExpert/Disco/Proxy/LazyBean/PropertyGenerator/ValueHolderBeanIdProperty.php | src/bitExpert/Disco/Proxy/LazyBean/PropertyGenerator/ValueHolderBeanIdProperty.php | <?php
/*
* This file is part of the Disco package.
*
* (c) bitExpert AG
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace bitExpert\Disco\Proxy\LazyBean\PropertyGenerator;
use ProxyManager\Generator\Util\UniqueIdentifierGenerator;
use Laminas\Code\Generator\Exception\InvalidArgumentException;
use Laminas\Code\Generator\PropertyGenerator;
/**
* Property that contains the beanId of the wrapped value object.
*/
class ValueHolderBeanIdProperty extends PropertyGenerator
{
/**
* Creates a new {@link \bitExpert\Disco\Proxy\LazyBean\PropertyGenerator\ValueHolderBeanIdProperty}.
*
* @throws InvalidArgumentException
*/
public function __construct()
{
parent::__construct(UniqueIdentifierGenerator::getIdentifier('valueHolderBeanId'));
$this->setVisibility(self::VISIBILITY_PRIVATE);
$this->setDocBlock('@var \\string beanId');
}
}
| php | Apache-2.0 | bfccc82a4757930e4ec1259fe87c3124888e327c | 2026-01-05T04:45:28.508624Z | false |
bitExpert/disco | https://github.com/bitExpert/disco/blob/bfccc82a4757930e4ec1259fe87c3124888e327c/src/bitExpert/Disco/Proxy/Configuration/AliasContainerInterface.php | src/bitExpert/Disco/Proxy/Configuration/AliasContainerInterface.php | <?php
/*
* This file is part of the Disco package.
*
* (c) bitExpert AG
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace bitExpert\Disco\Proxy\Configuration;
use bitExpert\Disco\BeanException;
use bitExpert\Disco\BeanNotFoundException;
/**
* Interface similar to {@link \Psr\Container\ContainerInterface}. The interface is needed
* to be able to retrieve aliased beans from the generated configuration class.
*/
interface AliasContainerInterface
{
/**
* Finds an entry of the container by the given alias and returns it.
*
* @param string $alias Alias of the entry to look for.
* @return mixed
* @throws BeanNotFoundException No entry was found for this alias.
* @throws BeanException Error while retrieving the entry.
*/
public function getAlias(string $alias);
/**
* Returns true if the container can return an entry for the given alias.
* Returns false otherwise.
*
* @param string $alias Identifier of the entry to look for
* @return boolean
*/
public function hasAlias(string $alias): bool;
}
| php | Apache-2.0 | bfccc82a4757930e4ec1259fe87c3124888e327c | 2026-01-05T04:45:28.508624Z | false |
bitExpert/disco | https://github.com/bitExpert/disco/blob/bfccc82a4757930e4ec1259fe87c3124888e327c/src/bitExpert/Disco/Proxy/Configuration/ConfigurationFactory.php | src/bitExpert/Disco/Proxy/Configuration/ConfigurationFactory.php | <?php
/*
* This file is part of the Disco package.
*
* (c) bitExpert AG
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace bitExpert\Disco\Proxy\Configuration;
use bitExpert\Disco\BeanFactoryConfiguration;
use ProxyManager\Factory\AbstractBaseFactory;
use ProxyManager\ProxyGenerator\ProxyGeneratorInterface;
/**
* Factory responsible of producing a proxy of the configuration instance.
*/
class ConfigurationFactory extends AbstractBaseFactory
{
/**
* @var ConfigurationGenerator
*/
private $generator;
/**
* Creates a new {@link \bitExpert\Disco\Proxy\Configuration\ConfigurationFactory}.
*
* @param BeanFactoryConfiguration $config
*/
public function __construct(BeanFactoryConfiguration $config)
{
parent::__construct($config->getProxyManagerConfiguration());
$this->generator = new ConfigurationGenerator();
}
/**
* Creates an instance of the given $configClassName.
*
* @param BeanFactoryConfiguration $config
* @param class-string<Object> $configClassName name of the configuration class
* @param array<mixed> $parameters
* @return AliasContainerInterface
*/
public function createInstance(
BeanFactoryConfiguration $config,
string $configClassName,
array $parameters = []
): AliasContainerInterface {
$proxyClassName = $this->generateProxy($configClassName);
/** @var AliasContainerInterface $proxy */
$proxy = new $proxyClassName($config, $parameters);
return $proxy;
}
/**
* {@inheritDoc}
*/
protected function getGenerator(): ProxyGeneratorInterface
{
return $this->generator;
}
}
| php | Apache-2.0 | bfccc82a4757930e4ec1259fe87c3124888e327c | 2026-01-05T04:45:28.508624Z | false |
bitExpert/disco | https://github.com/bitExpert/disco/blob/bfccc82a4757930e4ec1259fe87c3124888e327c/src/bitExpert/Disco/Proxy/Configuration/ConfigurationGenerator.php | src/bitExpert/Disco/Proxy/Configuration/ConfigurationGenerator.php | <?php
/*
* This file is part of the Disco package.
*
* (c) bitExpert AG
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace bitExpert\Disco\Proxy\Configuration;
use bitExpert\Disco\Annotations\Bean;
use bitExpert\Disco\Annotations\BeanPostProcessor;
use bitExpert\Disco\Annotations\Configuration;
use bitExpert\Disco\Annotations\Parameters;
use bitExpert\Disco\Proxy\Configuration\MethodGenerator\BeanMethod;
use bitExpert\Disco\Proxy\Configuration\MethodGenerator\BeanPostProcessorMethod;
use bitExpert\Disco\Proxy\Configuration\MethodGenerator\Constructor;
use bitExpert\Disco\Proxy\Configuration\MethodGenerator\GetAlias;
use bitExpert\Disco\Proxy\Configuration\MethodGenerator\GetParameter;
use bitExpert\Disco\Proxy\Configuration\MethodGenerator\HasAlias;
use bitExpert\Disco\Proxy\Configuration\MethodGenerator\MagicSleep;
use bitExpert\Disco\Proxy\Configuration\MethodGenerator\WrapBeanAsLazy;
use bitExpert\Disco\Proxy\Configuration\PropertyGenerator\AliasesProperty;
use bitExpert\Disco\Proxy\Configuration\PropertyGenerator\BeanFactoryConfigurationProperty;
use bitExpert\Disco\Proxy\Configuration\PropertyGenerator\BeanPostProcessorsProperty;
use bitExpert\Disco\Proxy\Configuration\PropertyGenerator\ForceLazyInitProperty;
use bitExpert\Disco\Proxy\Configuration\PropertyGenerator\ParameterValuesProperty;
use bitExpert\Disco\Proxy\Configuration\PropertyGenerator\SessionBeansProperty;
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\AnnotationRegistry;
use Exception;
use ProxyManager\Exception\InvalidProxiedClassException;
use ProxyManager\ProxyGenerator\Assertion\CanProxyAssertion;
use ProxyManager\ProxyGenerator\ProxyGeneratorInterface;
use ReflectionClass;
use ReflectionMethod;
use Laminas\Code\Generator\ClassGenerator;
use Laminas\Code\Generator\Exception\InvalidArgumentException;
use Laminas\Code\Reflection\MethodReflection;
/**
* Generator for configuration classes.
*/
class ConfigurationGenerator implements ProxyGeneratorInterface
{
/**
* Creates a new {@link \bitExpert\Disco\Proxy\Configuration\ConfigurationGenerator}.
*/
public function __construct()
{
// registers all required annotations
AnnotationRegistry::registerFile(__DIR__ . '/../../Annotations/Bean.php');
AnnotationRegistry::registerFile(__DIR__ . '/../../Annotations/Alias.php');
AnnotationRegistry::registerFile(__DIR__ . '/../../Annotations/BeanPostProcessor.php');
AnnotationRegistry::registerFile(__DIR__ . '/../../Annotations/Configuration.php');
AnnotationRegistry::registerFile(__DIR__ . '/../../Annotations/Parameter.php');
}
/**
* {@inheritDoc}
* @param ReflectionClass $originalClass
* @param ClassGenerator $classGenerator
* @throws InvalidProxiedClassException
* @throws InvalidArgumentException
* @throws \ReflectionException
*/
public function generate(ReflectionClass $originalClass, ClassGenerator $classGenerator)
{
CanProxyAssertion::assertClassCanBeProxied($originalClass, false);
$annotation = null;
$forceLazyInitProperty = new ForceLazyInitProperty();
$sessionBeansProperty = new SessionBeansProperty();
$postProcessorsProperty = new BeanPostProcessorsProperty();
$parameterValuesProperty = new ParameterValuesProperty();
$beanFactoryConfigurationProperty = new BeanFactoryConfigurationProperty();
$aliasesProperty = new AliasesProperty();
$getParameterMethod = new GetParameter($parameterValuesProperty);
$wrapBeanAsLazyMethod = new WrapBeanAsLazy($beanFactoryConfigurationProperty);
try {
$reader = new AnnotationReader();
$annotation = $reader->getClassAnnotation($originalClass, Configuration::class);
} catch (Exception $e) {
throw new InvalidProxiedClassException($e->getMessage(), $e->getCode(), $e);
}
if (null === $annotation) {
throw new InvalidProxiedClassException(
sprintf(
'"%s" seems not to be a valid configuration class. @Configuration annotation missing!',
$originalClass->name
)
);
}
$classGenerator->setExtendedClass($originalClass->getName());
$classGenerator->setImplementedInterfaces([AliasContainerInterface::class]);
$classGenerator->addPropertyFromGenerator($forceLazyInitProperty);
$classGenerator->addPropertyFromGenerator($sessionBeansProperty);
$classGenerator->addPropertyFromGenerator($postProcessorsProperty);
$classGenerator->addPropertyFromGenerator($parameterValuesProperty);
$classGenerator->addPropertyFromGenerator($beanFactoryConfigurationProperty);
$classGenerator->addPropertyFromGenerator($aliasesProperty);
$postProcessorMethods = [];
$parentAliases = [];
$localAliases = [];
$methods = $originalClass->getMethods(ReflectionMethod::IS_PUBLIC | ReflectionMethod::IS_PROTECTED);
foreach ($methods as $method) {
$methodReflection = new MethodReflection(
$method->class,
$method->name
);
/** @var \bitExpert\Disco\Annotations\Bean|null $beanAnnotation */
$beanAnnotation = $reader->getMethodAnnotation($method, Bean::class);
if (null === $beanAnnotation) {
/** @var \bitExpert\Disco\Annotations\BeanPostProcessor|null $beanAnnotation */
$beanAnnotation = $reader->getMethodAnnotation($method, BeanPostProcessor::class);
if ($beanAnnotation instanceof BeanPostProcessor) {
$postProcessorMethods[] = $method->name;
$proxyMethod = BeanPostProcessorMethod::generateMethod(
$methodReflection,
$beanAnnotation,
$getParameterMethod
);
$classGenerator->addMethodFromGenerator($proxyMethod);
continue;
}
if ($method->isProtected()) {
continue;
}
// every method needs either @Bean or @PostPostprocessor annotation
throw new InvalidProxiedClassException(
sprintf(
'Method "%s" on "%s" is missing the @Bean annotation!',
$method->name,
$originalClass->name
)
);
}
foreach ($beanAnnotation->getAliases() as $beanAlias) {
$alias = $beanAlias->isTypeAlias() ? (string) $method->getReturnType() : $beanAlias->getName();
$hasAlias = '';
if ($method->getDeclaringClass()->name === $originalClass->name) {
$hasAlias = $localAliases[$alias] ?? '';
} else {
$hasAlias= $parentAliases[$alias] ?? '';
}
if ($hasAlias !== '') {
throw new InvalidProxiedClassException(
sprintf(
'Alias "%s" of method "%s" on "%s" is already used by method "%s" of another Bean!'
. ' Did you use a type alias twice?',
$alias,
$method->name,
$originalClass->name,
$hasAlias
)
);
}
if ($method->getDeclaringClass()->name === $originalClass->name) {
$localAliases[$alias] = $method->name;
} else {
$parentAliases[$alias] = $method->name;
}
}
$proxyMethod = BeanMethod::generateMethod(
$methodReflection,
$beanAnnotation,
$method->getReturnType(),
$forceLazyInitProperty,
$sessionBeansProperty,
$postProcessorsProperty,
$beanFactoryConfigurationProperty,
$getParameterMethod,
$wrapBeanAsLazyMethod
);
$classGenerator->addMethodFromGenerator($proxyMethod);
}
$aliasesProperty->setDefaultValue($parentAliases + $localAliases);
$classGenerator->addMethodFromGenerator(
new Constructor(
$parameterValuesProperty,
$sessionBeansProperty,
$beanFactoryConfigurationProperty,
$postProcessorsProperty,
$postProcessorMethods
)
);
$classGenerator->addMethodFromGenerator($wrapBeanAsLazyMethod);
$classGenerator->addMethodFromGenerator($getParameterMethod);
$classGenerator->addMethodFromGenerator(
new MagicSleep(
$originalClass,
$sessionBeansProperty
)
);
$classGenerator->addMethodFromGenerator(
new GetAlias($aliasesProperty)
);
$classGenerator->addMethodFromGenerator(
new HasAlias($aliasesProperty)
);
}
}
| php | Apache-2.0 | bfccc82a4757930e4ec1259fe87c3124888e327c | 2026-01-05T04:45:28.508624Z | false |
bitExpert/disco | https://github.com/bitExpert/disco/blob/bfccc82a4757930e4ec1259fe87c3124888e327c/src/bitExpert/Disco/Proxy/Configuration/MethodGenerator/ParameterAwareMethodGenerator.php | src/bitExpert/Disco/Proxy/Configuration/MethodGenerator/ParameterAwareMethodGenerator.php | <?php
/*
* This file is part of the Disco package.
*
* (c) bitExpert AG
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace bitExpert\Disco\Proxy\Configuration\MethodGenerator;
use bitExpert\Disco\Annotations\Parameter;
use Laminas\Code\Generator\MethodGenerator;
/**
* Base class for all annotations that are parameter-aware.
*/
class ParameterAwareMethodGenerator extends MethodGenerator
{
/**
* Converts the Parameter annotations to the respective getParameter() method calls to retrieve the configuration
* values.
*
* @param Parameter[] $methodParameters
* @param GetParameter $parameterValuesMethod
* @return string
*/
protected static function convertMethodParamsToString(
array $methodParameters,
GetParameter $parameterValuesMethod
): string {
$parameters = [];
foreach ($methodParameters as $methodParameter) {
/** @var Parameter $methodParameter */
$defaultValue = $methodParameter->getDefaultValue();
switch (\gettype($defaultValue)) {
case 'string':
$defaultValue = '"' . $defaultValue . '"';
break;
case 'boolean':
$defaultValue = ($defaultValue === true) ? 'true' : 'false';
break;
case 'NULL':
$defaultValue = 'null';
break;
default:
break;
}
$template = ($defaultValue === '') ? '$this->%s("%s", %s)' : '$this->%s("%s", %s, %s)';
$required = $methodParameter->isRequired() ? 'true' : 'false';
$methodName = $parameterValuesMethod->getName();
$parameters[] = \sprintf($template, $methodName, $methodParameter->getName(), $required, $defaultValue);
}
return \implode(', ', $parameters);
}
}
| php | Apache-2.0 | bfccc82a4757930e4ec1259fe87c3124888e327c | 2026-01-05T04:45:28.508624Z | false |
bitExpert/disco | https://github.com/bitExpert/disco/blob/bfccc82a4757930e4ec1259fe87c3124888e327c/src/bitExpert/Disco/Proxy/Configuration/MethodGenerator/Constructor.php | src/bitExpert/Disco/Proxy/Configuration/MethodGenerator/Constructor.php | <?php
/*
* This file is part of the 02003-bitExpertLabs-24-Disco package.
*
* (c) bitExpert AG
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace bitExpert\Disco\Proxy\Configuration\MethodGenerator;
use bitExpert\Disco\BeanFactoryConfiguration;
use bitExpert\Disco\Proxy\Configuration\PropertyGenerator\BeanFactoryConfigurationProperty;
use bitExpert\Disco\Proxy\Configuration\PropertyGenerator\BeanPostProcessorsProperty;
use bitExpert\Disco\Proxy\Configuration\PropertyGenerator\ParameterValuesProperty;
use bitExpert\Disco\Proxy\Configuration\PropertyGenerator\SessionBeansProperty;
use ProxyManager\Generator\MethodGenerator;
use ReflectionClass;
use Laminas\Code\Generator\ParameterGenerator;
/**
* `__construct` method for the generated config proxy class.
*/
class Constructor extends MethodGenerator
{
/**
* Creates a new {@link \bitExpert\Disco\Proxy\Configuration\MethodGenerator\Constructor}.
*
* @param ParameterValuesProperty $parameterValuesProperty
* @param SessionBeansProperty $sessionBeansProperty
* @param BeanFactoryConfigurationProperty $beanFactoryConfigurationProperty
* @param BeanPostProcessorsProperty $beanPostProcessorsProperty
* @param string[] $beanPostProcessorMethodNames
*/
public function __construct(
ParameterValuesProperty $parameterValuesProperty,
SessionBeansProperty $sessionBeansProperty,
BeanFactoryConfigurationProperty $beanFactoryConfigurationProperty,
BeanPostProcessorsProperty $beanPostProcessorsProperty,
array $beanPostProcessorMethodNames
) {
parent::__construct('__construct');
$beanFactoryConfigurationParameter = new ParameterGenerator('config');
$beanFactoryConfigurationParameter->setType(BeanFactoryConfiguration::class);
$parametersParameter = new ParameterGenerator('params');
$parametersParameter->setDefaultValue([]);
$body = '$this->' . $parameterValuesProperty->getName() . ' = $' . $parametersParameter->getName() .
';' . PHP_EOL;
$body .= '$this->' . $beanFactoryConfigurationProperty->getName() .
' = $' . $beanFactoryConfigurationParameter->getName() . ';' . PHP_EOL;
$body .= '$this->' . $sessionBeansProperty->getName() . ' = $' . $beanFactoryConfigurationParameter->getName() .
'->getSessionBeanStore();' . PHP_EOL;
$body .= '// register {@link \\bitExpert\\Disco\\BeanPostProcessor} instances' . PHP_EOL;
foreach ($beanPostProcessorMethodNames as $methodName) {
$body .= '$this->' . $beanPostProcessorsProperty->getName() . '[] = $this->' . $methodName . '(); ';
$body .= PHP_EOL;
}
$this->setParameter($beanFactoryConfigurationParameter);
$this->setParameter($parametersParameter);
$this->setBody($body);
$this->setDocBlock('@override constructor');
}
}
| php | Apache-2.0 | bfccc82a4757930e4ec1259fe87c3124888e327c | 2026-01-05T04:45:28.508624Z | false |
bitExpert/disco | https://github.com/bitExpert/disco/blob/bfccc82a4757930e4ec1259fe87c3124888e327c/src/bitExpert/Disco/Proxy/Configuration/MethodGenerator/BeanMethod.php | src/bitExpert/Disco/Proxy/Configuration/MethodGenerator/BeanMethod.php | <?php
/*
* This file is part of the Disco package.
*
* (c) bitExpert AG
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace bitExpert\Disco\Proxy\Configuration\MethodGenerator;
use bitExpert\Disco\Annotations\Bean;
use bitExpert\Disco\BeanException;
use bitExpert\Disco\InitializedBean;
use bitExpert\Disco\Proxy\Configuration\PropertyGenerator\BeanFactoryConfigurationProperty;
use bitExpert\Disco\Proxy\Configuration\PropertyGenerator\BeanPostProcessorsProperty;
use bitExpert\Disco\Proxy\Configuration\PropertyGenerator\ForceLazyInitProperty;
use bitExpert\Disco\Proxy\Configuration\PropertyGenerator\SessionBeansProperty;
use bitExpert\Disco\Proxy\LazyBean\LazyBeanFactory;
use ProxyManager\Exception\InvalidProxiedClassException;
use ProxyManager\Proxy\LazyLoadingInterface;
use ReflectionType;
use Laminas\Code\Generator\MethodGenerator;
use Laminas\Code\Generator\ParameterGenerator;
use Laminas\Code\Reflection\MethodReflection;
/**
* The bean method generator will generate a method for each bean definition in the generated
* configuration class. The method contains the logic to deal with the bean creation as well
* as taking the configuration options like lazy creation or session-awareness of the bean into
* account. These configuration options are defined via annotations.
*/
class BeanMethod extends ParameterAwareMethodGenerator
{
/**
* Creates a new {@link \bitExpert\Disco\Proxy\Configuration\MethodGenerator\BeanMethod}.
*
* @param MethodReflection $originalMethod
* @param Bean $beanMetadata
* @param ReflectionType|null $beanType
* @param ForceLazyInitProperty $forceLazyInitProperty
* @param SessionBeansProperty $sessionBeansProperty
* @param BeanPostProcessorsProperty $postProcessorsProperty
* @param BeanFactoryConfigurationProperty $beanFactoryConfigurationProperty
* @param GetParameter $parameterValuesMethod
* @param WrapBeanAsLazy $wrapBeanAsLazy
* @return MethodGenerator
* @throws \Laminas\Code\Generator\Exception\InvalidArgumentException
* @throws \ProxyManager\Exception\InvalidProxiedClassException
*/
public static function generateMethod(
MethodReflection $originalMethod,
Bean $beanMetadata,
?ReflectionType $beanType,
ForceLazyInitProperty $forceLazyInitProperty,
SessionBeansProperty $sessionBeansProperty,
BeanPostProcessorsProperty $postProcessorsProperty,
BeanFactoryConfigurationProperty $beanFactoryConfigurationProperty,
GetParameter $parameterValuesMethod,
WrapBeanAsLazy $wrapBeanAsLazy
): MethodGenerator {
if (null === $beanType) {
throw new InvalidProxiedClassException(
sprintf(
'Method "%s" on "%s" is missing the return type hint!',
$originalMethod->name,
$originalMethod->class
)
);
}
$beanType = (string) $beanType;
$method = static::fromReflection($originalMethod);
$methodParams = static::convertMethodParamsToString($beanMetadata->getParameters(), $parameterValuesMethod);
$beanId = $originalMethod->name;
$body = '';
if (in_array($beanType, ['array', 'callable', 'bool', 'float', 'int', 'string'], true)) {
// return type is a primitive, simply call parent method and return immediately
$body .= 'return parent::' . $beanId . '(' . $methodParams . ');' . PHP_EOL;
} elseif (class_exists($beanType) || interface_exists($beanType)) {
if ($beanMetadata->isLazy()) {
$body = static::generateLazyBeanCode(
'',
$beanId,
$beanType,
$beanMetadata,
$methodParams,
$forceLazyInitProperty,
$sessionBeansProperty,
$postProcessorsProperty,
$beanFactoryConfigurationProperty
);
} else {
$body = static::generateNonLazyBeanCode(
'',
$beanId,
$beanType,
$beanMetadata,
$methodParams,
$forceLazyInitProperty,
$sessionBeansProperty,
$postProcessorsProperty,
$wrapBeanAsLazy
);
}
} else {
// return type is unknown, throw an exception
throw new InvalidProxiedClassException(
sprintf(
'Return type of method "%s" on "%s" cannot be found! Did you use the full qualified name?',
$originalMethod->getName(),
$originalMethod->getDeclaringClass()->getName()
)
);
}
$method->setBody($body);
$method->setDocBlock('{@inheritDoc}');
return $method;
}
/**
* @override Enforces generation of \ProxyManager\Generator\MethodGenerator.
*
* {@inheritDoc}
* @throws \Laminas\Code\Generator\Exception\InvalidArgumentException
*/
public static function fromReflection(MethodReflection $reflectionMethod): MethodGenerator
{
$method = parent::fromReflection($reflectionMethod);
/*
* When overwriting methods PHP 7 enforces the same method parameters to be defined as in the base class. Since
* the {@link \bitExpert\Disco\AnnotationBeanFactory} calls the generated methods without any parameters we
* simply set a default value of null for each of the method parameters.
*/
$method->setParameters([]);
foreach ($reflectionMethod->getParameters() as $reflectionParameter) {
$parameter = ParameterGenerator::fromReflection($reflectionParameter);
$parameter->setDefaultValue(null);
$method->setParameter($parameter);
}
return $method;
}
/**
* Helper method to generate the method body for managing lazy bean instances.
*
* @param string $padding
* @param string $beanId
* @param string $beanType
* @param Bean $beanMetadata
* @param string $methodParams
* @param ForceLazyInitProperty $forceLazyInitProperty
* @param SessionBeansProperty $sessionBeansProperty
* @param BeanPostProcessorsProperty $postProcessorsProperty
* @param BeanFactoryConfigurationProperty $beanFactoryConfigurationProperty
* @return string
*/
protected static function generateLazyBeanCode(
string $padding,
string $beanId,
string $beanType,
Bean $beanMetadata,
string $methodParams,
ForceLazyInitProperty $forceLazyInitProperty,
SessionBeansProperty $sessionBeansProperty,
BeanPostProcessorsProperty $postProcessorsProperty,
BeanFactoryConfigurationProperty $beanFactoryConfigurationProperty
): string {
$content = '';
if ($beanMetadata->isSession()) {
$content .= $padding . 'if($this->' . $sessionBeansProperty->getName() . '->has("' . $beanId . '")) {' .
PHP_EOL;
if ($beanMetadata->isSingleton()) {
$content .= $padding . ' $sessionInstance = clone $this->' . $sessionBeansProperty->getName() .
'->get("' . $beanId . '");' . PHP_EOL;
} else {
$content .= $padding . ' $sessionInstance = $this->' . $sessionBeansProperty->getName() . '->get("' .
$beanId . '");' . PHP_EOL;
}
$content .= $padding . ' return $sessionInstance;' . PHP_EOL;
$content .= $padding . '}' . PHP_EOL;
}
if ($beanMetadata->isSingleton()) {
$content .= $padding . 'static $instance = null;' . PHP_EOL;
$content .= $padding . 'if ($instance !== null) {' . PHP_EOL;
$content .= $padding . ' return $instance;' . PHP_EOL;
$content .= $padding . '}' . PHP_EOL;
}
$content .= $padding . '$factory = new \\' . LazyBeanFactory::class . '("' . $beanId . '", $this->' .
$beanFactoryConfigurationProperty->getName() . '->getProxyManagerConfiguration());' . PHP_EOL;
$content .= $padding . '$initializer = function (&$instance, \\' . LazyLoadingInterface::class .
' $proxy, $method, array $parameters, &$initializer) {' . PHP_EOL;
$content .= $padding . ' try {' . PHP_EOL;
$content .= $padding . ' $initializer = null;' . PHP_EOL;
if ($beanMetadata->isSession()) {
$content .= $padding . ' $backupForceLazyInit = $this->' . $forceLazyInitProperty->getName() . ';'
. PHP_EOL;
$content .= $padding . ' $this->' . $forceLazyInitProperty->getName() . ' = true;' . PHP_EOL;
}
$content .= $padding . self::generateBeanCreationCode(
$padding . ' ',
$beanId,
$methodParams,
$postProcessorsProperty
);
if ($beanMetadata->isSession()) {
$content .= $padding . ' $this->' . $forceLazyInitProperty->getName() . ' = $backupForceLazyInit;' .
PHP_EOL;
}
$content .= $padding . ' } catch (\Throwable $e) {' . PHP_EOL;
$content .= $padding . ' $message = sprintf(' . PHP_EOL;
$content .= $padding . ' \'Either return type declaration missing or unknown for bean with id "' .
$beanId . '": %s\',' . PHP_EOL;
$content .= $padding . ' $e->getMessage()' . PHP_EOL;
$content .= $padding . ' );' . PHP_EOL;
$content .= $padding . ' throw new \\' . BeanException::class . '($message, 0, $e);' . PHP_EOL;
$content .= $padding . ' }' . PHP_EOL;
$content .= $padding . ' return true;' . PHP_EOL;
$content .= $padding . '};' . PHP_EOL;
$content .= $padding . PHP_EOL;
$content .= $padding . '$initializer->bindTo($this);' . PHP_EOL;
$content .= $padding . '$instance = $factory->createProxy("' . $beanType . '", $initializer);' . PHP_EOL;
if ($beanMetadata->isSession()) {
$content .= $padding . '$this->' . $sessionBeansProperty->getName() . '->add("' . $beanId . '", $instance);'
. PHP_EOL;
}
$content .= $padding . 'return $instance;' . PHP_EOL;
return $content;
}
/**
* Helper method to generate the code to initialize a bean.
*
* @param string $padding
* @param string $beanId
* @param string $methodParams
* @param BeanPostProcessorsProperty $postProcessorsProperty
* @return string
*/
protected static function generateBeanCreationCode(
string $padding,
string $beanId,
string $methodParams,
BeanPostProcessorsProperty $postProcessorsProperty
): string {
$content = $padding . '$instance = parent::' . $beanId . '(' . $methodParams . ');' . PHP_EOL;
$content .= $padding . 'if ($instance instanceof \\' . InitializedBean::class . ') {
' . PHP_EOL;
$content .= $padding . ' $instance->postInitialization();' . PHP_EOL;
$content .= $padding . '}' . PHP_EOL;
$content .= PHP_EOL;
$content .= $padding . 'foreach ($this->' . $postProcessorsProperty->getName() . ' as $postProcessor) {
' .
PHP_EOL;
$content .= $padding . ' $postProcessor->postProcess($instance, "' . $beanId . '");' . PHP_EOL;
$content .= $padding . '}' . PHP_EOL;
return $content;
}
/**
* Helper method to generate the method body for managing non-lazy bean instances.
*
* @param string $padding
* @param string $beanId
* @param string $beanType
* @param Bean $beanMetadata
* @param string $methodParams
* @param ForceLazyInitProperty $forceLazyInitProperty
* @param SessionBeansProperty $sessionBeansProperty
* @param BeanPostProcessorsProperty $postProcessorsProperty
* @param WrapBeanAsLazy $wrapBeanAsLazy
* @return string
*/
protected static function generateNonLazyBeanCode(
string $padding,
string $beanId,
string $beanType,
Bean $beanMetadata,
string $methodParams,
ForceLazyInitProperty $forceLazyInitProperty,
SessionBeansProperty $sessionBeansProperty,
BeanPostProcessorsProperty $postProcessorsProperty,
WrapBeanAsLazy $wrapBeanAsLazy
): string {
$content = $padding . '$backupForceLazyInit = $this->' . $forceLazyInitProperty->getName() . ';' . PHP_EOL;
if ($beanMetadata->isSession()) {
$content .= $padding . 'if($this->' . $sessionBeansProperty->getName() . '->has("' . $beanId . '")) {'
. PHP_EOL;
if ($beanMetadata->isSingleton()) {
$content .= $padding . ' $sessionInstance = clone $this->' . $sessionBeansProperty->getName()
. '->get("' . $beanId . '");' . PHP_EOL;
} else {
$content .= $padding . ' $sessionInstance = $this->' . $sessionBeansProperty->getName() . '->get("' .
$beanId . '");' . PHP_EOL;
}
$content .= $padding . ' return ($backupForceLazyInit) ? $this->' . $wrapBeanAsLazy->getName() . '("' .
$beanId . '", "' . $beanType . '", $sessionInstance) : $sessionInstance;' . PHP_EOL;
$content .= $padding . '}' . PHP_EOL;
}
if ($beanMetadata->isSingleton()) {
$content .= $padding . 'static $instance = null;' . PHP_EOL;
$content .= $padding . 'if ($instance !== null) {' . PHP_EOL;
$content .= $padding . ' return ($backupForceLazyInit) ? $this->' . $wrapBeanAsLazy->getName() . '("' .
$beanId . '", "' . $beanType . '", $instance) : $instance;' . PHP_EOL;
$content .= $padding . '}' . PHP_EOL;
}
if ($beanMetadata->isSession()) {
$content .= $padding . '$this->' . $forceLazyInitProperty->getName() . ' = true;' . PHP_EOL;
}
$content .= self::generateBeanCreationCode($padding, $beanId, $methodParams, $postProcessorsProperty);
if ($beanMetadata->isSession()) {
$content .= $padding . '$this->' . $forceLazyInitProperty->getName() . ' = $backupForceLazyInit;' . PHP_EOL;
$content .= $padding . '$this->' . $sessionBeansProperty->getName() . '->add("' . $beanId . '", $instance);'
. PHP_EOL;
}
$content .= $padding . 'return ($backupForceLazyInit) ? $this->' . $wrapBeanAsLazy->getName() . '("' .
$beanId . '", "' . $beanType . '", $instance) : $instance;' . PHP_EOL;
return $content;
}
}
| php | Apache-2.0 | bfccc82a4757930e4ec1259fe87c3124888e327c | 2026-01-05T04:45:28.508624Z | false |
bitExpert/disco | https://github.com/bitExpert/disco/blob/bfccc82a4757930e4ec1259fe87c3124888e327c/src/bitExpert/Disco/Proxy/Configuration/MethodGenerator/WrapBeanAsLazy.php | src/bitExpert/Disco/Proxy/Configuration/MethodGenerator/WrapBeanAsLazy.php | <?php
/*
* This file is part of the 02003-bitExpertLabs-24-Disco package.
*
* (c) bitExpert AG
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace bitExpert\Disco\Proxy\Configuration\MethodGenerator;
use bitExpert\Disco\Proxy\Configuration\PropertyGenerator\BeanFactoryConfigurationProperty;
use ProxyManager\Generator\MethodGenerator;
use ProxyManager\Generator\Util\UniqueIdentifierGenerator;
use ReflectionClass;
use Laminas\Code\Generator\ParameterGenerator;
/**
* `wrapBeanAsLazy` method for lazy loading value holder objects.
*/
class WrapBeanAsLazy extends MethodGenerator
{
/**
* Creates a new {@link \bitExpert\Disco\Proxy\LazyBean\MethodGenerator\Constructor}.
*
* @param BeanFactoryConfigurationProperty $beanFactoryConfigurationProperty
*/
public function __construct(
BeanFactoryConfigurationProperty $beanFactoryConfigurationProperty
) {
parent::__construct(UniqueIdentifierGenerator::getIdentifier('wrapBeanAsLazy'));
$this->setParameter(new ParameterGenerator('beanId'));
$this->setParameter(new ParameterGenerator('beanType'));
$this->setParameter(new ParameterGenerator('instance'));
$content = '$factory = new \\' . \bitExpert\Disco\Proxy\LazyBean\LazyBeanFactory::class . '($beanId, $this->' .
$beanFactoryConfigurationProperty->getName() . '->getProxyManagerConfiguration());' . PHP_EOL;
$content .= '$initializer = function (&$wrappedObject, \\' . \ProxyManager\Proxy\LazyLoadingInterface::class .
' $proxy, $method, array $parameters, &$initializer) use($instance) {' . PHP_EOL;
$content .= ' $initializer = null;' . PHP_EOL;
$content .= ' $wrappedObject = $instance;' . PHP_EOL;
$content .= ' return true;' . PHP_EOL;
$content .= '};' . PHP_EOL;
$content .= PHP_EOL;
$content .= '$initializer->bindTo($this);' . PHP_EOL;
$content .= 'return $factory->createProxy($beanType, $initializer);' . PHP_EOL;
$this->setVisibility(self::VISIBILITY_PROTECTED);
$this->setBody($content);
}
}
| php | Apache-2.0 | bfccc82a4757930e4ec1259fe87c3124888e327c | 2026-01-05T04:45:28.508624Z | false |
bitExpert/disco | https://github.com/bitExpert/disco/blob/bfccc82a4757930e4ec1259fe87c3124888e327c/src/bitExpert/Disco/Proxy/Configuration/MethodGenerator/MagicSleep.php | src/bitExpert/Disco/Proxy/Configuration/MethodGenerator/MagicSleep.php | <?php
/*
* This file is part of the Disco package.
*
* (c) bitExpert AG
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace bitExpert\Disco\Proxy\Configuration\MethodGenerator;
use bitExpert\Disco\Proxy\Configuration\PropertyGenerator\SessionBeansProperty;
use ProxyManager\Generator\MagicMethodGenerator;
use ReflectionClass;
use Laminas\Code\Generator\Exception\InvalidArgumentException;
/**
* `__sleep` method for the generated config proxy class.
*/
class MagicSleep extends MagicMethodGenerator
{
/**
* Creates a new {@link \bitExpert\Disco\Proxy\Configuration\MethodGenerator\MagicSleep}.
*
* @param ReflectionClass<Object> $originalClass
* @param SessionBeansProperty $aliasesProperty
* @throws InvalidArgumentException
*/
public function __construct(ReflectionClass $originalClass, SessionBeansProperty $aliasesProperty)
{
parent::__construct($originalClass, '__sleep');
$this->setBody(
'return ["' . $aliasesProperty->getName() . '"];'
);
}
}
| php | Apache-2.0 | bfccc82a4757930e4ec1259fe87c3124888e327c | 2026-01-05T04:45:28.508624Z | false |
bitExpert/disco | https://github.com/bitExpert/disco/blob/bfccc82a4757930e4ec1259fe87c3124888e327c/src/bitExpert/Disco/Proxy/Configuration/MethodGenerator/GetParameter.php | src/bitExpert/Disco/Proxy/Configuration/MethodGenerator/GetParameter.php | <?php
/*
* This file is part of the Disco package.
*
* (c) bitExpert AG
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace bitExpert\Disco\Proxy\Configuration\MethodGenerator;
use bitExpert\Disco\Proxy\Configuration\PropertyGenerator\ParameterValuesProperty;
use ProxyManager\Generator\MethodGenerator;
use ProxyManager\Generator\Util\UniqueIdentifierGenerator;
use ReflectionClass;
use Laminas\Code\Generator\Exception\InvalidArgumentException;
use Laminas\Code\Generator\ParameterGenerator;
/**
* `getParameter` method for the generated config proxy class.
*/
class GetParameter extends MethodGenerator
{
/**
* Creates a new {@link \bitExpert\Disco\Proxy\Configuration\MethodGenerator\GetParameter}.
*
* @param ParameterValuesProperty $parameterValueProperty
* @throws InvalidArgumentException
*/
public function __construct(ParameterValuesProperty $parameterValueProperty)
{
parent::__construct(UniqueIdentifierGenerator::getIdentifier('getParameter'));
$propertyNameParameter = new ParameterGenerator('propertyName');
$requiredParameter = new ParameterGenerator('required');
$requiredParameter->setDefaultValue(true);
$defaultValueParameter = new ParameterGenerator('defaultValue');
$defaultValueParameter->setDefaultValue(null);
$body = '$steps = explode(\'.\', $' . $propertyNameParameter->getName() . ');' . PHP_EOL;
$body .= '$value = $this->' . $parameterValueProperty->getName() . ';' . PHP_EOL;
$body .= '$currentPath = [];' . PHP_EOL;
$body .= 'foreach ($steps as $step) {' . PHP_EOL;
$body .= ' $currentPath[] = $step;' . PHP_EOL;
$body .= ' if (isset($value[$step])) {' . PHP_EOL;
$body .= ' $value = $value[$step];' . PHP_EOL;
$body .= ' } else {' . PHP_EOL;
$body .= ' $value = $' . $defaultValueParameter->getName() . ';' . PHP_EOL;
$body .= ' break;' . PHP_EOL;
$body .= ' }' . PHP_EOL;
$body .= '}' . PHP_EOL . PHP_EOL;
$body .= 'if ($' . $requiredParameter->getName() . ' && (null === $value)) {' . PHP_EOL;
$body .= ' if (null === $' . $defaultValueParameter->getName() . ') {' . PHP_EOL;
$body .= ' throw new \RuntimeException(\'Parameter "\' .$' . $propertyNameParameter->getName() .
'. \'" is required but not defined and no default value provided!\');' . PHP_EOL;
$body .= ' }' . PHP_EOL;
$body .= ' throw new \RuntimeException(\'Parameter "\' .$' . $propertyNameParameter->getName() .
'. \'" not defined!\');' . PHP_EOL;
$body .= '}' . PHP_EOL . PHP_EOL;
$body .= 'return $value;' . PHP_EOL;
$this->setParameter($propertyNameParameter);
$this->setParameter($requiredParameter);
$this->setParameter($defaultValueParameter);
$this->setVisibility(self::VISIBILITY_PROTECTED);
$this->setBody($body);
}
}
| php | Apache-2.0 | bfccc82a4757930e4ec1259fe87c3124888e327c | 2026-01-05T04:45:28.508624Z | false |
bitExpert/disco | https://github.com/bitExpert/disco/blob/bfccc82a4757930e4ec1259fe87c3124888e327c/src/bitExpert/Disco/Proxy/Configuration/MethodGenerator/GetAlias.php | src/bitExpert/Disco/Proxy/Configuration/MethodGenerator/GetAlias.php | <?php
/*
* This file is part of the Disco package.
*
* (c) bitExpert AG
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace bitExpert\Disco\Proxy\Configuration\MethodGenerator;
use bitExpert\Disco\BeanNotFoundException;
use bitExpert\Disco\Proxy\Configuration\PropertyGenerator\AliasesProperty;
use ProxyManager\Generator\MethodGenerator;
use ReflectionClass;
use Laminas\Code\Generator\Exception\InvalidArgumentException;
use Laminas\Code\Generator\ParameterGenerator;
/**
* `getAlias` method for the generated config proxy class.
*/
class GetAlias extends MethodGenerator
{
/**
* Creates a new {@link \bitExpert\Disco\Proxy\Configuration\MethodGenerator\GetAlias}.
*
* @param AliasesProperty $aliasesProperty
* @throws InvalidArgumentException
*/
public function __construct(AliasesProperty $aliasesProperty)
{
parent::__construct('getAlias');
$aliasParameter = new ParameterGenerator('alias');
$aliasParameter->setType('string');
$body = 'if ($this->hasAlias($' . $aliasParameter->getName() . ')) {' . PHP_EOL;
$body .= ' $methodname = $this->' . $aliasesProperty->getName() . '[$' . $aliasParameter->getName() . '];' .
PHP_EOL;
$body .= ' return $this->$methodname();' . PHP_EOL;
$body .= '}' . PHP_EOL . PHP_EOL;
$body .= 'throw new ' . BeanNotFoundException::class . '(sprintf(\'Alias "%s" is not defined!\', $' .
$aliasParameter->getName() . '));' . PHP_EOL;
$this->setParameter($aliasParameter);
$this->setVisibility(self::VISIBILITY_PUBLIC);
$this->setBody($body);
}
}
| php | Apache-2.0 | bfccc82a4757930e4ec1259fe87c3124888e327c | 2026-01-05T04:45:28.508624Z | false |
bitExpert/disco | https://github.com/bitExpert/disco/blob/bfccc82a4757930e4ec1259fe87c3124888e327c/src/bitExpert/Disco/Proxy/Configuration/MethodGenerator/HasAlias.php | src/bitExpert/Disco/Proxy/Configuration/MethodGenerator/HasAlias.php | <?php
/*
* This file is part of the Disco package.
*
* (c) bitExpert AG
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace bitExpert\Disco\Proxy\Configuration\MethodGenerator;
use bitExpert\Disco\Proxy\Configuration\PropertyGenerator\AliasesProperty;
use ProxyManager\Generator\MethodGenerator;
use ReflectionClass;
use Laminas\Code\Generator\Exception\InvalidArgumentException;
use Laminas\Code\Generator\ParameterGenerator;
/**
* `hasAlias` method for the generated config proxy class.
*/
class HasAlias extends MethodGenerator
{
/**
* Creates a new {@link \bitExpert\Disco\Proxy\Configuration\MethodGenerator\HasAlias}.
*
* @param AliasesProperty $aliasesProperty
* @throws InvalidArgumentException
*/
public function __construct(AliasesProperty $aliasesProperty)
{
parent::__construct('hasAlias');
$aliasParameter = new ParameterGenerator('alias');
$aliasParameter->setType('string');
$this->setParameter($aliasParameter);
$this->setVisibility(self::VISIBILITY_PUBLIC);
$this->setReturnType('bool');
$this->setBody(
'return !empty($' . $aliasParameter->getName() . ') && ' .
'isset($this->' . $aliasesProperty->getName() . '[$' . $aliasParameter->getName() . ']);'
);
}
}
| php | Apache-2.0 | bfccc82a4757930e4ec1259fe87c3124888e327c | 2026-01-05T04:45:28.508624Z | false |
bitExpert/disco | https://github.com/bitExpert/disco/blob/bfccc82a4757930e4ec1259fe87c3124888e327c/src/bitExpert/Disco/Proxy/Configuration/MethodGenerator/BeanPostProcessorMethod.php | src/bitExpert/Disco/Proxy/Configuration/MethodGenerator/BeanPostProcessorMethod.php | <?php
/*
* This file is part of the Disco package.
*
* (c) bitExpert AG
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace bitExpert\Disco\Proxy\Configuration\MethodGenerator;
use bitExpert\Disco\Annotations\BeanPostProcessor;
use Laminas\Code\Generator\MethodGenerator;
use Laminas\Code\Reflection\MethodReflection;
class BeanPostProcessorMethod extends ParameterAwareMethodGenerator
{
/**
* Creates a new {@link \bitExpert\Disco\Proxy\Configuration\MethodGenerator\BeanPostProcessorMethod}.
*
* @param MethodReflection $originalMethod
* @param BeanPostProcessor $beanPostProcessorMetadata
* @param GetParameter $parameterValuesMethod
* @return MethodGenerator
* @throws \Laminas\Code\Generator\Exception\InvalidArgumentException
*/
public static function generateMethod(
MethodReflection $originalMethod,
BeanPostProcessor $beanPostProcessorMetadata,
GetParameter $parameterValuesMethod
): MethodGenerator {
$method = static::fromReflection($originalMethod);
$methodParams = static::convertMethodParamsToString(
$beanPostProcessorMetadata->getParameters(),
$parameterValuesMethod
);
$beanId = $originalMethod->name;
$body = 'return parent::' . $beanId . '(' . $methodParams . ');' . PHP_EOL;
$method->setBody($body);
$method->setDocBlock('{@inheritDoc}');
return $method;
}
}
| php | Apache-2.0 | bfccc82a4757930e4ec1259fe87c3124888e327c | 2026-01-05T04:45:28.508624Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.