Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade End Func #177 #178

Merged
merged 1 commit into from
Nov 30, 2017
Merged

Upgrade End Func #177 #178

merged 1 commit into from
Nov 30, 2017

Conversation

ragboyjr
Copy link
Contributor

  • Updated the end func to multi-purpose and
    just simply end the output buffering
  • Updated the start func to utilize the
    new end func and perform the start section
    semantics

Signed-off-by: RJ Garcia [email protected]

- Updated the end func to multi-purpose and
  just simply end the output buffering
- Updated the start func to utilize the
  new end func and perform the start section
  semantics

Signed-off-by: RJ Garcia <[email protected]>
@@ -28,43 +28,51 @@ function sectionFunc() {

/** Starts the output buffering for a section, update of 0 = replace, 1 = append, 2 = prepend */
function startFunc($update = START_REPLACE) {
return function(FuncArgs $args) use ($update) {
$section_def = $args->template->getContextItem('_section_def') ?: [];
return startBufferFunc(function(FuncArgs $args) use ($update) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected 1 space after FUNCTION keyword; 0 found

return function(FuncArgs $args) use ($update) {
$section_def = $args->template->getContextItem('_section_def') ?: [];
return startBufferFunc(function(FuncArgs $args) use ($update) {
return function($contents) use ($update, $args) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected 1 space after FUNCTION keyword; 0 found


ob_start();
$section_def[] = [$args->args[0], $update, ob_get_level()];
function startBufferFunc(callable $create_callback) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opening brace should be on a new line

ob_start();
$section_def[] = [$args->args[0], $update, ob_get_level()];
function startBufferFunc(callable $create_callback) {
return function(FuncArgs $args) use ($create_callback) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected 1 space after FUNCTION keyword; 0 found

@@ -1,45 +1,132 @@
<?php

use League\Plates\{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There must be one USE keyword per declaration

Exception\FuncException
};

use function Eloquent\Phony\{on, mock};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • There must be one USE keyword per declaration
  • Closing brace must be on a line by itself

};

use function Eloquent\Phony\{on, mock};
use function League\Plates\{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There must be one USE keyword per declaration

Template\getSections,
Util\stack
};
use function League\Plates\RenderContext\{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There must be one USE keyword per declaration

startBufferFunc,
endFunc
};
use const League\Plates\RenderContext\{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There must be one USE keyword per declaration

});
xdescribe('platesFunc', function() {
it('creates the default plates func stack');
describe('Funcs', function() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected 1 space after FUNCTION keyword; 0 found

xdescribe('platesFunc', function() {
it('creates the default plates func stack');
describe('Funcs', function() {
beforeEach(function() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected 1 space after FUNCTION keyword; 0 found

$this->template = new Template('');
$this->args = new FuncArgs($this->render, $this->template, '', []);
});
describe('layoutFunc', function() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected 1 space after FUNCTION keyword; 0 found

describe('layoutFunc', function() {
it('forks a template and sets the layout');
});
xdescribe('sectionFunc', function() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected 1 space after FUNCTION keyword; 0 found

xdescribe('sectionFunc', function() {
it('gets a section from the template sections');
});
describe('startFunc', function() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected 1 space after FUNCTION keyword; 0 found

it('gets a section from the template sections');
});
describe('startFunc', function() {
$create_test = function($update_text, $update, $expected) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected 1 space after FUNCTION keyword; 0 found

});
describe('startFunc', function() {
$create_test = function($update_text, $update, $expected) {
it("can start buffering and {$update_text} the section", function() use ($update, $expected) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected 1 space after FUNCTION keyword; 0 found

$create_test('append', START_APPEND, 'bazbar');
$create_test('prepend', START_PREPEND, 'barbaz');
});
describe('startBufferFunc', function() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected 1 space after FUNCTION keyword; 0 found

$create_test('prepend', START_PREPEND, 'barbaz');
});
describe('startBufferFunc', function() {
it('starts the output buffering and appends the buffer_stack', function() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected 1 space after FUNCTION keyword; 0 found

describe('startBufferFunc', function() {
it('starts the output buffering and appends the buffer_stack', function() {
$args = $this->args;
$callback = function() {};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Expected 1 space after FUNCTION keyword; 0 found
  • Closing brace must be on a line by itself

$callback = function() {};

$cur_level = ob_get_level();
startBufferFunc(function($passed_args) use ($args, $callback) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected 1 space after FUNCTION keyword; 0 found

ob_end_clean();
});
});
describe('endFunc', function() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected 1 space after FUNCTION keyword; 0 found

});
});
describe('endFunc', function() {
it('throws an exception if no buffer_stack have been defined', function() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected 1 space after FUNCTION keyword; 0 found

describe('endFunc', function() {
it('throws an exception if no buffer_stack have been defined', function() {
$func = endFunc();
expect(function() use ($func) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected 1 space after FUNCTION keyword; 0 found

$func($this->args);
})->throw(FuncException::class, 'Cannot end a section definition because no section has been started.');
});
it('throws an exception if the output buffering level does not match the section def', function() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected 1 space after FUNCTION keyword; 0 found

});
it('throws an exception if the output buffering level does not match the section def', function() {

startBufferFunc(function() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected 1 space after FUNCTION keyword; 0 found

it('throws an exception if the output buffering level does not match the section def', function() {

startBufferFunc(function() {
return function() {};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Expected 1 space after FUNCTION keyword; 0 found
  • Closing brace must be on a line by itself

ob_end_clean();

$func = endFunc();
expect(function() use ($func) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected 1 space after FUNCTION keyword; 0 found

$func($this->args);
})->throw(FuncException::class, 'Output buffering level does not match when section was started.');
});
it('cleans the buffer and calls the callback', function() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected 1 space after FUNCTION keyword; 0 found

});
it('cleans the buffer and calls the callback', function() {
$was_called = false;
startBufferFunc(function() use (&$was_called) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected 1 space after FUNCTION keyword; 0 found

it('cleans the buffer and calls the callback', function() {
$was_called = false;
startBufferFunc(function() use (&$was_called) {
return function() use (&$was_called) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected 1 space after FUNCTION keyword; 0 found

expect($this->args->template->context['buffer_stack'])->length(0);
});
});
xdescribe('insertFunc', function() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected 1 space after FUNCTION keyword; 0 found

xdescribe('insertFunc', function() {
it('forks a template and echos the rendered contents');
});
xdescribe('escapeFunc', function() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected 1 space after FUNCTION keyword; 0 found

xdescribe('escapeFunc', function() {
it('it escapes the content with htmlspecialchars');
});
xdescribe('assertArgsFunc', function() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected 1 space after FUNCTION keyword; 0 found

it('passes through if there are enough args');
it('appends null to the args to make up the amount of required and defaulted args');
});
xdescribe('aliasNameFunc', function() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected 1 space after FUNCTION keyword; 0 found

it('passes through if no aliases are matched');
it('recursively aliases func names');
});
xdescribe('splitByNameFunc', function() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected 1 space after FUNCTION keyword; 0 found

it('allows stacks to be invoked by func name');
it('passes through if no stack was registered per func name');
});
xdescribe('platesFunc', function() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected 1 space after FUNCTION keyword; 0 found

@ragboyjr ragboyjr merged commit 5996618 into v4.0-dev Nov 30, 2017
@ragboyjr ragboyjr deleted the 177-upgrade-end-func branch November 30, 2017 04:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants