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

Add additional features - copy of PR/14 #17

Merged
merged 4 commits into from
May 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ I'd also love PRs to add translations. Maybe contact me first or open an issue i

I am manually curating the list of features and related content here. And I'd love for people to help by PR-ing additions.

Feautures to add to the list will need to meet the following criteria:
Features to add to the list will need to meet the following criteria:

* They were added, deprecated or removed in PHP version 5.6 or greater.

Expand All @@ -58,7 +58,7 @@ PHP features are listed in `features.js`. Hopefully the format of this makes sen
* the whole thing is a JSON array
* each entry is an object with the following properties:
* `name`: The name of the feature - plain text only
* `description`: A description of the feature - HTML is allowed, but may not be styled. `<code>` tags are fine.
* `description`: A description of the feature - HTML is allowed, but may not be styled. `<code>` tags are fine and backticks will be converted to code tags.
* `keywords`: An array of strings. These are used when searching, so add strings that people may use to search for this feature.
* `added`: A string for the version of PHP that the feature was added. Must be in the format `X.Y`, e.g. `7.0`. Use `0.0` if this is not known or appropriate.
* `deprecated`: A string for the version of PHP that the feature was deprecated. Must be in the format `X.Y`, e.g. `8.0`. Use `null` if this is not know or appropriate.
Expand Down
59 changes: 59 additions & 0 deletions features.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
const features = [
{
name: 'Fibers (Fiber class, Fiber exceptions)',
description: 'Lightweight concurrency for PHP. Fibers represent full-stack, interruptible functions. Fibers may be suspended from anywhere in the call-stack, pausing execution within the fiber until the fiber is resumed at a later time.',
keywords: [
'class', 'types', 'functionality', 'concurrency', 'interruptible', 'functions'
],
added: '8.1',
deprecated: null,
removed: null,
resources: [
{
name: 'PHP.Watch Introduction to Fibers (php.watch)',
url: 'https://php.watch/versions/8.1/fibers'
}, {
name: 'Fibres overview and documentation (php.net)',
url: 'https://www.php.net/manual/en/language.fibers.php'
}
]
},
{
name: 'Enums',
description: 'Enums are a way to define a set of named constants.',
Expand Down Expand Up @@ -542,5 +561,45 @@ const features = [
url: 'https://www.php.net/manual/en/function.get-magic-quotes-gpc.php'
}
]
},
{
name: 'FILTER_FLAG_SCHEME_REQUIRED constant',
description: 'Filter flag for `filter_var()` for use with `FILTER_VALIDATE_URL`',
keywords: [
'filters', 'constants', 'deprecated', 'removed', 'urls', 'validation'
],
added: '0.0',
deprecated: '7.3.0',
removed: '8.0',
resources: [
{
name: 'Validate filters (php.net)',
url: 'https://www.php.net/manual/en/filter.filters.validate.php'
},
{
name: 'Filter flags (php.net)',
url: 'https://www.php.net/manual/en/filter.filters.flags.php'
}
]
},
{
name: 'FILTER_FLAG_HOST_REQUIRED constant',
description: 'Filter flag for `filter_var()` for use with `FILTER_VALIDATE_URL`',
keywords: [
'filters', 'constants', 'deprecated', 'removed', 'urls', 'validation'
],
added: '0.0',
deprecated: '7.3.0',
removed: '8.0',
resources: [
{
name: 'Validate filters (php.net)',
url: 'https://www.php.net/manual/en/filter.filters.validate.php'
},
{
name: 'Filter flags (php.net)',
url: 'https://www.php.net/manual/en/filter.filters.flags.php'
}
]
}
]
12 changes: 11 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ <h2 x-text="feature.name" class="text-lg mb-4 font-bold"></h2>
<div class="flex">
<!-- Feature top panel, left column -->
<div class="w-3/4 pr-4">
<p x-html="feature.description" class="mb-6"></p>
<p x-html="formatAsHtml(feature.description)" class="mb-6"></p>
<h3 class="font-bold text-l mb-2">Resources</h3>
<ul x-show="feature?.resources?.length > 0" class="list-disc list-inside text-sm mb-4">
<template x-for="resource in feature.resources">
Expand Down Expand Up @@ -184,6 +184,16 @@ <h3 class="font-bold text-l mb-2">Resources</h3>
featuresHaving(featureKeyword) {
const versions = features.filter(feature => this.featureMatches(feature, featureKeyword));
return versions;
},

/*
* This does some basic formatting.
*
* - backticks are converted to <code></code>
*/
formatAsHtml(rawString) {
htmlString = rawString.replace(/`(.*?)`/g, '<code>$1</code>');
return htmlString;
}
}
});
Expand Down