- Install LSP and LSP-intelephense from Package Control.
- Restart
- Then run
composer global require phpactor/phpactor
- Then in LSP settings
"clients": {
"phpactor": {
const signal = (value) => { | |
const fn = () => value; | |
let subscribers = []; | |
const notifySubscribers = () => { | |
subscribers.forEach((subscriber) => subscriber(value)); | |
}; | |
fn.set = (newValue) => { | |
value = newValue; |
interface InjectionInstanceInterface { | |
[key: string]: any; | |
} | |
interface ClassRef<T> extends Function { | |
new (...args: any[]): T; | |
} | |
class InjectService { | |
private instances: InjectionInstanceInterface = {}; |
/** | |
* Parse template string | |
* | |
* @usage parseTemplate(`my name is {name} {nested.name}`, {name: 'foo', nested: { name: 'bar' }}) | |
* @param template string | |
* @param data object | |
* @returns string | |
*/ | |
export function HelperParseTemplate(template: string, data: any): string { | |
return template.replace(/\{([\w\\.]*)\}/g, (str: string, key: string) => { |
version: '3.8' | |
services: | |
db: | |
image: mysql | |
container_name: db | |
environment: | |
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD} | |
MYSQL_DATABASE: ${DB_DATABASE} |
type UserUrl = string; | |
// const getUserUrl = (id: number) => { | |
// return `/user/${id}`; // as const | |
// }; | |
// type UserUrl = ReturnType<typeof getUserUrl>; | |
const url: UserUrl = '/user/2'; |
// The Adapter pattern is a structural design pattern that allows objects with incompatible interfaces to work together. | |
interface NotificationInterface { | |
send(subject: string, message: string): boolean; | |
} | |
class EmailNotification implements NotificationInterface { | |
send(subject: string, message: string): boolean { | |
console.log(`Sending email notification: ${subject} ${message}`); | |
return true; |
// Guard Clause is a technique derived from the fail-fast method | |
// whose purpose is to validate a condition and immediately stop the code execution | |
// about the result of the validation. | |
// Using guard clauses is a common and clean technique for simplifying the code block and avoiding unnecessary complexity. | |
// Example 1 | |
const submitForm = (formData, formMeta) => { | |
if (!formMeta.hasError(formData)) { | |
formData.submit(); | |
} |
// 1 | |
console.log(typeof typeof 1); | |
// 2 | |
console.log(018 - 015); | |
// 3 | |
const numbers = [33, 2, 8]; | |
numbers.sort(); | |
console.log(numbers[1]); |
version: '3.8' | |
services: | |
mongo: | |
image: mongo:latest | |
volumes: | |
- ./.data/mongodb:/data/db | |
environment: | |
MONGO_INITDB_ROOT_USERNAME: root |