Initial commit: apps.prometeysev.ru

This commit is contained in:
root committed 2026-10-22 00:22:57 +03:00
commit 96ccabcd8b
6561 files changed
+1270349

No files matched your search

@@ -0,0 +1,4 @@
/vendor/
*.cache
composer.lock
phpunit.xml
+36
View File
@@ -0,0 +1,36 @@
<?php
$header = <<<EOF
AJGL Breakpoint Twig Extension Component
Copyright (C) Antonio J. García Lagar <aj@garcialagar.es>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
EOF;
return \PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules(
[
'@Symfony' => true,
'@Symfony:risky' => true,
'array_syntax' => array('syntax' => 'short'),
'fully_qualified_strict_types' => true,
'header_comment' => array('header' => $header),
'native_function_invocation' => false,
'ordered_imports' => [
'imports_order' => ['class', 'const', 'function'],
],
'phpdoc_order' => true,
'psr4' => true,
'strict_comparison' => true,
'strict_param' => true,
]
)
->setFinder(
\PhpCsFixer\Finder::create()
->in(__DIR__.'/src')
->in(__DIR__.'/tests')
)
;
@@ -0,0 +1,7 @@
# .scrutinizer.yml
checks:
php: true
tools:
external_code_coverage:
timeout: 900
+68
View File
@@ -0,0 +1,68 @@
language: php
sudo: false
cache:
directories:
- $HOME/.composer/cache/files
- $HOME/symfony-bridge/.phpunit
env:
global:
- PHPUNIT_FLAGS="-v"
- SYMFONY_PHPUNIT_DIR="$HOME/symfony-bridge/.phpunit"
matrix:
fast_finish: true
include:
# Minimum supported dependencies with the latest and oldest PHP version
- php: 7.3
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="weak_vendors"
- php: 5.6
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="weak_vendors"
# Test the latest stable release
- php: 5.6
- php: 7.0
- php: 7.1
- php: 7.2
- php: 7.3
env: COVERAGE=true PHPUNIT_FLAGS="-v --coverage-text" LINT=true
# Test LTS versions. This makes sure we do not use Symfony packages with version greater
# than 2 or 3 respectively. Read more at https://github.com/symfony/lts
- php: 7.3
env: DEPENDENCIES="symfony/lts:^2"
- php: 7.3
env: DEPENDENCIES="symfony/lts:^3"
# Latest commit to master
- php: 7.3
env: STABILITY="dev"
- php: 7.4
env: STABILITY="dev"
- php: nightly
env: STABILITY="dev"
allow_failures:
# Dev-master is allowed to fail.
- env: STABILITY="dev"
before_install:
- if [[ $COVERAGE != true ]]; then phpenv config-rm xdebug.ini || true; fi
- if ! [ -z "$STABILITY" ]; then composer config minimum-stability ${STABILITY}; fi;
- if ! [ -v "$DEPENDENCIES" ]; then composer require --no-update ${DEPENDENCIES}; fi;
- if [[ $LINT = true ]]; then wget https://cs.symfony.com/download/php-cs-fixer-v2.phar; fi
install:
- composer update ${COMPOSER_FLAGS} --prefer-dist --no-interaction
- ./vendor/bin/simple-phpunit install
script:
- composer validate --strict --no-check-lock
- if [[ $LINT = true ]]; then php php-cs-fixer-v2.phar fix --dry-run --diff --no-ansi; fi
# simple-phpunit is the PHPUnit wrapper provided by the PHPUnit Bridge component and
# it helps with testing legacy code and deprecations (composer require symfony/phpunit-bridge)
- ./vendor/bin/simple-phpunit $PHPUNIT_FLAGS
after_script:
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover
+60
View File
@@ -0,0 +1,60 @@
# [CHANGELOG](http://keepachangelog.com/)
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased][unreleased]
## [0.3.4] - 2019-04-10
### Fixed
- Population of `$arguments` variable
## [0.3.3] - 2019-03-18
### Fixed
- Population of `$arguments` variable
- Usage of deprecated classes
## [0.3.2] - 2018-12-10
### Added
- Add support for Symfony 4
## [0.3.1] - 2017-11-20
### Changed
- Require PHP 5.6
### Fixed
- Update requirements to allow twig 2.x
## [0.3.0] - 2016-03-31
### Added
- Add `$environment` and `$context` variables
- Allow to inspect function arguments
## [0.2.0] - 2016-03-10
### Added
- Add Symfony Bundle
## 0.1.0 - 2016-03-09
### Added
- Add `breakpoint` function
[unreleased]: https://github.com/ajgarlag/AjglBreakpointTwigExtension/compare/0.3.4...master
[0.3.4]: https://github.com/ajgarlag/AjglBreakpointTwigExtension/compare/0.3.3...0.3.4
[0.3.3]: https://github.com/ajgarlag/AjglBreakpointTwigExtension/compare/0.3.2...0.3.3
[0.3.2]: https://github.com/ajgarlag/AjglBreakpointTwigExtension/compare/0.3.1...0.3.2
[0.3.1]: https://github.com/ajgarlag/AjglBreakpointTwigExtension/compare/0.3.0...0.3.1
[0.3.0]: https://github.com/ajgarlag/AjglBreakpointTwigExtension/compare/0.2.0...0.3.0
[0.2.0]: https://github.com/ajgarlag/AjglBreakpointTwigExtension/compare/0.1.0...0.2.0
+23
View File
@@ -0,0 +1,23 @@
Copyright (c) 2013-2016 Antonio J. García Lagar <aj@garcialagar.es>
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the
Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions of
the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+124
View File
@@ -0,0 +1,124 @@
AjglBreakpointTwigExtension
===========================
The AjglBreakpointTwigExtension component allows you set breakpoints in twig templates.
[![Build Status](https://travis-ci.org/ajgarlag/AjglBreakpointTwigExtension.png?branch=master)](https://travis-ci.org/ajgarlag/AjglBreakpointTwigExtension)
[![Latest Stable Version](https://poser.pugx.org/ajgl/breakpoint-twig-extension/v/stable.png)](https://packagist.org/packages/ajgl/breakpoint-twig-extension)
[![Latest Unstable Version](https://poser.pugx.org/ajgl/breakpoint-twig-extension/v/unstable.png)](https://packagist.org/packages/ajgl/breakpoint-twig-extension)
[![Total Downloads](https://poser.pugx.org/ajgl/breakpoint-twig-extension/downloads.png)](https://packagist.org/packages/ajgl/breakpoint-twig-extension)
[![Montly Downloads](https://poser.pugx.org/ajgl/breakpoint-twig-extension/d/monthly.png)](https://packagist.org/packages/ajgl/breakpoint-twig-extension)
[![Daily Downloads](https://poser.pugx.org/ajgl/breakpoint-twig-extension/d/daily.png)](https://packagist.org/packages/ajgl/breakpoint-twig-extension)
[![License](https://poser.pugx.org/ajgl/breakpoint-twig-extension/license.png)](https://packagist.org/packages/ajgl/breakpoint-twig-extension)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/ajgarlag/AjglBreakpointTwigExtension/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/ajgarlag/AjglBreakpointTwigExtension/?branch=master)
[![Code Coverage](https://scrutinizer-ci.com/g/ajgarlag/AjglBreakpointTwigExtension/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/ajgarlag/AjglBreakpointTwigExtension/?branch=master)
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/e0f1276d-6ded-4a20-9b3f-1a7c77a92015/mini.png)](https://insight.sensiolabs.com/projects/e0f1276d-6ded-4a20-9b3f-1a7c77a92015)
This component requires the [Xdebug] PHP extension to be installed.
Installation
------------
To install the latest stable version of this component, open a console and execute the following command:
```
$ composer require ajgl/breakpoint-twig-extension
```
Usage
-----
The first step is to register the extension into the twig environment
```php
/* @var $twig Twig_Environment */
$twig->addExtension(new Ajgl\Twig\Extension\BreakpointExtension());
```
Once registered, you can call the new `breakpoint` function:
```twig
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>title</title>
</head>
<body>
{{ breakpoint() }}
</body>
</html>
```
Once stopped, your debugger will allow you to inspect the `$environment` and `$context` variables.
### Function arguments
Any argument passed to the twig function will be added to the `$arguments` array, so you can inspect it easily.
```twig
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>title</title>
</head>
<body>
{{ breakpoint(app.user, app.session) }}
</body>
</html>
```
Symfony Bundle
--------------
If you want to use this extension in your Symfony application, you can enable the
Symfony Bundle included in this package.
The bundle will register the twig extension automatically. So, once enabled, you
can insert the `breakpoint` twig function in your templates.
### Symfony 2/3
```php
// app/AppKernel.php
if (in_array($this->getEnvironment(), array('dev', 'test'), true)) {
$bundles[] = new Ajgl\Twig\Extension\SymfonyBundle\AjglBreakpointTwigExtensionBundle();
}
```
### Symfony 4
```php
// config/bundles.php
//...
return [
//...
Ajgl\Twig\Extension\SymfonyBundle\AjglBreakpointTwigExtensionBundle::class => ['dev' => true]
];
```
License
-------
This component is under the MIT license. See the complete license in the [LICENSE] file.
Reporting an issue or a feature request
---------------------------------------
Issues and feature requests are tracked in the [Github issue tracker].
Author Information
------------------
Developed with ♥ by [Antonio J. García Lagar].
If you find this component useful, please add a ★ in the [GitHub repository page] and/or the [Packagist package page].
[Xdebug]: https://xdebug.org/
[LICENSE]: LICENSE
[Github issue tracker]: https://github.com/ajgarlag/AjglBreakpointTwigExtension/issues
[Antonio J. García Lagar]: http://aj.garcialagar.es
[GitHub repository page]: https://github.com/ajgarlag/AjglBreakpointTwigExtension
[Packagist package page]: https://packagist.org/packages/ajgl/breakpoint-twig-extension
+46
View File
@@ -0,0 +1,46 @@
{
"name": "ajgl/breakpoint-twig-extension",
"description": "Twig extension to set breakpoints",
"keywords": ["twig", "xdebug", "breakpoint"],
"homepage": "https://github.com/ajgarlag/AjglBreakpointTwigExtension",
"license": "MIT",
"authors": [
{
"name": "Antonio J. García Lagar",
"email": "aj@garcialagar.es",
"homepage": "http://aj.garcialagar.es",
"role": "developer"
}
],
"autoload": {
"psr-4": { "Ajgl\\Twig\\Extension\\": "src/" }
},
"autoload-dev": {
"psr-4": { "Ajgl\\Twig\\Extension\\Tests\\": "tests/" }
},
"require": {
"php": ">=5.6",
"twig/twig": "^1.14|^2.0"
},
"require-dev": {
"symfony/framework-bundle": "^2.7|^3.2|^4.1",
"symfony/twig-bundle": "^2.7|^3.2|^4.1",
"symfony/phpunit-bridge": "^3.4|^4.1"
},
"suggest": {
"ext-xdebug": "The Xdebug extension is required for the breakpoint to work",
"symfony/framework-bundle": "The framework bundle to integrate the extension into Symfony",
"symfony/twig-bundle": "The twig bundle to integrate the extension into Symfony"
},
"scripts": {
"phpunit": "vendor/bin/simple-phpunit --colors=always",
"test": [
"@phpunit"
]
},
"extra": {
"branch-alias": {
"dev-master": "0.3.x-dev"
}
}
}
+22
View File
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.0/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php"
>
<testsuites>
<testsuite name="AjglBreakpointTwigExtension Test Suite">
<directory>./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>./src</directory>
</whitelist>
</filter>
</phpunit>
@@ -0,0 +1,49 @@
<?php
/*
* AJGL Breakpoint Twig Extension Component
*
* Copyright (C) Antonio J. García Lagar <aj@garcialagar.es>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Ajgl\Twig\Extension;
use Twig\Environment;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
/**
* @author Antonio J. García Lagar <aj@garcialagar.es>
*/
class BreakpointExtension extends AbstractExtension
{
public function getName()
{
return 'breakpoint';
}
public function getFunctions()
{
return [
new TwigFunction('breakpoint', [$this, 'setBreakpoint'], ['needs_environment' => true, 'needs_context' => true]),
];
}
/**
* If Xdebug is detected, makes the debugger break.
*
* @param Environment $environment the environment instance
* @param mixed $context variables from the Twig template
*/
public function setBreakpoint(Environment $environment, $context)
{
if (function_exists('xdebug_break')) {
$arguments = func_get_args();
$arguments = array_slice($arguments, 2);
xdebug_break();
}
}
}
@@ -0,0 +1,21 @@
<?php
/*
* AJGL Breakpoint Twig Extension Component
*
* Copyright (C) Antonio J. García Lagar <aj@garcialagar.es>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Ajgl\Twig\Extension\SymfonyBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
/**
* @author Antonio J. García Lagar <aj@garcialagar.es>
*/
class AjglBreakpointTwigExtensionBundle extends Bundle
{
}
@@ -0,0 +1,29 @@
<?php
/*
* AJGL Breakpoint Twig Extension Component
*
* Copyright (C) Antonio J. García Lagar <aj@garcialagar.es>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Ajgl\Twig\Extension\SymfonyBundle\DependencyInjection;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
/**
* @author Antonio J. García Lagar <aj@garcialagar.es>
*/
class AjglBreakpointTwigExtensionExtension extends Extension
{
public function load(array $config, ContainerBuilder $container)
{
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('twig.xml');
}
}
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="ajgl_twig_extension.breakpoint" class="Ajgl\Twig\Extension\BreakpointExtension" public="false">
<tag name="twig.extension"/>
</service>
</services>
</container>
@@ -0,0 +1,49 @@
<?php
/*
* AJGL Breakpoint Twig Extension Component
*
* Copyright (C) Antonio J. García Lagar <aj@garcialagar.es>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Ajgl\Twig\Extension\Tests;
use Ajgl\Twig\Extension\BreakpointExtension;
use PHPUnit\Framework\TestCase;
/**
* @author Antonio J. García Lagar <aj@garcialagar.es>
*/
class BreakpointExtensionTest extends TestCase
{
/**
* @var BreakpointExtension
*/
protected $extension;
protected function setUp()
{
$this->extension = new BreakpointExtension();
}
public function testGetName()
{
$this->assertSame('breakpoint', $this->extension->getName());
}
public function testGetFunctions()
{
$functions = $this->extension->getFunctions();
$this->assertCount(1, $functions);
$function = reset($functions);
$this->assertInstanceOf('Twig_SimpleFunction', $function);
$callable = $function->getCallable();
$this->assertTrue(is_array($callable));
$this->assertCount(2, $callable);
$this->assertSame($this->extension, $callable[0]);
$this->assertSame('setBreakpoint', $callable[1]);
}
}
@@ -0,0 +1,50 @@
<?php
/*
* AJGL Breakpoint Twig Extension Component
*
* Copyright (C) Antonio J. García Lagar <aj@garcialagar.es>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Ajgl\Twig\Extension\Tests\SymfonyBundle\DependencyInjection;
use Ajgl\Twig\Extension\SymfonyBundle\DependencyInjection\AjglBreakpointTwigExtensionExtension;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;
/**
* @author Antonio J. García Lagar <aj@garcialagar.es>
*/
class AjglBreakpointTwigExtensionExtensionTest extends TestCase
{
/**
* @var ContainerBuilder
*/
protected $container;
/**
* @var AjglBreakpointTwigExtensionExtension
*/
protected $extension;
protected function setUp()
{
$this->container = new ContainerBuilder();
$this->extension = new AjglBreakpointTwigExtensionExtension();
}
public function testTwigExtensionsDefinition()
{
$this->extension->load([], $this->container);
$this->assertTrue($this->container->hasDefinition('ajgl_twig_extension.breakpoint'));
$definition = $this->container->getDefinition('ajgl_twig_extension.breakpoint');
$this->assertSame(
'Ajgl\Twig\Extension\BreakpointExtension',
$definition->getClass()
);
$this->assertNotNull($definition->getTag('twig.extension'));
}
}