-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 48feb34
Showing
11 changed files
with
313 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/vendor/ | ||
*.cache | ||
composer.lock | ||
phpunit.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
$header = <<<EOF | ||
AJGL Breakpoint Twig Extension Component | ||
Copyright (C) Antonio J. García Lagar <[email protected]> | ||
For the full copyright and license information, please view the LICENSE | ||
file that was distributed with this source code. | ||
EOF; | ||
|
||
Symfony\CS\Fixer\Contrib\HeaderCommentFixer::setHeader($header); | ||
|
||
return Symfony\CS\Config\Config::create() | ||
->setUsingCache(true) | ||
// use default SYMFONY_LEVEL and extra fixers: | ||
->fixers(array( | ||
'-psr0', | ||
'header_comment', | ||
'newline_after_open_tag', | ||
'ordered_use', | ||
'phpdoc_order', | ||
'strict', | ||
'strict_param', | ||
)) | ||
->finder( | ||
Symfony\CS\Finder\DefaultFinder::create() | ||
->in(__DIR__.'/src') | ||
->in(__DIR__.'/tests') | ||
) | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# .scrutinizer.yml | ||
checks: | ||
php: true | ||
|
||
tools: | ||
external_code_coverage: | ||
timeout: 900 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
language: php | ||
|
||
matrix: | ||
fast_finish: true | ||
include: | ||
- php: 5.4 | ||
env: COMPOSER_FLAGS="--prefer-lowest" | ||
- php: 5.4 | ||
- php: 5.5 | ||
- php: 5.6 | ||
- php: 7 | ||
- php: hhvm | ||
|
||
before_script: | ||
- composer update --prefer-dist --no-interaction $COMPOSER_FLAGS | ||
script: phpunit --coverage-clover=coverage.clover | ||
after_script: | ||
- wget https://scrutinizer-ci.com/ocular.phar | ||
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# [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] | ||
|
||
### Added | ||
- Add `breakpoint` function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Copyright (c) 2013-2016 Antonio J. García Lagar <[email protected]> | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
AjglBreakpointTwigExtension | ||
=========================== | ||
|
||
The AjglBreakpointTwigExtension component allows you set breakpoints in twig templates. | ||
|
||
[](https://travis-ci.org/ajgarlag/AjglBreakpointTwigExtension) | ||
[](https://packagist.org/packages/ajgl/breakpoint-twig-extension) | ||
[](https://packagist.org/packages/ajgl/breakpoint-twig-extension) | ||
[](https://packagist.org/packages/ajgl/breakpoint-twig-extension) | ||
[](https://packagist.org/packages/ajgl/breakpoint-twig-extension) | ||
[](https://packagist.org/packages/ajgl/breakpoint-twig-extension) | ||
[](https://packagist.org/packages/ajgl/breakpoint-twig-extension) | ||
[](https://scrutinizer-ci.com/g/ajgarlag/AjglBreakpointTwigExtension/?branch=master) | ||
[](https://scrutinizer-ci.com/g/ajgarlag/AjglBreakpointTwigExtension/?branch=master) | ||
[](https://insight.sensiolabs.com/projects/e0f1276d-6ded-4a20-9b3f-1a7c77a92015) | ||
[](https://styleci.io/repos/53512207) | ||
|
||
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\Breakpoint()); | ||
``` | ||
|
||
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> | ||
``` | ||
|
||
|
||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"name": "ajgl/breakpoint-twig-extension", | ||
"description": "Twig extension to set breakpoints", | ||
"keywords": ["twig", "xdebug", "breakpoint"], | ||
"homepage": "https://github.com/ajgl/AjglTwigBreakpointExtension", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Antonio J. García Lagar", | ||
"email": "[email protected]", | ||
"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.4.0", | ||
"twig/twig": "^1.14" | ||
}, | ||
"suggest": { | ||
"ext-xdebug": "The Xdebug extension is required for the breakpoint to work" | ||
}, | ||
"extra": { | ||
"branch-alias": { | ||
"dev-master": "0.1.x-dev" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
/* | ||
* AJGL Breakpoint Twig Extension Component | ||
* | ||
* Copyright (C) Antonio J. García Lagar <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Ajgl\Twig\Extension; | ||
|
||
/** | ||
* @author Antonio J. García Lagar <[email protected]> | ||
*/ | ||
class BreakpointExtension extends \Twig_Extension | ||
{ | ||
public function getName() | ||
{ | ||
return 'breakpoint'; | ||
} | ||
|
||
public function getFunctions() | ||
{ | ||
return array( | ||
new \Twig_SimpleFunction('breakpoint', array($this, 'setBreakpoint')), | ||
); | ||
} | ||
|
||
/** | ||
* If XDebug is detected, makes the debugger break. | ||
*/ | ||
public function setBreakpoint() | ||
{ | ||
if (function_exists('xdebug_break')) { | ||
xdebug_break(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
/* | ||
* AJGL Breakpoint Twig Extension Component | ||
* | ||
* Copyright (C) Antonio J. García Lagar <[email protected]> | ||
* | ||
* 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; | ||
|
||
/** | ||
* @author Antonio J. García Lagar <[email protected]> | ||
*/ | ||
class BreakpointExtensionTest extends \PHPUnit_Framework_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]); | ||
} | ||
} |