From c218095dc937714e13e14a2f165520dd4a91f578 Mon Sep 17 00:00:00 2001 From: Alberto Parziale Date: Thu, 6 Feb 2020 11:39:10 +0100 Subject: [PATCH] update featured image decoration and bump to v1.0.0 --- Malini/Abstracts/PostDecorator.php | 18 +-- Malini/Accessors/MediaAccessor.php | 79 ++++---------- Malini/Decorators/WithFeaturedImage.php | 19 ++-- Malini/Helpers/AccessorRegistry.php | 42 ++++--- Malini/Helpers/FieldsTree.php | 61 ++++++----- Malini/Malini.php | 50 ++++----- Malini/Post.php | 139 ++++++++++++++++-------- Malini/helpers.php | 25 ++--- malini.php | 12 +- vendor/composer/ClassLoader.php | 4 +- 10 files changed, 227 insertions(+), 222 deletions(-) mode change 100755 => 100644 malini.php diff --git a/Malini/Abstracts/PostDecorator.php b/Malini/Abstracts/PostDecorator.php index 1ab8501..0dafdbc 100644 --- a/Malini/Abstracts/PostDecorator.php +++ b/Malini/Abstracts/PostDecorator.php @@ -8,27 +8,31 @@ abstract class PostDecorator implements PostDecoratorInterface { - - public function __construct(Post $post, array $options = []) { + public function __construct(Post $post, array $options = []) + { $this->decorate($post, $options); + return $post; } - public function decorate(Post $post, array $_options = []) : Post { + public function decorate(Post $post, array $_options = []): Post + { return $post; } - public function getConfig(string $option_name, array $options, $default) { + public function getConfig(string $option_name, array $options, $default) + { return isset($options[$option_name]) ? $options[$option_name] : $default; } - public function filterConfig(Post $post, array $options = [], array $default = []) { + public function filterConfig(Post $post, array $options = [], array $default = []) + { $fields = $this->getConfig('filter', $options, $default); + $post->addShowFields( FieldsTree::parse($fields) ); } - -} \ No newline at end of file +} diff --git a/Malini/Accessors/MediaAccessor.php b/Malini/Accessors/MediaAccessor.php index 0a733f8..5b4e9e3 100644 --- a/Malini/Accessors/MediaAccessor.php +++ b/Malini/Accessors/MediaAccessor.php @@ -7,11 +7,11 @@ /** * The `media` accessor retrieves media related to the post. - * + * * Syntax: - * + * * @media:{size},{media_meta_key_or_id},{media_property_key} - * + * * - {size}: media size (full, thumbnail, etc.; custom sizes are accepted as * long as they have been registered); * - {media_meta_key_or_id}: if the id of the wanted media is saved inside a @@ -27,72 +27,33 @@ */ class MediaAccessor implements AccessorInterface { - - protected static $media_cache = []; - - public function getThumbnailData($thumbnail_id) { - $thumbnail_key = 't_' . $thumbnail_id; - if (!isset(static::$media_cache[$thumbnail_key])) { - static::$media_cache[$thumbnail_key] = (array)wp_prepare_attachment_for_js($thumbnail_id); - } - return static::$media_cache[$thumbnail_key]; - } - - public function retrieve(Post $post, ...$arguments) { + public function retrieve(Post $post, ...$arguments) + { $wp_post = $post->wp_post; - $size = isset($arguments[0]) - ? $arguments[0] - : 'full'; - - $thumbnail_id = (isset($arguments[1]) && $arguments[1] !== 'this') - ? (int)get_post_meta($wp_post->ID, $arguments[1], true) - : get_post_thumbnail_id($wp_post->ID); + $media_id = (isset($arguments[1]) && $arguments[1] !== 'this') + ? (int) get_post_meta($wp_post->ID, $arguments[1], true) + : get_post_thumbnail_id($wp_post->ID); - if (empty($thumbnail_id)) { + if (empty($media_id)) { return null; } - $media_property_key = isset($arguments[2]) - ? (string)$arguments[2] - : null; - - $thumbnail_data = static::getThumbnailData($thumbnail_id); - if (!isset($thumbnail_data['sizes'][$size])) { - $size = 'full'; - } - - if (empty($thumbnail_data)) { - return null; - } - - $selected_size = $thumbnail_data['sizes'][$size]; - $media = [ - 'name' => $thumbnail_data['name'], - 'filename' => $thumbnail_data['filename'], - 'alt' => $thumbnail_data['alt'], - 'caption' => $thumbnail_data['caption'], - 'description' => $thumbnail_data['description'], - 'originalurl' => $thumbnail_data['url'], - 'mime' => $thumbnail_data['mime'], - 'type' => $thumbnail_data['type'], - 'subtype' => $thumbnail_data['subtype'], - 'filesize' => $thumbnail_data['filesizeInBytes'], - 'readablefilesize' => $thumbnail_data['filesizeHumanReadable'], - 'size' => $size, - 'url' => $selected_size['url'], - 'width' => $selected_size['width'], - 'height' => $selected_size['height'], - 'orientation' => $selected_size['orientation'], - 'ratio' => $selected_size['width'] / $selected_size['height'] + 'meta' => get_post($media_id), ]; + if (isset($arguments[0])) { + $sizes = explode($arguments[0]); + } else { + $sizes = get_intermediate_image_sizes(); + $sizes[] = 'full'; + } - if (!empty($media_property_key) && isset($media[$media_property_key])) { - return $media[$media_property_key]; + foreach ($sizes as $size) { + $media[$size] = wp_get_attachment_image_src($media_id, $size); + $media[$size][3] = $media[$size][2] / $media[$size][1]; } return $media; } - -} \ No newline at end of file +} diff --git a/Malini/Decorators/WithFeaturedImage.php b/Malini/Decorators/WithFeaturedImage.php index 41bc692..ea3d15c 100644 --- a/Malini/Decorators/WithFeaturedImage.php +++ b/Malini/Decorators/WithFeaturedImage.php @@ -8,29 +8,28 @@ /** * The `featuredimage` decorator enrich the `Malini\Post` with the data regarding the feature selected for this post. - * + * * Attributes added: * - `thumbnail`: the featured image data in its `thumbnail` size; * - `featuredimage`: the featured image data in its `full` size. - * + * * Options: * - `filter`: the attributes we want to retrieve */ -class WithFeaturedImage extends PostDecorator implements PostDecoratorInterface { - - public function decorate(Post $post, array $options = []) : Post { +class WithFeaturedImage extends PostDecorator implements PostDecoratorInterface +{ + public function decorate(Post $post, array $options = []): Post + { $post->addRawAttributes([ - 'thumbnail' => '@media:thumbnail', - 'featuredimage' => '@media:full' + 'featuredimage' => '@media', ]); $this->filterConfig( $post, $options, - [ 'thumbnail', 'featuredimage' ] + ['featuredimage'] ); return $post; } - -} \ No newline at end of file +} diff --git a/Malini/Helpers/AccessorRegistry.php b/Malini/Helpers/AccessorRegistry.php index 8dd0a5f..9b7deef 100644 --- a/Malini/Helpers/AccessorRegistry.php +++ b/Malini/Helpers/AccessorRegistry.php @@ -8,45 +8,49 @@ /** * Accessors are utilities that helps retrieve data in a structured way. * They can be described using simple strings with the following syntax (curly - * brackets indicates placeholders): - * + * brackets indicates placeholders):. + * * @{accessor_name}:{param_1},{param_2},... - * + * * - {accessor_name}: is the name of the registered accessor; * - {param_N}: is the N-th param to pass to the accessor. - * + * * If no {accessor_name} is specified, the `BaseAccessor` will be used. - * + * * Examples: - * + * * - 'post_title' // retrieves the post_title, using the BaseAccessor; * - '@base:post_title' // retrieves the post_title, using the BaseAccessor; * - '@meta:_edit_lock' // retrieves the _edit_lock post meta MetaAccessor. */ class AccessorRegistry { - protected static $registered_accessors = []; - public static function has(string $name) { + public static function has(string $name) + { return isset(static::$registered_accessors[$name]); } - public static function get(string $name) { + public static function get(string $name) + { if (!static::has($name)) { throw new \Exception("Unknown `{$name}` accessor"); } + return static::$registered_accessors[$name]; } - public static function register(string $name, $accessor_class_name) { + public static function register(string $name, $accessor_class_name) + { if (!in_array(AccessorInterface::class, class_implements($accessor_class_name))) { throw new \Exception("`{$accessor_class_name}` does not implements the `AccessorInterface`"); } static::$registered_accessors[$name] = new $accessor_class_name(); } - public static function parse(string $source) { + public static function parse(string $source) + { if (strpos($source, '@') === 0) { $pieces = explode(':', substr($source, 1), 2); $accessor = array_shift($pieces); @@ -55,23 +59,27 @@ public static function parse(string $source) { : explode(',', $pieces[0]); } else { $accessor = 'base'; - $params = [ $source ]; + $params = [$source]; } - return [ $accessor, $params ]; + return [$accessor, $params]; } - public static function access(Post $post, string $accessor_name, array $params) { + public static function access(Post $post, string $accessor_name, array $params) + { $accessor = static::get($accessor_name); + return $accessor->retrieve($post, ...$params); } - public static function retrieve(Post $post, $source) { + public static function retrieve(Post $post, $source) + { if (is_callable($source)) { return $source($post); } + list($accessor_name, $params) = static::parse($source); + return static::access($post, $accessor_name, $params); } - -} \ No newline at end of file +} diff --git a/Malini/Helpers/FieldsTree.php b/Malini/Helpers/FieldsTree.php index 7e727f4..a59075d 100644 --- a/Malini/Helpers/FieldsTree.php +++ b/Malini/Helpers/FieldsTree.php @@ -4,15 +4,15 @@ class FieldsTree { - - protected static function strParse(string $filter_field) { + protected static function strParse(string $filter_field) + { if (substr_count($filter_field, '(') !== substr_count($filter_field, ')')) { throw new \Exception( - "Parentheses must be balanced; found " - . substr_count($filter_field, '(') - . ' `(` and ' - . substr_count($filter_field, ')') - . ' `)`' + 'Parentheses must be balanced; found ' + .substr_count($filter_field, '(') + .' `(` and ' + .substr_count($filter_field, ')') + .' `)`' ); } if ($filter_field[0] == '(' && $filter_field[strlen($filter_field) - 1] == ')') { @@ -33,7 +33,7 @@ protected static function strParse(string $filter_field) { --$depth; } else { throw new \Exception( - "Parentheses must be balanced; found a `)` without an equivalent `(`" + 'Parentheses must be balanced; found a `)` without an equivalent `(`' ); } break; @@ -51,16 +51,18 @@ protected static function strParse(string $filter_field) { } if ($depth > 0) { throw new \Exception( - "Parentheses must be balanced; found a `(` without an equivalent `)`" + 'Parentheses must be balanced; found a `(` without an equivalent `)`' ); } if ($buffer !== '') { $stack[] = $buffer; } + return $stack; } - public static function parse($filter_fields, array $opts = []) { + public static function parse($filter_fields, array $opts = []) + { $alias_separator = isset($opts['alias_separator']) ? $opts['alias_separator'] : ':'; @@ -68,7 +70,6 @@ public static function parse($filter_fields, array $opts = []) { if (is_string($filter_fields)) { $filter_fields = static::strParse($filter_fields); } - $fields = []; foreach ($filter_fields as $key => $filter_field) { $callable = null; @@ -76,8 +77,8 @@ public static function parse($filter_fields, array $opts = []) { $numeric_index = false; if (is_int($key) && is_string($filter_field) && strpos($filter_field, '.') > 0) { list($key, $filter_field) = explode('.', $filter_field, 2); - if (ctype_digit((string)$key)) { - $key = (int)$key; + if (ctype_digit((string) $key)) { + $key = (int) $key; $filter_field = $filter_field; $numeric_index = true; } @@ -86,7 +87,7 @@ public static function parse($filter_fields, array $opts = []) { if ($key === '*') { $fields['*'] = static::parse($filter_field); continue; - } else if (is_int($key) && is_array($filter_field)) { + } elseif (is_int($key) && is_array($filter_field)) { if (isset($filter_field['name'])) { $fields[] = [ 'name' => $filter_field['name'], @@ -96,16 +97,16 @@ public static function parse($filter_fields, array $opts = []) { 'filter' => null, 'children' => isset($filter_field['children']) ? static::parse($filter_field['children']) - : [] + : [], ]; } else { - $fields['_' . $key] = static::parse($filter_field); + $fields['_'.$key] = static::parse($filter_field); } continue; - } else if (is_int($key) && $numeric_index) { - $fields['_' . $key] = static::parse($filter_field); + } elseif (is_int($key) && $numeric_index) { + $fields['_'.$key] = static::parse($filter_field); continue; - } else if (is_int($key)) { + } elseif (is_int($key)) { $name = $filter_field; } else { $name = $key; @@ -125,27 +126,29 @@ public static function parse($filter_fields, array $opts = []) { } $fields[] = [ - 'name' => $name, - 'alias' => $alias, - 'filter' => $callable, - 'children' => $children + 'name' => $name, + 'alias' => $alias, + 'filter' => $callable, + 'children' => $children, ]; } + return $fields; } - public static function getIndexedFilter(int $index, array $filter_fields) { - if (isset($filter_fields['_' . $index])) { - return $filter_fields['_' . $index]; - } else if (isset($filter_fields['*'])) { + public static function getIndexedFilter(int $index, array $filter_fields) + { + if (isset($filter_fields['_'.$index])) { + return $filter_fields['_'.$index]; + } elseif (isset($filter_fields['*'])) { return $filter_fields['*']; } $check = str_replace( '_', '', implode('', array_keys($filter_fields)) ); + return []; // throw new \Exception("Undefined indexed filter `{$index}`"); } - -} \ No newline at end of file +} diff --git a/Malini/Malini.php b/Malini/Malini.php index 6cfd25b..2a48090 100644 --- a/Malini/Malini.php +++ b/Malini/Malini.php @@ -1,10 +1,9 @@ booted) { return; } @@ -46,55 +48,41 @@ public function boot() { do_action('malini_register_decorators'); // Init - do_action('malini_init'); - // Register custom actions/filters - add_action( - 'pre_get_posts', - function($query) { - if (!isset($query->query) - || !isset($query->query['post_type']) - || empty(isset($query->query['post_type']))) { - return; - } - $post_types = is_string($query->query['post_type']) - ? [ $query->query['post_type'] ] - : array_unique($query->query['post_type']); - sort($post_types); - do_action( - 'malini_pre_get_' . implode('_', $post_types), - $query - ); - } - ); - $this->booted = true; } - public static function getInstance() { + public static function getInstance() + { if (empty(static::$instance)) { static::$instance = new Malini(); } + return static::$instance; } - public function registerAccessor(string $name, string $namespace) { + public function registerAccessor(string $name, string $namespace) + { AccessorRegistry::register($name, $namespace); + return $this; } - public function registerDecorator(string $name, string $namespace) { + public function registerDecorator(string $name, string $namespace) + { DecoratorRegistry::register($name, $namespace); + return $this; } - public function post(\WP_post $post) { + public function post(\WP_post $post) + { return Post::create($post); } - public function archive(array $posts) { + public function archive(array $posts) + { return Archive::create($posts); } - } diff --git a/Malini/Post.php b/Malini/Post.php index 286f240..783704b 100644 --- a/Malini/Post.php +++ b/Malini/Post.php @@ -10,8 +10,8 @@ use Malini\Interfaces\PostDecoratorInterface; use Malini\Interfaces\SerializableInterface; -class Post implements SerializableInterface { - +class Post implements SerializableInterface +{ protected $attributes = []; protected $casts = []; @@ -28,96 +28,119 @@ class Post implements SerializableInterface { public $custom_fields = null; - public function __construct(\WP_Post $post) { + public function __construct(\WP_Post $post) + { $this->wp_post = $post; } - public static function add(array &$target, string $source, $dest) { + public static function add(array &$target, string $source, $dest) + { $target[$source] = $dest; } - public static function multiAdd(array &$target, array $options) { + public static function multiAdd(array &$target, array $options) + { foreach ($options as $option_src => $option_dest) { static::add($target, $option_src, $option_dest); } } - public function addAttribute(string $source, $dest, bool $dont_add_to_show_fields = false) { + public function addAttribute(string $source, $dest, bool $dont_add_to_show_fields = false) + { static::add($this->attributes, $source, $dest); if (!$dont_add_to_show_fields) { $this->addShowFields( FieldsTree::parse($source) ); } + return $this; } - public function addAttributes(array $attributes, bool $dont_add_to_show_fields = false) { + public function addAttributes(array $attributes, bool $dont_add_to_show_fields = false) + { foreach ($attributes as $attribute_src => $attribute_dest) { $this->addAttribute($attribute_src, $attribute_dest, $dont_add_to_show_fields); } + return $this; } - public function addRawAttribute(string $source, $dest) { + public function addRawAttribute(string $source, $dest) + { return $this->addAttribute($source, $dest, true); } - public function addRawAttributes(array $attributes) { + public function addRawAttributes(array $attributes) + { return $this->addAttributes($attributes, true); } - public function addFilter(string $source, $dest) { + public function addFilter(string $source, $dest) + { static::add($this->filters, $source, $dest); + return $this; } - public function addFilters(array $filters) { + public function addFilters(array $filters) + { static::multiAdd($this->filters, $filters); + return $this; } - public function mapField(string $old_key, string $new_key) { + public function mapField(string $old_key, string $new_key) + { if (isset($this->show[$old_key])) { $this->show[$new_key] = $this->show[$old_key]; unset($this->show[$old_key]); } } - public function map(array $map) { + public function map(array $map) + { foreach ($map as $old_key => $new_key) { $this->mapField($old_key, $new_key); } } - public function extend(string $method_name, $callback) { + public function extend(string $method_name, $callback) + { $this->extensions[$method_name] = $callback; + return $this; } - public function hasMethod(string $method_name) { + public function hasMethod(string $method_name) + { return isset($this->extensions[$method_name]); } - public function __call($method_name, $args) { + public function __call($method_name, $args) + { if ($this->hasMethod($method_name)) { return $this->extensions[$method_name](...$args); } - throw new Exception("Unknown method `$method_name` in class `" . static::class . "`"); + throw new Exception("Unknown method `$method_name` in class `".static::class.'`'); } - public static function create(\WP_Post $post) { + public static function create(\WP_Post $post) + { return new static($post); } - public function loadCustom() { + public function loadCustom() + { if (empty($this->custom_fields)) { $this->custom_fields = get_post_custom($this->wp_post->ID); } + return $this; } - public function getCustom(string $key, $single = null) { + public function getCustom(string $key, $single = null) + { $this->loadCustom(); if (!isset($this->custom_fields[$key])) { return null; @@ -141,7 +164,8 @@ public function getCustom(string $key, $single = null) { } } - public function getGroupedCustom(string $prefix, bool $auto_detect_single = false) { + public function getGroupedCustom(string $prefix, bool $auto_detect_single = false) + { $this->loadCustom(); $data = []; foreach (array_keys($this->custom_fields) as $key) { @@ -152,10 +176,12 @@ public function getGroupedCustom(string $prefix, bool $auto_detect_single = fals } } } + return $data; } - public function getAllCustom(bool $auto_detect_single = false) { + public function getAllCustom(bool $auto_detect_single = false) + { $this->loadCustom(); $data = []; foreach (array_keys($this->custom_fields) as $key) { @@ -164,53 +190,64 @@ public function getAllCustom(bool $auto_detect_single = false) { $data[$key] = $data[$key][0]; } } + return $data; } - public function hasAttribute($attribute_name) { + public function hasAttribute($attribute_name) + { return isset($this->attributes[$attribute_name]); } - public function addShowField(array $field) { + public function addShowField(array $field) + { $this->show[$field['name']] = $field; if (!empty($field['filter'])) { $this->addFilter($field['name'], $field['filter']); } + return $this; } - public function addShowFields(array $fields) { + public function addShowFields(array $fields) + { foreach ($fields as $field) { $this->addShowField($field); } + return $this; } - public function show($fields) { + public function show($fields) + { $this->show = []; $this->addShowFields( FieldsTree::parse($fields) ); + return $this; } - protected function parseFilters($raw_filters) { + protected function parseFilters($raw_filters) + { if ($raw_filters instanceof Closure) { return [ - $raw_filters + $raw_filters, ]; } - return ( + + return is_array($raw_filters) ? $raw_filters : (is_string($raw_filters) ? explode('|', $raw_filters) : [] ) - ); + ; } - protected function applyFilters($attr_name, $value) { + protected function applyFilters($attr_name, $value) + { $attr_filters = isset($this->filters[$attr_name]) ? $this->filters[$attr_name] : []; @@ -220,10 +257,10 @@ protected function applyFilters($attr_name, $value) { if ($filter instanceof Closure) { $value = $filter($value, $attr_name, $this); continue; - } else if (is_array($filter)) { + } elseif (is_array($filter)) { $filter_name = array_shift($filter); $args = $filter; - } else if (is_string($filter)) { + } elseif (is_string($filter)) { $args = explode(':', $filter, 2); $filter_name = array_shift($args); $args = count($args) == 0 @@ -250,7 +287,8 @@ protected function applyFilters($attr_name, $value) { return $value; } - protected static function filterArrayChildren(array $data, $filter_children) { + protected static function filterArrayChildren(array $data, $filter_children) + { $new_data = []; foreach ($filter_children as $attr) { $name = $attr['name']; @@ -260,10 +298,12 @@ protected static function filterArrayChildren(array $data, $filter_children) { ? $data[$name] : static::filterChildren($data[$name], $children); } + return $new_data; } - protected static function filterObjectChildren($data, $filter_children) { + protected static function filterObjectChildren($data, $filter_children) + { $new_data = new \StdClass(); foreach ($filter_children as $attr) { $name = $attr['name']; @@ -273,12 +313,14 @@ protected static function filterObjectChildren($data, $filter_children) { ? $data->{$name} : static::filterChildren($data->{$name}, $children); } + return $new_data; } - protected static function filterChildren($data, array $filter_children) { + protected static function filterChildren($data, array $filter_children) + { if (!is_object($data) && !is_array($data)) { - throw new Exception("Cannot filter children of `" . gettype($data) . "` variable"); + throw new Exception('Cannot filter children of `'.gettype($data).'` variable'); } if (is_object($data)) { @@ -300,20 +342,23 @@ protected static function filterChildren($data, array $filter_children) { return $new_data; } - protected function mapAttributesOnShow() { + protected function mapAttributesOnShow() + { $this->show = []; foreach ($this->attributes as $key => $_value) { $this->show[$key] = [ 'name' => $key, 'alias' => $key, 'filter' => null, - 'children' => [] + 'children' => [], ]; } + return $this->show; } - public function toObject() { + public function toObject() + { $show_attrs = (empty($this->show)) ? $this->mapAttributesOnShow() : $this->show; @@ -334,19 +379,23 @@ public function toObject() { return $to_show; } - public function jsonSerialize() { + public function jsonSerialize() + { return json_encode($this->toObject(), JSON_NUMERIC_CHECK); } - public function toJson() { + public function toJson() + { return $this->jsonSerialize(); } - public function toArray() : array { + public function toArray(): array + { return json_decode($this->jsonSerialize(), true); } - public function decorate(string $decorator, array $options = []) : Post { + public function decorate(string $decorator, array $options = []): Post + { $decorator_namespace = DecoratorRegistry::get($decorator); if (!in_array(PostDecoratorInterface::class, class_implements($decorator_namespace))) { @@ -354,7 +403,7 @@ public function decorate(string $decorator, array $options = []) : Post { } new $decorator_namespace($this, $options); + return $this; } - } diff --git a/Malini/helpers.php b/Malini/helpers.php index 8437dc5..5319da5 100644 --- a/Malini/helpers.php +++ b/Malini/helpers.php @@ -1,8 +1,6 @@ post($post); } } @@ -47,24 +46,21 @@ function malini_archive($posts = null) $posts[] = get_post(); } } - return malini()->archive($posts); - } -} -if (!function_exists('malini_access')) { - function malini_access(Post $post, string $accessor_name, array $params) { - AccessorRegistry::access($post, $accessor_name, $params); + return malini()->archive($posts); } } if (!function_exists('is_sequential_array')) { - function is_sequential_array($value) { + function is_sequential_array($value) + { if (!is_array($value)) { return false; } if ([] === $value) { return true; } + return array_keys($value) === range(0, count($value) - 1); } } @@ -75,13 +71,13 @@ function dump(...$args) $message = implode( "\n\n", array_map( - function($value) { + function ($value) { return var_export($value, true); }, $args ) ); - $is_cli = in_array(php_sapi_name(), [ 'cli', 'cli-server' ]); + $is_cli = in_array(php_sapi_name(), ['cli', 'cli-server']); if (!$is_cli) { $message = preg_replace( [ @@ -96,8 +92,8 @@ function($value) { ], highlight_string( "\n\n", + .$message + ."\n/*begin*/?>\n\n", true ) ); @@ -106,7 +102,6 @@ function($value) { } } - if (!function_exists('dd')) { function dd(...$args) { diff --git a/malini.php b/malini.php old mode 100755 new mode 100644 index a6ac46b..820ffe7 --- a/malini.php +++ b/malini.php @@ -1,8 +1,7 @@ boot(); \Malini\Updater::updateService(); }); diff --git a/vendor/composer/ClassLoader.php b/vendor/composer/ClassLoader.php index dc02dfb..fce8549 100644 --- a/vendor/composer/ClassLoader.php +++ b/vendor/composer/ClassLoader.php @@ -279,7 +279,7 @@ public function isClassMapAuthoritative() */ public function setApcuPrefix($apcuPrefix) { - $this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null; + $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null; } /** @@ -377,7 +377,7 @@ private function findFileWithExtension($class, $ext) $subPath = $class; while (false !== $lastPos = strrpos($subPath, '\\')) { $subPath = substr($subPath, 0, $lastPos); - $search = $subPath.'\\'; + $search = $subPath . '\\'; if (isset($this->prefixDirsPsr4[$search])) { $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); foreach ($this->prefixDirsPsr4[$search] as $dir) {