code
stringlengths 31
1.39M
| docstring
stringlengths 23
16.8k
| func_name
stringlengths 1
126
| language
stringclasses 1
value | repo
stringlengths 7
63
| path
stringlengths 7
166
| url
stringlengths 50
220
| license
stringclasses 7
values |
---|---|---|---|---|---|---|---|
public function create(User $user): bool
{
return $user->can('create_leave::type');
}
|
Determine whether the user can create models.
|
create
|
php
|
aureuserp/aureuserp
|
plugins/webkul/time-off/src/Policies/LeaveTypePolicy.php
|
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/time-off/src/Policies/LeaveTypePolicy.php
|
MIT
|
public function update(User $user, LeaveType $leaveType): bool
{
return $user->can('update_leave::type');
}
|
Determine whether the user can update the model.
|
update
|
php
|
aureuserp/aureuserp
|
plugins/webkul/time-off/src/Policies/LeaveTypePolicy.php
|
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/time-off/src/Policies/LeaveTypePolicy.php
|
MIT
|
public function delete(User $user, LeaveType $leaveType): bool
{
return $user->can('delete_leave::type');
}
|
Determine whether the user can delete the model.
|
delete
|
php
|
aureuserp/aureuserp
|
plugins/webkul/time-off/src/Policies/LeaveTypePolicy.php
|
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/time-off/src/Policies/LeaveTypePolicy.php
|
MIT
|
public function deleteAny(User $user): bool
{
return $user->can('delete_any_leave::type');
}
|
Determine whether the user can bulk delete.
|
deleteAny
|
php
|
aureuserp/aureuserp
|
plugins/webkul/time-off/src/Policies/LeaveTypePolicy.php
|
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/time-off/src/Policies/LeaveTypePolicy.php
|
MIT
|
public function forceDelete(User $user, LeaveType $leaveType): bool
{
return $user->can('force_delete_leave::type');
}
|
Determine whether the user can permanently delete.
|
forceDelete
|
php
|
aureuserp/aureuserp
|
plugins/webkul/time-off/src/Policies/LeaveTypePolicy.php
|
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/time-off/src/Policies/LeaveTypePolicy.php
|
MIT
|
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_leave::type');
}
|
Determine whether the user can permanently bulk delete.
|
forceDeleteAny
|
php
|
aureuserp/aureuserp
|
plugins/webkul/time-off/src/Policies/LeaveTypePolicy.php
|
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/time-off/src/Policies/LeaveTypePolicy.php
|
MIT
|
public function restore(User $user, LeaveType $leaveType): bool
{
return $user->can('restore_leave::type');
}
|
Determine whether the user can restore.
|
restore
|
php
|
aureuserp/aureuserp
|
plugins/webkul/time-off/src/Policies/LeaveTypePolicy.php
|
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/time-off/src/Policies/LeaveTypePolicy.php
|
MIT
|
public function restoreAny(User $user): bool
{
return $user->can('restore_any_leave::type');
}
|
Determine whether the user can bulk restore.
|
restoreAny
|
php
|
aureuserp/aureuserp
|
plugins/webkul/time-off/src/Policies/LeaveTypePolicy.php
|
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/time-off/src/Policies/LeaveTypePolicy.php
|
MIT
|
public function replicate(User $user, LeaveType $leaveType): bool
{
return $user->can('replicate_leave::type');
}
|
Determine whether the user can replicate.
|
replicate
|
php
|
aureuserp/aureuserp
|
plugins/webkul/time-off/src/Policies/LeaveTypePolicy.php
|
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/time-off/src/Policies/LeaveTypePolicy.php
|
MIT
|
public function reorder(User $user): bool
{
return $user->can('reorder_leave::type');
}
|
Determine whether the user can reorder.
|
reorder
|
php
|
aureuserp/aureuserp
|
plugins/webkul/time-off/src/Policies/LeaveTypePolicy.php
|
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/time-off/src/Policies/LeaveTypePolicy.php
|
MIT
|
public function definition(): array
{
return [
];
}
|
Define the model's default state.
@return array<string, mixed>
|
definition
|
php
|
aureuserp/aureuserp
|
plugins/webkul/website/database/factories/PageFactory.php
|
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/website/database/factories/PageFactory.php
|
MIT
|
public function run($parameters = [])
{
$this->call([
WebsitePageSeeder::class,
]);
}
|
Seed the application's database.
@param array $parameters
@return void
|
run
|
php
|
aureuserp/aureuserp
|
plugins/webkul/website/database/seeders/DatabaseSeeder.php
|
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/website/database/seeders/DatabaseSeeder.php
|
MIT
|
protected function getForms(): array
{
return [
'form' => $this->form(
$this->makeForm()
->schema([
$this->getEmailFormComponent(),
$this->getPasswordFormComponent(),
$this->getRememberFormComponent(),
])
->statePath('data'),
),
];
}
|
@return array<int | string, string | Form>
|
getForms
|
php
|
aureuserp/aureuserp
|
plugins/webkul/website/src/Filament/Customer/Auth/Login.php
|
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/website/src/Filament/Customer/Auth/Login.php
|
MIT
|
protected function getCredentialsFromFormData(array $data): array
{
return [
'email' => $data['email'],
'password' => $data['password'],
];
}
|
@param array<string, mixed> $data
@return array<string, mixed>
|
getCredentialsFromFormData
|
php
|
aureuserp/aureuserp
|
plugins/webkul/website/src/Filament/Customer/Auth/Login.php
|
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/website/src/Filament/Customer/Auth/Login.php
|
MIT
|
protected function getForms(): array
{
return [
'form' => $this->form(
$this->makeForm()
->schema([
$this->getNameFormComponent(),
$this->getEmailFormComponent(),
$this->getPasswordFormComponent(),
$this->getPasswordConfirmationFormComponent(),
])
->statePath('data'),
),
];
}
|
@return array<int | string, string | Form>
|
getForms
|
php
|
aureuserp/aureuserp
|
plugins/webkul/website/src/Filament/Customer/Auth/Register.php
|
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/website/src/Filament/Customer/Auth/Register.php
|
MIT
|
protected function mutateFormDataBeforeRegister(array $data): array
{
return $data;
}
|
@param array<string, mixed> $data
@return array<string, mixed>
|
mutateFormDataBeforeRegister
|
php
|
aureuserp/aureuserp
|
plugins/webkul/website/src/Filament/Customer/Auth/Register.php
|
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/website/src/Filament/Customer/Auth/Register.php
|
MIT
|
protected function getForms(): array
{
return [
'form' => $this->form(
$this->makeForm()
->schema([
$this->getEmailFormComponent(),
])
->statePath('data'),
),
];
}
|
@return array<int | string, string | Form>
|
getForms
|
php
|
aureuserp/aureuserp
|
plugins/webkul/website/src/Filament/Customer/Auth/PasswordReset/RequestPasswordReset.php
|
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/website/src/Filament/Customer/Auth/PasswordReset/RequestPasswordReset.php
|
MIT
|
public function __construct(array $attributes = [])
{
$this->mergeFillable([
'password',
'is_active',
]);
$this->mergeCasts([
'email_verified_at' => 'datetime',
'password' => 'hashed',
]);
parent::__construct($attributes);
}
|
Create a new Eloquent model instance.
@return void
|
__construct
|
php
|
aureuserp/aureuserp
|
plugins/webkul/website/src/Models/Partner.php
|
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/website/src/Models/Partner.php
|
MIT
|
public function viewAny(User $user): bool
{
return $user->can('view_any_page');
}
|
Determine whether the user can view any models.
|
viewAny
|
php
|
aureuserp/aureuserp
|
plugins/webkul/website/src/Policies/PagePolicy.php
|
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/website/src/Policies/PagePolicy.php
|
MIT
|
public function view(User $user, Page $page): bool
{
return $user->can('view_page');
}
|
Determine whether the user can view the model.
|
view
|
php
|
aureuserp/aureuserp
|
plugins/webkul/website/src/Policies/PagePolicy.php
|
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/website/src/Policies/PagePolicy.php
|
MIT
|
public function create(User $user): bool
{
return $user->can('create_page');
}
|
Determine whether the user can create models.
|
create
|
php
|
aureuserp/aureuserp
|
plugins/webkul/website/src/Policies/PagePolicy.php
|
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/website/src/Policies/PagePolicy.php
|
MIT
|
public function update(User $user, Page $page): bool
{
return $user->can('update_page');
}
|
Determine whether the user can update the model.
|
update
|
php
|
aureuserp/aureuserp
|
plugins/webkul/website/src/Policies/PagePolicy.php
|
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/website/src/Policies/PagePolicy.php
|
MIT
|
public function delete(User $user, Page $page): bool
{
return $user->can('delete_page');
}
|
Determine whether the user can delete the model.
|
delete
|
php
|
aureuserp/aureuserp
|
plugins/webkul/website/src/Policies/PagePolicy.php
|
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/website/src/Policies/PagePolicy.php
|
MIT
|
public function deleteAny(User $user): bool
{
return $user->can('delete_any_page');
}
|
Determine whether the user can bulk delete.
|
deleteAny
|
php
|
aureuserp/aureuserp
|
plugins/webkul/website/src/Policies/PagePolicy.php
|
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/website/src/Policies/PagePolicy.php
|
MIT
|
public function forceDelete(User $user, Page $page): bool
{
return $user->can('force_delete_page');
}
|
Determine whether the user can permanently delete.
|
forceDelete
|
php
|
aureuserp/aureuserp
|
plugins/webkul/website/src/Policies/PagePolicy.php
|
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/website/src/Policies/PagePolicy.php
|
MIT
|
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_page');
}
|
Determine whether the user can permanently bulk delete.
|
forceDeleteAny
|
php
|
aureuserp/aureuserp
|
plugins/webkul/website/src/Policies/PagePolicy.php
|
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/website/src/Policies/PagePolicy.php
|
MIT
|
public function restore(User $user, Page $page): bool
{
return $user->can('restore_page');
}
|
Determine whether the user can restore.
|
restore
|
php
|
aureuserp/aureuserp
|
plugins/webkul/website/src/Policies/PagePolicy.php
|
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/website/src/Policies/PagePolicy.php
|
MIT
|
public function restoreAny(User $user): bool
{
return $user->can('restore_any_page');
}
|
Determine whether the user can bulk restore.
|
restoreAny
|
php
|
aureuserp/aureuserp
|
plugins/webkul/website/src/Policies/PagePolicy.php
|
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/website/src/Policies/PagePolicy.php
|
MIT
|
public function replicate(User $user, Page $page): bool
{
return $user->can('replicate_page');
}
|
Determine whether the user can replicate.
|
replicate
|
php
|
aureuserp/aureuserp
|
plugins/webkul/website/src/Policies/PagePolicy.php
|
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/website/src/Policies/PagePolicy.php
|
MIT
|
public function reorder(User $user): bool
{
return $user->can('reorder_page');
}
|
Determine whether the user can reorder.
|
reorder
|
php
|
aureuserp/aureuserp
|
plugins/webkul/website/src/Policies/PagePolicy.php
|
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/website/src/Policies/PagePolicy.php
|
MIT
|
public function viewAny(User $user): bool
{
return $user->can('view_any_partner');
}
|
Determine whether the user can view any models.
|
viewAny
|
php
|
aureuserp/aureuserp
|
plugins/webkul/website/src/Policies/PartnerPolicy.php
|
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/website/src/Policies/PartnerPolicy.php
|
MIT
|
public function view(User $user, Partner $partner): bool
{
return $user->can('view_partner');
}
|
Determine whether the user can view the model.
|
view
|
php
|
aureuserp/aureuserp
|
plugins/webkul/website/src/Policies/PartnerPolicy.php
|
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/website/src/Policies/PartnerPolicy.php
|
MIT
|
public function create(User $user): bool
{
return $user->can('create_partner');
}
|
Determine whether the user can create models.
|
create
|
php
|
aureuserp/aureuserp
|
plugins/webkul/website/src/Policies/PartnerPolicy.php
|
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/website/src/Policies/PartnerPolicy.php
|
MIT
|
public function update(User $user, Partner $partner): bool
{
return $user->can('update_partner');
}
|
Determine whether the user can update the model.
|
update
|
php
|
aureuserp/aureuserp
|
plugins/webkul/website/src/Policies/PartnerPolicy.php
|
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/website/src/Policies/PartnerPolicy.php
|
MIT
|
public function delete(User $user, Partner $partner): bool
{
return $user->can('delete_partner');
}
|
Determine whether the user can delete the model.
|
delete
|
php
|
aureuserp/aureuserp
|
plugins/webkul/website/src/Policies/PartnerPolicy.php
|
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/website/src/Policies/PartnerPolicy.php
|
MIT
|
public function deleteAny(User $user): bool
{
return $user->can('delete_any_partner');
}
|
Determine whether the user can bulk delete.
|
deleteAny
|
php
|
aureuserp/aureuserp
|
plugins/webkul/website/src/Policies/PartnerPolicy.php
|
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/website/src/Policies/PartnerPolicy.php
|
MIT
|
public function forceDelete(User $user, Partner $partner): bool
{
return $user->can('force_delete_partner');
}
|
Determine whether the user can permanently delete.
|
forceDelete
|
php
|
aureuserp/aureuserp
|
plugins/webkul/website/src/Policies/PartnerPolicy.php
|
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/website/src/Policies/PartnerPolicy.php
|
MIT
|
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_partner');
}
|
Determine whether the user can permanently bulk delete.
|
forceDeleteAny
|
php
|
aureuserp/aureuserp
|
plugins/webkul/website/src/Policies/PartnerPolicy.php
|
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/website/src/Policies/PartnerPolicy.php
|
MIT
|
public function restore(User $user, Partner $partner): bool
{
return $user->can('restore_partner');
}
|
Determine whether the user can restore.
|
restore
|
php
|
aureuserp/aureuserp
|
plugins/webkul/website/src/Policies/PartnerPolicy.php
|
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/website/src/Policies/PartnerPolicy.php
|
MIT
|
public function restoreAny(User $user): bool
{
return $user->can('restore_any_partner');
}
|
Determine whether the user can bulk restore.
|
restoreAny
|
php
|
aureuserp/aureuserp
|
plugins/webkul/website/src/Policies/PartnerPolicy.php
|
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/website/src/Policies/PartnerPolicy.php
|
MIT
|
public function replicate(User $user, Partner $partner): bool
{
return $user->can('replicate_partner');
}
|
Determine whether the user can replicate.
|
replicate
|
php
|
aureuserp/aureuserp
|
plugins/webkul/website/src/Policies/PartnerPolicy.php
|
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/website/src/Policies/PartnerPolicy.php
|
MIT
|
public function reorder(User $user): bool
{
return $user->can('reorder_partner');
}
|
Determine whether the user can reorder.
|
reorder
|
php
|
aureuserp/aureuserp
|
plugins/webkul/website/src/Policies/PartnerPolicy.php
|
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/website/src/Policies/PartnerPolicy.php
|
MIT
|
function connectDefaultInternals()
{
# call_user_func() etc. are not a problem if no other internal functions are redefined
if (Config\getRedefinableInternals() === []) {
return;
}
foreach (Config\getDefaultRedefinableInternals() as $function) {
# Which arguments are callbacks? Store their offsets in the following array.
$offsets = [];
foreach ((new \ReflectionFunction($function))->getParameters() as $offset => $argument) {
$name = $argument->getName();
if (strpos($name, 'call') !== false || strpos($name, 'func') !== false) {
$offsets[] = $offset;
}
}
connect($function, function() use ($function, $offsets) {
# This is the argument-inspecting patch.
$args = Stack\top('args');
$caller = Stack\all()[1];
foreach ($offsets as $offset) {
# Callback absent
if (!isset($args[$offset])) {
continue;
}
$callable = $args[$offset];
# Callback is a closure => definitely not internal
if ($callable instanceof \Closure) {
continue;
}
list($class, $method, $instance) = Utils\interpretCallable($callable);
if (empty($class)) {
# Callback is global function, which might be internal too.
$args[$offset] = function() use ($callable) {
return dispatchDynamic($callable, func_get_args());
};
}
# Callback involves a class => not internal either, since the only internals that
# Patchwork can handle as of 2.0 are global functions.
# However, we must handle all kinds of opaque access here too, such as self:: and
# private methods, because we're actually patching a stub (see INTERNAL_STUB_CODE)
# and not directly call_user_func itself (or usort, or any other of those).
# We must compensate for scope that is lost, and that callback-taking functions
# can make use of.
if (!empty($class)) {
if ($class === 'self' || $class === 'static' || $class === 'parent') {
# We do not discriminate between early and late static binding here: FIXME.
$actualClass = $caller['class'];
if ($class === 'parent') {
$actualClass = get_parent_class($actualClass);
}
$class = $actualClass;
}
# When calling a parent constructor, the reference to the object being
# constructed needs to be extracted from the stack info.
# Also turned out to be necessary to solve this, without any parent
# constructors involved: https://github.com/antecedent/patchwork/issues/99
if (is_null($instance) && isset($caller['object'])) {
$instance = $caller['object'];
}
try {
$reflection = new \ReflectionMethod($class, $method);
$reflection->setAccessible(true);
$args[$offset] = function() use ($reflection, $instance) {
return $reflection->invokeArgs($instance, func_get_args());
};
} catch (\ReflectionException $e) {
# If it's an invalid callable, then just prevent the unexpected propagation
# of ReflectionExceptions.
}
}
}
# Give the inspected arguments back to the *original* definition of the
# callback-taking function, e.g. \array_map(). This works given that the
# present patch is the innermost.
return call_user_func_array($function, $args);
});
}
}
|
This is needed, for instance, to intercept the time() call in call_user_func('time').
For that to happen, we require that if at least one internal function is redefinable, then
call_user_func, preg_replace_callback and other callback-taking internal functions also be
redefinable: see Patchwork\Config.
Here, we go through the callback-taking internals and add argument-inspecting patches
(redefinitions) to them.
The patches are then expected to find the "nested" internal calls, such as the 'time' argument
in call_user_func('time'), and invoke their respective redefinitions, if any.
|
connectDefaultInternals
|
php
|
antecedent/patchwork
|
src/CallRerouting.php
|
https://github.com/antecedent/patchwork/blob/master/src/CallRerouting.php
|
MIT
|
function translateIfLanguageConstruct($callable)
{
if (!is_string($callable)) {
return $callable;
}
if (in_array($callable, Config\getRedefinableLanguageConstructs())) {
return RedefinitionOfLanguageConstructs\LANGUAGE_CONSTRUCT_PREFIX . $callable;
} elseif (in_array($callable, Config\getSupportedLanguageConstructs())) {
throw new Exceptions\NotUserDefined($callable);
} else {
return $callable;
}
}
|
@since 2.0.5
As of version 2.0.5, this is used to accommodate language constructs
(echo, eval, exit and others) within the concept of callable.
|
translateIfLanguageConstruct
|
php
|
antecedent/patchwork
|
src/CallRerouting.php
|
https://github.com/antecedent/patchwork/blob/master/src/CallRerouting.php
|
MIT
|
function preventImportingOtherCopiesOfPatchwork()
{
return function(Source $s) {
$namespaceKeyword = $s->next(T_NAMESPACE, -1);
if ($namespaceKeyword === INF || $namespaceKeyword < 2) {
return;
}
if ($s->read($namespaceKeyword, 4) == 'namespace Patchwork;') {
$pattern = '/@copyright\s+2010(-\d+)? Ignas Rudaitis/';
if (preg_match($pattern, $s->read($namespaceKeyword - 2))) {
# Clear the file completely (in memory)
$s->splice('', 0, count($s->tokens));
}
}
};
}
|
@since 2.0.1
Serves to avoid "Cannot redeclare Patchwork\redefine()" errors.
|
preventImportingOtherCopiesOfPatchwork
|
php
|
antecedent/patchwork
|
src/CodeManipulation/Actions/ConflictPrevention.php
|
https://github.com/antecedent/patchwork/blob/master/src/CodeManipulation/Actions/ConflictPrevention.php
|
MIT
|
function foo( $a, ...$args ) {
echo "\$a is " . var_export( $a, true ) . "\n";
echo "\$args are " . var_export( $args, true ) . "\n";
}
|
@see https://github.com/antecedent/patchwork/issues/114
|
foo
|
php
|
antecedent/patchwork
|
tests/includes/VariadicsBug.php
|
https://github.com/antecedent/patchwork/blob/master/tests/includes/VariadicsBug.php
|
MIT
|
function foo( &$a, &...$args ) {
$a += 1;
foreach ( $args as &$v ) {
$v += 2;
}
}
|
@see https://github.com/antecedent/patchwork/issues/115
|
foo
|
php
|
antecedent/patchwork
|
tests/includes/VariadicsRefBug.php
|
https://github.com/antecedent/patchwork/blob/master/tests/includes/VariadicsRefBug.php
|
MIT
|
public function actionIndex($message = 'hello world')
{
echo $message . "\n";
}
|
This command echoes what you have entered as the message.
@param string $message the message to be echoed.
|
actionIndex
|
php
|
gugoan/economizzer
|
commands/HelloController.php
|
https://github.com/gugoan/economizzer/blob/master/commands/HelloController.php
|
MIT
|
public function connectCallback($client)
{
// uncomment this to see which attributes you get back
//echo "<pre>";print_r($client->getUserAttributes());echo "</pre>";exit;
// check if user is not logged in. if so, do nothing
if (Yii::$app->user->isGuest) {
return;
}
// check duplicates by provider_id
$attributes = $client->getUserAttributes();
if ($this->checkIsAlreadyConnected($attributes['id'])) {
// register a new user
$userAuth = $this->initUserAuth($client);
$userAuth->setUser(Yii::$app->user->id)->save();
} else {
Yii::$app->session->setFlash('Connect-danger', Yii::t('user','This account has already been connected'));
}
}
|
Connect social auth to the logged-in user
@param \yii\authclient\BaseClient $client
@return \yii\web\Response
@throws \yii\web\ForbiddenHttpException
|
connectCallback
|
php
|
gugoan/economizzer
|
controllers/AuthController.php
|
https://github.com/gugoan/economizzer/blob/master/controllers/AuthController.php
|
MIT
|
protected function checkIsAlreadyConnected($provider_id)
{
$count = UserAuth::find()
->where(['provider_id'=>$provider_id])
->count();
return !($count > 0);
}
|
Returns 'true' if $provider_id is not persist into user_auth
@param $provider_id
@return bool
|
checkIsAlreadyConnected
|
php
|
gugoan/economizzer
|
controllers/AuthController.php
|
https://github.com/gugoan/economizzer/blob/master/controllers/AuthController.php
|
MIT
|
public function actionDisconnect($id){
try{
$result = UserKeychain::disconnect($id);
if ($result == false){
\Yii::$app->session->setFlash("Disconnect-danger", \Yii::t('user', 'Account has already been disabled'));
}else{
\Yii::$app->session->setFlash("Disconnect-success", \Yii::t('user', 'Account successfully disconnected'));
}
}catch (\Exception $e){
\Yii::$app->session->setFlash("Disconnect-danger", \Yii::t('user', $e->getMessage()));
}
$this->goBack();
}
|
Disconnect social account by id and go back
@param $id
|
actionDisconnect
|
php
|
gugoan/economizzer
|
controllers/AuthController.php
|
https://github.com/gugoan/economizzer/blob/master/controllers/AuthController.php
|
MIT
|
public function search($params)
{
$query = Dashboard::find();
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
// grid filtering conditions
$query->andFilterWhere([
'id' => $this->id,
'value' => $this->value,
'date' => $this->date,
'is_pending' => $this->is_pending,
'inc_datetime' => $this->inc_datetime,
'edit_datetime' => $this->edit_datetime,
'user_id' => $this->user_id,
'category_id' => $this->category_id,
'type_id' => $this->type_id,
]);
$query->andFilterWhere(['like', 'description', $this->description])
->andFilterWhere(['like', 'attachment', $this->attachment]);
return $dataProvider;
}
|
Creates data provider instance with search query applied
@param array $params
@return ActiveDataProvider
|
search
|
php
|
gugoan/economizzer
|
models/DashboardSearch.php
|
https://github.com/gugoan/economizzer/blob/master/models/DashboardSearch.php
|
MIT
|
public static function getKeychainConnects()
{
$connectedAccounts = [];
$accounts = UserAuth::find()
->where(['user_id' => \Yii::$app->user->id])
->orderBy('create_time')
->all();
if ($accounts){
foreach ($accounts as $account){
switch ($account->provider){
case 'google':
$connectedAccounts[] = self::parseGoogleProviderAttributes($account);
break;
case 'facebook':
$connectedAccounts[] = self::parseFacebookProviderAttributes($account);
break;
case 'twitter':
$connectedAccounts[] = self::parseTwitterProviderAttributes($account);
break;
case 'vkontakte':
$connectedAccounts[] = self::parseVkontakteProviderAttributes($account);
break;
}
}
}
return $connectedAccounts;
}
|
Select all records from user_auth for current user and extract provider attributes
@return array
|
getKeychainConnects
|
php
|
gugoan/economizzer
|
models/UserKeychain.php
|
https://github.com/gugoan/economizzer/blob/master/models/UserKeychain.php
|
MIT
|
protected static function parseGoogleProviderAttributes($account)
{
$encodedAttributes = json_decode($account->provider_attributes);
return [
'displayName' => $encodedAttributes->displayName,
'imageUrl' => $encodedAttributes->image->url,
'url' => $encodedAttributes->url,
'provider' => $account->provider,
'user_id' => $account->user_id,
'id' => $account->id,
];
}
|
Extract provider attributes from google account
@param $account
@return array
|
parseGoogleProviderAttributes
|
php
|
gugoan/economizzer
|
models/UserKeychain.php
|
https://github.com/gugoan/economizzer/blob/master/models/UserKeychain.php
|
MIT
|
protected static function parseFacebookProviderAttributes($account)
{
$encodedAttributes = json_decode($account->provider_attributes);
return [
'displayName' => $encodedAttributes->name,
'imageUrl' => Url::to('//graph.facebook.com/v2.5/'.$encodedAttributes->id.'/picture'),
'url' => Url::to('//facebook.com/'.$encodedAttributes->id),
'provider' => $account->provider,
'user_id' => $account->user_id,
'id' => $account->id,
];
}
|
Extract provider attributes from facebook account
@param $account
@return array
|
parseFacebookProviderAttributes
|
php
|
gugoan/economizzer
|
models/UserKeychain.php
|
https://github.com/gugoan/economizzer/blob/master/models/UserKeychain.php
|
MIT
|
protected static function parseTwitterProviderAttributes($account)
{
$encodedAttributes = json_decode($account->provider_attributes);
return [
'displayName' => $encodedAttributes->screen_name,
'imageUrl' => $encodedAttributes->profile_image_url_https,
'url' => Url::to('//twitter.com/intent/user?user_id='.$encodedAttributes->id),
'provider' => $account->provider,
'user_id' => $account->user_id,
'id' => $account->id,
];
}
|
Extract provider attributes from twitter account
@param $account
@return array
|
parseTwitterProviderAttributes
|
php
|
gugoan/economizzer
|
models/UserKeychain.php
|
https://github.com/gugoan/economizzer/blob/master/models/UserKeychain.php
|
MIT
|
protected static function parseVkontakteProviderAttributes($account)
{
$encodedAttributes = json_decode($account->provider_attributes);
return [
'displayName' => $encodedAttributes->first_name.' '.$encodedAttributes->last_name,
'imageUrl' => $encodedAttributes->photo,
'url' => Url::to('//vk.com/'.$encodedAttributes->id),
'provider' => $account->provider,
'user_id' => $account->user_id,
'id' => $account->id,
];
}
|
Extract provider attributes from Vkontakte account
@param $account
@return array
|
parseVkontakteProviderAttributes
|
php
|
gugoan/economizzer
|
models/UserKeychain.php
|
https://github.com/gugoan/economizzer/blob/master/models/UserKeychain.php
|
MIT
|
protected function defaultClients()
{
/* @var $collection \yii\authclient\Collection */
$collection = \Yii::$app->get($this->clientCollection);
$collectionClients = $collection->getClients();
$providersToExclude = [];
foreach($this->keychainConnects as $connect){
$providersToExclude[] = $connect['provider'];
}
$clients = [];
foreach ($collectionClients as $id=>$client){
if(!in_array($id,$providersToExclude)){
$clients[$id] = $client;
}
}
return $clients;
}
|
Returns default auth clients list.
@return ClientInterface[] auth clients list.
|
defaultClients
|
php
|
gugoan/economizzer
|
widgets/authchoice/AuthChoice.php
|
https://github.com/gugoan/economizzer/blob/master/widgets/authchoice/AuthChoice.php
|
MIT
|
public function appendHandler($handler)
{
array_unshift($this->handlerStack, $this->resolveHandler($handler));
return $this;
}
|
Explicitly request your handler runs as the last of all currently registered handlers.
@param callable|HandlerInterface $handler
@return Run
|
appendHandler
|
php
|
filp/whoops
|
src/Whoops/Run.php
|
https://github.com/filp/whoops/blob/master/src/Whoops/Run.php
|
MIT
|
public function prependHandler($handler)
{
return $this->pushHandler($handler);
}
|
Explicitly request your handler runs as the first of all currently registered handlers.
@param callable|HandlerInterface $handler
@return Run
|
prependHandler
|
php
|
filp/whoops
|
src/Whoops/Run.php
|
https://github.com/filp/whoops/blob/master/src/Whoops/Run.php
|
MIT
|
public function pushHandler($handler)
{
$this->handlerStack[] = $this->resolveHandler($handler);
return $this;
}
|
Register your handler as the last of all currently registered handlers (to be executed first).
Prefer using appendHandler and prependHandler for clarity.
@param callable|HandlerInterface $handler
@return Run
@throws InvalidArgumentException If argument is not callable or instance of HandlerInterface.
|
pushHandler
|
php
|
filp/whoops
|
src/Whoops/Run.php
|
https://github.com/filp/whoops/blob/master/src/Whoops/Run.php
|
MIT
|
public function popHandler()
{
return array_pop($this->handlerStack);
}
|
Removes and returns the last handler pushed to the handler stack.
@see Run::removeFirstHandler(), Run::removeLastHandler()
@return HandlerInterface|null
|
popHandler
|
php
|
filp/whoops
|
src/Whoops/Run.php
|
https://github.com/filp/whoops/blob/master/src/Whoops/Run.php
|
MIT
|
public function removeFirstHandler()
{
array_pop($this->handlerStack);
}
|
Removes the first handler.
@return void
|
removeFirstHandler
|
php
|
filp/whoops
|
src/Whoops/Run.php
|
https://github.com/filp/whoops/blob/master/src/Whoops/Run.php
|
MIT
|
public function removeLastHandler()
{
array_shift($this->handlerStack);
}
|
Removes the last handler.
@return void
|
removeLastHandler
|
php
|
filp/whoops
|
src/Whoops/Run.php
|
https://github.com/filp/whoops/blob/master/src/Whoops/Run.php
|
MIT
|
public function getHandlers()
{
return $this->handlerStack;
}
|
Returns an array with all handlers, in the order they were added to the stack.
@return array
|
getHandlers
|
php
|
filp/whoops
|
src/Whoops/Run.php
|
https://github.com/filp/whoops/blob/master/src/Whoops/Run.php
|
MIT
|
public function clearHandlers()
{
$this->handlerStack = [];
return $this;
}
|
Clears all handlers in the handlerStack, including the default PrettyPage handler.
@return Run
|
clearHandlers
|
php
|
filp/whoops
|
src/Whoops/Run.php
|
https://github.com/filp/whoops/blob/master/src/Whoops/Run.php
|
MIT
|
public function register()
{
if (!$this->isRegistered) {
// Workaround PHP bug 42098
// https://bugs.php.net/bug.php?id=42098
class_exists("\\Whoops\\Exception\\ErrorException");
class_exists("\\Whoops\\Exception\\FrameCollection");
class_exists("\\Whoops\\Exception\\Frame");
class_exists("\\Whoops\\Exception\\Inspector");
class_exists("\\Whoops\\Inspector\\InspectorFactory");
$this->system->setErrorHandler([$this, self::ERROR_HANDLER]);
$this->system->setExceptionHandler([$this, self::EXCEPTION_HANDLER]);
$this->system->registerShutdownFunction([$this, self::SHUTDOWN_HANDLER]);
$this->isRegistered = true;
}
return $this;
}
|
Registers this instance as an error handler.
@return Run
|
register
|
php
|
filp/whoops
|
src/Whoops/Run.php
|
https://github.com/filp/whoops/blob/master/src/Whoops/Run.php
|
MIT
|
public function unregister()
{
if ($this->isRegistered) {
$this->system->restoreExceptionHandler();
$this->system->restoreErrorHandler();
$this->isRegistered = false;
}
return $this;
}
|
Unregisters all handlers registered by this Whoops\Run instance.
@return Run
|
unregister
|
php
|
filp/whoops
|
src/Whoops/Run.php
|
https://github.com/filp/whoops/blob/master/src/Whoops/Run.php
|
MIT
|
public function allowQuit($exit = null)
{
if (func_num_args() == 0) {
return $this->allowQuit;
}
return $this->allowQuit = (bool) $exit;
}
|
Should Whoops allow Handlers to force the script to quit?
@param bool|int $exit
@return bool
|
allowQuit
|
php
|
filp/whoops
|
src/Whoops/Run.php
|
https://github.com/filp/whoops/blob/master/src/Whoops/Run.php
|
MIT
|
public function silenceErrorsInPaths($patterns, $levels = 10240)
{
$this->silencedPatterns = array_merge(
$this->silencedPatterns,
array_map(
function ($pattern) use ($levels) {
return [
"pattern" => $pattern,
"levels" => $levels,
];
},
(array) $patterns
)
);
return $this;
}
|
Silence particular errors in particular files.
@param array|string $patterns List or a single regex pattern to match.
@param int $levels Defaults to E_STRICT | E_DEPRECATED.
@return Run
|
silenceErrorsInPaths
|
php
|
filp/whoops
|
src/Whoops/Run.php
|
https://github.com/filp/whoops/blob/master/src/Whoops/Run.php
|
MIT
|
public function getSilenceErrorsInPaths()
{
return $this->silencedPatterns;
}
|
Returns an array with silent errors in path configuration.
@return array
|
getSilenceErrorsInPaths
|
php
|
filp/whoops
|
src/Whoops/Run.php
|
https://github.com/filp/whoops/blob/master/src/Whoops/Run.php
|
MIT
|
public function sendHttpCode($code = null)
{
if (func_num_args() == 0) {
return $this->sendHttpCode;
}
if (!$code) {
return $this->sendHttpCode = false;
}
if ($code === true) {
$code = 500;
}
if ($code < 400 || 600 <= $code) {
throw new InvalidArgumentException(
"Invalid status code '$code', must be 4xx or 5xx"
);
}
return $this->sendHttpCode = $code;
}
|
Should Whoops send HTTP error code to the browser if possible?
Whoops will by default send HTTP code 500, but you may wish to
use 502, 503, or another 5xx family code.
@param bool|int $code
@return int|false
@throws InvalidArgumentException
|
sendHttpCode
|
php
|
filp/whoops
|
src/Whoops/Run.php
|
https://github.com/filp/whoops/blob/master/src/Whoops/Run.php
|
MIT
|
public function sendExitCode($code = null)
{
if (func_num_args() == 0) {
return $this->sendExitCode;
}
if ($code < 0 || 255 <= $code) {
throw new InvalidArgumentException(
"Invalid status code '$code', must be between 0 and 254"
);
}
return $this->sendExitCode = (int) $code;
}
|
Should Whoops exit with a specific code on the CLI if possible?
Whoops will exit with 1 by default, but you can specify something else.
@param int $code
@return int
@throws InvalidArgumentException
|
sendExitCode
|
php
|
filp/whoops
|
src/Whoops/Run.php
|
https://github.com/filp/whoops/blob/master/src/Whoops/Run.php
|
MIT
|
public function writeToOutput($send = null)
{
if (func_num_args() == 0) {
return $this->sendOutput;
}
return $this->sendOutput = (bool) $send;
}
|
Should Whoops push output directly to the client?
If this is false, output will be returned by handleException.
@param bool|int $send
@return bool
|
writeToOutput
|
php
|
filp/whoops
|
src/Whoops/Run.php
|
https://github.com/filp/whoops/blob/master/src/Whoops/Run.php
|
MIT
|
public function handleException($exception)
{
// Walk the registered handlers in the reverse order
// they were registered, and pass off the exception
$inspector = $this->getInspector($exception);
// Capture output produced while handling the exception,
// we might want to send it straight away to the client,
// or return it silently.
$this->system->startOutputBuffering();
// Just in case there are no handlers:
$handlerResponse = null;
$handlerContentType = null;
try {
foreach (array_reverse($this->handlerStack) as $handler) {
$handler->setRun($this);
$handler->setInspector($inspector);
$handler->setException($exception);
// The HandlerInterface does not require an Exception passed to handle()
// and neither of our bundled handlers use it.
// However, 3rd party handlers may have already relied on this parameter,
// and removing it would be possibly breaking for users.
$handlerResponse = $handler->handle($exception);
// Collect the content type for possible sending in the headers.
$handlerContentType = method_exists($handler, 'contentType') ? $handler->contentType() : null;
if (in_array($handlerResponse, [Handler::LAST_HANDLER, Handler::QUIT])) {
// The Handler has handled the exception in some way, and
// wishes to quit execution (Handler::QUIT), or skip any
// other handlers (Handler::LAST_HANDLER). If $this->allowQuit
// is false, Handler::QUIT behaves like Handler::LAST_HANDLER
break;
}
}
$willQuit = $handlerResponse == Handler::QUIT && $this->allowQuit();
} finally {
$output = $this->system->cleanOutputBuffer();
}
// If we're allowed to, send output generated by handlers directly
// to the output, otherwise, and if the script doesn't quit, return
// it so that it may be used by the caller
if ($this->writeToOutput()) {
// @todo Might be able to clean this up a bit better
if ($willQuit) {
// Cleanup all other output buffers before sending our output:
while ($this->system->getOutputBufferLevel() > 0) {
$this->system->endOutputBuffering();
}
// Send any headers if needed:
if (Misc::canSendHeaders() && $handlerContentType) {
header("Content-Type: {$handlerContentType}");
}
}
$this->writeToOutputNow($output);
}
if ($willQuit) {
// HHVM fix for https://github.com/facebook/hhvm/issues/4055
$this->system->flushOutputBuffer();
$this->system->stopExecution(
$this->sendExitCode()
);
}
return $output;
}
|
Handles an exception, ultimately generating a Whoops error page.
@param Throwable $exception
@return string Output generated by handlers.
|
handleException
|
php
|
filp/whoops
|
src/Whoops/Run.php
|
https://github.com/filp/whoops/blob/master/src/Whoops/Run.php
|
MIT
|
public function handleError($level, $message, $file = null, $line = null)
{
if ($level & $this->system->getErrorReportingLevel()) {
foreach ($this->silencedPatterns as $entry) {
$pathMatches = (bool) preg_match($entry["pattern"], $file);
$levelMatches = $level & $entry["levels"];
if ($pathMatches && $levelMatches) {
// Ignore the error, abort handling
// See https://github.com/filp/whoops/issues/418
return true;
}
}
// XXX we pass $level for the "code" param only for BC reasons.
// see https://github.com/filp/whoops/issues/267
$exception = new ErrorException($message, /*code*/ $level, /*severity*/ $level, $file, $line);
if ($this->canThrowExceptions) {
throw $exception;
} else {
$this->handleException($exception);
}
// Do not propagate errors which were already handled by Whoops.
return true;
}
// Propagate error to the next handler, allows error_get_last() to
// work on silenced errors.
return false;
}
|
Converts generic PHP errors to \ErrorException instances, before passing them off to be handled.
This method MUST be compatible with set_error_handler.
@param int $level
@param string $message
@param string|null $file
@param int|null $line
@return bool
@throws ErrorException
|
handleError
|
php
|
filp/whoops
|
src/Whoops/Run.php
|
https://github.com/filp/whoops/blob/master/src/Whoops/Run.php
|
MIT
|
public function handleShutdown()
{
// If we reached this step, we are in shutdown handler.
// An exception thrown in a shutdown handler will not be propagated
// to the exception handler. Pass that information along.
$this->canThrowExceptions = false;
// If we are not currently registered, we should not do anything
if (!$this->isRegistered) {
return;
}
$error = $this->system->getLastError();
if ($error && Misc::isLevelFatal($error['type'])) {
// If there was a fatal error,
// it was not handled in handleError yet.
$this->allowQuit = false;
$this->handleError(
$error['type'],
$error['message'],
$error['file'],
$error['line']
);
}
}
|
Special case to deal with Fatal errors and the like.
@return void
|
handleShutdown
|
php
|
filp/whoops
|
src/Whoops/Run.php
|
https://github.com/filp/whoops/blob/master/src/Whoops/Run.php
|
MIT
|
private function resolveHandler($handler)
{
if (is_callable($handler)) {
$handler = new CallbackHandler($handler);
}
if (!$handler instanceof HandlerInterface) {
throw new InvalidArgumentException(
"Handler must be a callable, or instance of "
. "Whoops\\Handler\\HandlerInterface"
);
}
return $handler;
}
|
Resolves the giving handler.
@param callable|HandlerInterface $handler
@return HandlerInterface
@throws InvalidArgumentException
|
resolveHandler
|
php
|
filp/whoops
|
src/Whoops/Run.php
|
https://github.com/filp/whoops/blob/master/src/Whoops/Run.php
|
MIT
|
private function writeToOutputNow($output)
{
if ($this->sendHttpCode() && Misc::canSendHeaders()) {
$this->system->setHttpResponseCode(
$this->sendHttpCode()
);
}
echo $output;
return $this;
}
|
Echo something to the browser.
@param string $output
@return Run
|
writeToOutputNow
|
php
|
filp/whoops
|
src/Whoops/Run.php
|
https://github.com/filp/whoops/blob/master/src/Whoops/Run.php
|
MIT
|
public static function formatExceptionAsDataArray(InspectorInterface $inspector, $shouldAddTrace, array $frameFilters = [])
{
$exception = $inspector->getException();
$response = [
'type' => get_class($exception),
'message' => $exception->getMessage(),
'code' => $exception->getCode(),
'file' => $exception->getFile(),
'line' => $exception->getLine(),
];
if ($shouldAddTrace) {
$frames = $inspector->getFrames($frameFilters);
$frameData = [];
foreach ($frames as $frame) {
/** @var Frame $frame */
$frameData[] = [
'file' => $frame->getFile(),
'line' => $frame->getLine(),
'function' => $frame->getFunction(),
'class' => $frame->getClass(),
'args' => $frame->getArgs(),
];
}
$response['trace'] = $frameData;
}
return $response;
}
|
Returns all basic information about the exception in a simple array
for further convertion to other languages
@param InspectorInterface $inspector
@param bool $shouldAddTrace
@param array<callable> $frameFilters
@return array
|
formatExceptionAsDataArray
|
php
|
filp/whoops
|
src/Whoops/Exception/Formatter.php
|
https://github.com/filp/whoops/blob/master/src/Whoops/Exception/Formatter.php
|
MIT
|
public function getFile($shortened = false)
{
if (empty($this->frame['file'])) {
return null;
}
$file = $this->frame['file'];
// Check if this frame occurred within an eval().
// @todo: This can be made more reliable by checking if we've entered
// eval() in a previous trace, but will need some more work on the upper
// trace collector(s).
if (preg_match('/^(.*)\((\d+)\) : (?:eval\(\)\'d|assert) code$/', $file, $matches)) {
$file = $this->frame['file'] = $matches[1];
$this->frame['line'] = (int) $matches[2];
}
if ($shortened && is_string($file)) {
// Replace the part of the path that all frames have in common, and add 'soft hyphens' for smoother line-breaks.
$dirname = dirname(dirname(dirname(dirname(dirname(dirname(__DIR__))))));
if ($dirname !== '/') {
$file = str_replace($dirname, "…", $file);
}
$file = str_replace("/", "/­", $file);
}
return $file;
}
|
@param bool $shortened
@return string|null
|
getFile
|
php
|
filp/whoops
|
src/Whoops/Exception/Frame.php
|
https://github.com/filp/whoops/blob/master/src/Whoops/Exception/Frame.php
|
MIT
|
public function getFileContents()
{
if ($this->fileContentsCache === null && $filePath = $this->getFile()) {
// Leave the stage early when 'Unknown' or '[internal]' is passed
// this would otherwise raise an exception when
// open_basedir is enabled.
if ($filePath === "Unknown" || $filePath === '[internal]') {
return null;
}
try {
$this->fileContentsCache = file_get_contents($filePath);
} catch (ErrorException $exception) {
// Internal file paths of PHP extensions cannot be opened
}
}
return $this->fileContentsCache;
}
|
Returns the full contents of the file for this frame,
if it's known.
@return string|null
|
getFileContents
|
php
|
filp/whoops
|
src/Whoops/Exception/Frame.php
|
https://github.com/filp/whoops/blob/master/src/Whoops/Exception/Frame.php
|
MIT
|
public function addComment($comment, $context = 'global')
{
$this->comments[] = [
'comment' => $comment,
'context' => $context,
];
}
|
Adds a comment to this frame, that can be received and
used by other handlers. For example, the PrettyPage handler
can attach these comments under the code for each frame.
An interesting use for this would be, for example, code analysis
& annotations.
@param string $comment
@param string $context Optional string identifying the origin of the comment
|
addComment
|
php
|
filp/whoops
|
src/Whoops/Exception/Frame.php
|
https://github.com/filp/whoops/blob/master/src/Whoops/Exception/Frame.php
|
MIT
|
public function getComments($filter = null)
{
$comments = $this->comments;
if ($filter !== null) {
$comments = array_filter($comments, function ($c) use ($filter) {
return $c['context'] == $filter;
});
}
return $comments;
}
|
Returns all comments for this frame. Optionally allows
a filter to only retrieve comments from a specific
context.
@param string $filter
@return array[]
|
getComments
|
php
|
filp/whoops
|
src/Whoops/Exception/Frame.php
|
https://github.com/filp/whoops/blob/master/src/Whoops/Exception/Frame.php
|
MIT
|
public function getRawFrame()
{
return $this->frame;
}
|
Returns the array containing the raw frame data from which
this Frame object was built
@return array
|
getRawFrame
|
php
|
filp/whoops
|
src/Whoops/Exception/Frame.php
|
https://github.com/filp/whoops/blob/master/src/Whoops/Exception/Frame.php
|
MIT
|
public function getFileLines($start = 0, $length = null)
{
if (null !== ($contents = $this->getFileContents())) {
$lines = explode("\n", $contents);
// Get a subset of lines from $start to $end
if ($length !== null) {
$start = (int) $start;
$length = (int) $length;
if ($start < 0) {
$start = 0;
}
if ($length <= 0) {
throw new InvalidArgumentException(
"\$length($length) cannot be lower or equal to 0"
);
}
$lines = array_slice($lines, $start, $length, true);
}
return $lines;
}
}
|
Returns the contents of the file for this frame as an
array of lines, and optionally as a clamped range of lines.
NOTE: lines are 0-indexed
@example
Get all lines for this file
$frame->getFileLines(); // => array( 0 => '<?php', 1 => '...', ...)
@example
Get one line for this file, starting at line 10 (zero-indexed, remember!)
$frame->getFileLines(9, 1); // array( 9 => '...' )
@throws InvalidArgumentException if $length is less than or equal to 0
@param int $start
@param int $length
@return string[]|null
|
getFileLines
|
php
|
filp/whoops
|
src/Whoops/Exception/Frame.php
|
https://github.com/filp/whoops/blob/master/src/Whoops/Exception/Frame.php
|
MIT
|
public function serialize()
{
$frame = $this->frame;
if (!empty($this->comments)) {
$frame['_comments'] = $this->comments;
}
return serialize($frame);
}
|
Implements the Serializable interface, with special
steps to also save the existing comments.
@see Serializable::serialize
@return string
|
serialize
|
php
|
filp/whoops
|
src/Whoops/Exception/Frame.php
|
https://github.com/filp/whoops/blob/master/src/Whoops/Exception/Frame.php
|
MIT
|
public function unserialize($serializedFrame)
{
$frame = unserialize($serializedFrame);
if (!empty($frame['_comments'])) {
$this->comments = $frame['_comments'];
unset($frame['_comments']);
}
$this->frame = $frame;
}
|
Unserializes the frame data, while also preserving
any existing comment data.
@see Serializable::unserialize
@param string $serializedFrame
|
unserialize
|
php
|
filp/whoops
|
src/Whoops/Exception/Frame.php
|
https://github.com/filp/whoops/blob/master/src/Whoops/Exception/Frame.php
|
MIT
|
public function equals(Frame $frame)
{
if (!$this->getFile() || $this->getFile() === 'Unknown' || !$this->getLine()) {
return false;
}
return $frame->getFile() === $this->getFile() && $frame->getLine() === $this->getLine();
}
|
Compares Frame against one another
@param Frame $frame
@return bool
|
equals
|
php
|
filp/whoops
|
src/Whoops/Exception/Frame.php
|
https://github.com/filp/whoops/blob/master/src/Whoops/Exception/Frame.php
|
MIT
|
public function isApplication()
{
return $this->application;
}
|
Returns whether this frame belongs to the application or not.
@return boolean
|
isApplication
|
php
|
filp/whoops
|
src/Whoops/Exception/Frame.php
|
https://github.com/filp/whoops/blob/master/src/Whoops/Exception/Frame.php
|
MIT
|
public function setApplication($application)
{
$this->application = $application;
}
|
Mark as an frame belonging to the application.
@param boolean $application
|
setApplication
|
php
|
filp/whoops
|
src/Whoops/Exception/Frame.php
|
https://github.com/filp/whoops/blob/master/src/Whoops/Exception/Frame.php
|
MIT
|
public function filter($callable)
{
$this->frames = array_values(array_filter($this->frames, $callable));
return $this;
}
|
Filters frames using a callable, returns the same FrameCollection
@param callable $callable
@return FrameCollection
|
filter
|
php
|
filp/whoops
|
src/Whoops/Exception/FrameCollection.php
|
https://github.com/filp/whoops/blob/master/src/Whoops/Exception/FrameCollection.php
|
MIT
|
public function map($callable)
{
// Contain the map within a higher-order callable
// that enforces type-correctness for the $callable
$this->frames = array_map(function ($frame) use ($callable) {
$frame = call_user_func($callable, $frame);
if (!$frame instanceof Frame) {
throw new UnexpectedValueException(
"Callable to " . __CLASS__ . "::map must return a Frame object"
);
}
return $frame;
}, $this->frames);
return $this;
}
|
Map the collection of frames
@param callable $callable
@return FrameCollection
|
map
|
php
|
filp/whoops
|
src/Whoops/Exception/FrameCollection.php
|
https://github.com/filp/whoops/blob/master/src/Whoops/Exception/FrameCollection.php
|
MIT
|
public function getArray()
{
return $this->frames;
}
|
Returns an array with all frames, does not affect
the internal array.
@todo If this gets any more complex than this,
have getIterator use this method.
@see FrameCollection::getIterator
@return array
|
getArray
|
php
|
filp/whoops
|
src/Whoops/Exception/FrameCollection.php
|
https://github.com/filp/whoops/blob/master/src/Whoops/Exception/FrameCollection.php
|
MIT
|
#[ReturnTypeWillChange]
public function offsetExists($offset)
{
return isset($this->frames[$offset]);
}
|
@see ArrayAccess::offsetExists
@param int $offset
|
offsetExists
|
php
|
filp/whoops
|
src/Whoops/Exception/FrameCollection.php
|
https://github.com/filp/whoops/blob/master/src/Whoops/Exception/FrameCollection.php
|
MIT
|
#[ReturnTypeWillChange]
public function offsetGet($offset)
{
return $this->frames[$offset];
}
|
@see ArrayAccess::offsetGet
@param int $offset
|
offsetGet
|
php
|
filp/whoops
|
src/Whoops/Exception/FrameCollection.php
|
https://github.com/filp/whoops/blob/master/src/Whoops/Exception/FrameCollection.php
|
MIT
|
#[ReturnTypeWillChange]
public function offsetSet($offset, $value)
{
throw new \Exception(__CLASS__ . ' is read only');
}
|
@see ArrayAccess::offsetSet
@param int $offset
|
offsetSet
|
php
|
filp/whoops
|
src/Whoops/Exception/FrameCollection.php
|
https://github.com/filp/whoops/blob/master/src/Whoops/Exception/FrameCollection.php
|
MIT
|
#[ReturnTypeWillChange]
public function offsetUnset($offset)
{
throw new \Exception(__CLASS__ . ' is read only');
}
|
@see ArrayAccess::offsetUnset
@param int $offset
|
offsetUnset
|
php
|
filp/whoops
|
src/Whoops/Exception/FrameCollection.php
|
https://github.com/filp/whoops/blob/master/src/Whoops/Exception/FrameCollection.php
|
MIT
|
public function countIsApplication()
{
return count(array_filter($this->frames, function (Frame $f) {
return $f->isApplication();
}));
}
|
Count the frames that belongs to the application.
@return int
|
countIsApplication
|
php
|
filp/whoops
|
src/Whoops/Exception/FrameCollection.php
|
https://github.com/filp/whoops/blob/master/src/Whoops/Exception/FrameCollection.php
|
MIT
|
#[ReturnTypeWillChange]
public function unserialize($serializedFrames)
{
$this->frames = unserialize($serializedFrames);
}
|
@see Serializable::unserialize
@param string $serializedFrames
|
unserialize
|
php
|
filp/whoops
|
src/Whoops/Exception/FrameCollection.php
|
https://github.com/filp/whoops/blob/master/src/Whoops/Exception/FrameCollection.php
|
MIT
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.